sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
1,401 lines (1,389 loc) • 97.2 kB
TypeScript
import { ComponentType, ReactNode } from "react";
import { ObjectSchemaType, Path, SanityDocument, SanityDocumentLike, SchemaType, SortOrdering, SortOrderingItem, ValidationMarker } from "@sanity/types";
import { Observable } from "rxjs";
import { SearchParam } from "sanity/router";
import { ConfigContext, DocumentActionComponent, DocumentBadgeComponent, DocumentFieldAction, DocumentFieldActionNode, DocumentFormNode, DocumentInspector, DocumentLanguageFilterComponent, DocumentStore, EditStateFor, GeneralPreviewLayoutKey, I18nTextRecord as I18nTextRecord$1, InitialValueTemplateItem, LocaleSource, NodeChronologyProps, PatchEvent, PermissionCheckResult, PerspectiveStack, PreviewLayoutKey, ReleaseId, Source, StateTree, TimelineStore } from "sanity";
/**
* Intent parameters (json)
*
* @public
*/
type IntentJsonParams = {
[key: string]: any;
};
/**
* Base intent parameters
*
* @public
* @todo dedupe with core
*/
interface BaseIntentParams {
/**
* Document schema type name to create/edit.
* Required for `create` intents, optional for `edit` (but encouraged, safer and faster)
*/
type?: string;
/**
* ID of the document to create/edit.
* Required for `edit` intents, optional for `create`.
*/
id?: string;
/**
* Name (ID) of initial value template to use for `create` intent. Optional.
*/
template?: string;
/**
* Experimental field path
*
* @beta
* @experimental
* @hidden
*/
path?: string;
/**
* Optional "mode" to use for edit intent.
* Known modes are `structure` and `presentation`.
*/
mode?: string;
/**
* Arbitrary/custom parameters are generally discouraged - try to keep them to a minimum,
* or use `payload` (arbitrary JSON-serializable object) instead.
*/
[key: string]: string | undefined;
}
/** @internal */
declare const DEFAULT_INTENT_HANDLER: unique symbol;
/**
* Intent parameters
* See {@link structure.BaseIntentParams} and {@link structure.IntentJsonParams}
*
* @public
*/
type IntentParams = BaseIntentParams | [BaseIntentParams, IntentJsonParams];
/**
* Interface for intents
* @public */
interface Intent {
/** Intent type */
type: string;
/** Intent parameters. See {@link IntentParams}
*/
params?: IntentParams;
searchParams?: SearchParam[];
}
/**
* Interface for intent checker
*
* @public
*/
interface IntentChecker {
(/** Intent name */intentName: string, /** Intent checker parameter */params: {
[key: string]: any;
}, /** Structure context. See {@link StructureNode} */context: {
pane: StructureNode;
index: number;
}): boolean;
/** intent checker identify */
identity?: symbol;
}
declare function defaultIntentChecker(intentName: string, params: {
[key: string]: any;
}, {
pane
}: {
pane: StructureNode;
index: number;
}): boolean;
declare namespace defaultIntentChecker {
var identity: symbol | undefined;
}
declare class DividerBuilder implements Serializable<Divider> {
protected spec: Divider;
constructor(spec?: Divider);
/** Set the title of the divider
* @param title - the title of the divider
* @returns divider builder based on title provided
*/
title(title: string): DividerBuilder;
/** Get the title of the divider
* @returns the title of the divider
*/
getTitle(): Divider['title'];
/** Set the i18n key and namespace used to populate the localized title.
* @param i18n - the key and namespaced used to populate the localized title.
* @returns divider builder based on i18n key and ns provided
*/
i18n(i18n: I18nTextRecord$1<'title'>): DividerBuilder;
/** Get i18n key and namespace used to populate the localized title
* @returns the i18n key and namespace used to populate the localized title
*/
getI18n(): I18nTextRecord$1<'title'> | undefined;
/** Serialize the divider
* @returns the serialized divider
*/
serialize(): Divider;
/** Clone divider builder (allows for options overriding)
* @param withSpec - divider builder options
* @returns cloned builder
*/
clone(withSpec?: Partial<Divider>): DividerBuilder;
}
/**
* Interface for component views.
*
* @public */
interface ComponentView<TOptions = Record<string, any>> extends BaseView {
type: 'component';
/** Component view components. See {@link UserViewComponent} */
component: UserViewComponent;
/** Component view options */
options: TOptions;
}
/**
* Class for building a component view.
*
* @public */
declare class ComponentViewBuilder extends GenericViewBuilder<Partial<ComponentView>, ComponentViewBuilder> {
/** Partial Component view option object. See {@link ComponentView} */
protected spec: Partial<ComponentView>;
constructor(
/**
* Component view component or spec
* @param componentOrSpec - user view component or partial component view. See {@link UserViewComponent} and {@link ComponentView}
*/
componentOrSpec?: UserViewComponent | Partial<ComponentView>);
/** Set view Component
* @param component - component view component. See {@link UserViewComponent}
* @returns component view builder based on component view provided. See {@link ComponentViewBuilder}
*/
component(component: UserViewComponent): ComponentViewBuilder;
/** Get view Component
* @returns Partial component view. See {@link ComponentView}
*/
getComponent(): Partial<ComponentView>['component'];
/** Set view Component options
* @param options - component view options
* @returns component view builder based on options provided. See {@link ComponentViewBuilder}
*/
options(options: {
[key: string]: any;
}): ComponentViewBuilder;
/** Get view Component options
* @returns component view options. See {@link ComponentView}
*/
getOptions(): ComponentView['options'];
/** Serialize view Component
* @param options - serialization options. See {@link SerializeOptions}
* @returns component view based on path provided in options. See {@link ComponentView}
*
*/
serialize(options?: SerializeOptions): ComponentView;
/** Clone Component view builder (allows for options overriding)
* @param withSpec - partial for component view option. See {@link ComponentView}
* @returns component view builder. See {@link ComponentViewBuilder}
*/
clone(withSpec?: Partial<ComponentView>): ComponentViewBuilder;
}
/**
* Interface for form views.
*
* @public */
interface FormView extends BaseView {
type: 'form';
}
/**
* Class for building a form view.
*
* @public */
declare class FormViewBuilder extends GenericViewBuilder<Partial<BaseView>, FormViewBuilder> {
/** Document list options. See {@link FormView} */
protected spec: Partial<FormView>;
constructor(spec?: Partial<FormView>);
/**
* Serialize Form view builder
* @param options - Serialize options. See {@link SerializeOptions}
* @returns form view builder based on path provided in options. See {@link FormView}
*/
serialize(options?: SerializeOptions): FormView;
/**
* Clone Form view builder (allows for options overriding)
* @param withSpec - Partial form view builder options. See {@link FormView}
* @returns form view builder. See {@link FormViewBuilder}
*/
clone(withSpec?: Partial<FormView>): FormViewBuilder;
}
/**
* Interface for base view
*
* @public */
interface BaseView {
/** View id */
id: string;
/** View Title */
title: string;
/** View Icon */
icon?: React.ComponentType | React.ReactNode;
}
/**
* Class for building generic views.
*
* @public
*/
declare abstract class GenericViewBuilder<TView extends Partial<BaseView>, ConcreteImpl> implements Serializable<BaseView> {
/** Generic view option object */
protected spec: TView;
/** Set generic view ID
* @param id - generic view ID
* @returns generic view builder based on ID provided.
*/
id(id: string): ConcreteImpl;
/** Get generic view ID
* @returns generic view ID
*/
getId(): TView['id'];
/** Set generic view title
* @param title - generic view title
* @returns generic view builder based on title provided and (if provided) its ID.
*/
title(title: string): ConcreteImpl;
/** Get generic view title
* @returns generic view title
*/
getTitle(): TView['title'];
/** Set generic view icon
* @param icon - generic view icon
* @returns generic view builder based on icon provided.
*/
icon(icon: React.ComponentType | React.ReactNode): ConcreteImpl;
/** Get generic view icon
* @returns generic view icon
*/
getIcon(): TView['icon'];
/** Serialize generic view
* @param options - serialization options. See {@link SerializeOptions}
* @returns generic view object based on path provided in options. See {@link BaseView}
*/
serialize(options?: SerializeOptions): BaseView;
/** Clone generic view builder (allows for options overriding)
* @param withSpec - Partial generic view builder options. See {@link BaseView}
* @returns Generic view builder.
*/
abstract clone(withSpec?: Partial<BaseView>): ConcreteImpl;
}
/** @internal */
declare function maybeSerializeView(item: View | Serializable<View>, index: number, path: SerializePath): View;
/**
* View builder. See {@link ComponentViewBuilder} and {@link FormViewBuilder}
*
* @public
*/
type ViewBuilder = ComponentViewBuilder | FormViewBuilder;
/**
* Interface for options of Partial Documents. See {@link PartialDocumentNode}
*
* @public */
interface DocumentOptions {
/** Document Id */
id: string;
/** Document Type */
type: string;
/** Document Template */
template?: string;
/** Template parameters */
templateParameters?: Record<string, unknown>;
}
/**
* Interface for partial document (focused on the document pane)
*
* @public */
interface PartialDocumentNode {
/** Document Id */
id?: string;
/** Document title */
title?: string;
/** I18n key and namespace used to populate the localized title */
i18n?: I18nTextRecord$1<'title'>;
/** Document children of type {@link Child} */
child?: Child;
/**
* Views for the document pane. See {@link ViewBuilder} and {@link View}
*/
views?: (View | ViewBuilder)[];
/**
* Document options. See {@link DocumentOptions}
*/
options?: Partial<DocumentOptions>;
/**
* View IDs to open as split panes by default when the document is opened.
* Pass an array of view IDs that match the IDs defined in `views`.
* If specified with 2+ valid view IDs, the document will open in split-pane mode.
*/
defaultPanes?: string[];
}
/**
* A `DocumentBuilder` is used to build a document node.
*
* @public */
declare class DocumentBuilder implements Serializable<DocumentNode> {
/** Component builder option object See {@link PartialDocumentNode} */
protected spec: PartialDocumentNode;
protected _context: StructureContext;
constructor(
/**
* Structure context. See {@link StructureContext}
*/
_context: StructureContext, spec?: PartialDocumentNode);
/** Set Document Builder ID
* @param id - document builder ID
* @returns document builder based on ID provided. See {@link DocumentBuilder}
*/
id(id: string): DocumentBuilder;
/** Get Document Builder ID
* @returns document ID. See {@link PartialDocumentNode}
*/
getId(): PartialDocumentNode['id'];
/** Set Document title
* @param title - document title
* @returns document builder based on title provided (and ID). See {@link DocumentBuilder}
*/
title(title: string): DocumentBuilder;
/** Get Document title
* @returns document title. See {@link PartialDocumentNode}
*/
getTitle(): PartialDocumentNode['title'];
/** Set the i18n key and namespace used to populate the localized title.
* @param i18n - the key and namespaced used to populate the localized title.
* @returns component builder based on i18n key and ns provided
*/
i18n(i18n: I18nTextRecord$1<'title'>): DocumentBuilder;
/** Get i18n key and namespace used to populate the localized title
* @returns the i18n key and namespace used to populate the localized title
*/
getI18n(): I18nTextRecord$1<'title'> | undefined;
/** Set Document child
* @param child - document child
* @returns document builder based on child provided. See {@link DocumentBuilder}
*/
child(child: Child): DocumentBuilder;
/** Get Document child
* @returns document child. See {@link PartialDocumentNode}
*/
getChild(): PartialDocumentNode['child'];
/** Set Document ID
* @param documentId - document ID
* @returns document builder with document based on ID provided. See {@link DocumentBuilder}
*/
documentId(documentId: string): DocumentBuilder;
/** Get Document ID
* @returns document ID. See {@link DocumentOptions}
*/
getDocumentId(): Partial<DocumentOptions>['id'];
/** Set Document Type
* @param documentType - document type
* @returns document builder with document based on type provided. See {@link DocumentBuilder}
*/
schemaType(documentType: SchemaType | string): DocumentBuilder;
/** Get Document Type
* @returns document type. See {@link DocumentOptions}
*/
getSchemaType(): Partial<DocumentOptions>['type'];
/** Set Document Template
* @param templateId - document template ID
* @param parameters - document template parameters
* @returns document builder with document based on template provided. See {@link DocumentBuilder}
*/
initialValueTemplate(templateId: string, parameters?: Record<string, unknown>): DocumentBuilder;
/** Get Document Template
* @returns document template. See {@link DocumentOptions}
*/
getInitialValueTemplate(): Partial<DocumentOptions>['template'];
/** Get Document's initial value Template parameters
* @returns document template parameters. See {@link DocumentOptions}
*/
getInitialValueTemplateParameters(): Partial<DocumentOptions>['templateParameters'];
/** Set Document views
* @param views - document views. See {@link ViewBuilder} and {@link View}
* @returns document builder with document based on views provided. See {@link DocumentBuilder}
*/
views(views: (View | ViewBuilder)[]): DocumentBuilder;
/** Get Document views
* @returns document views. See {@link ViewBuilder} and {@link View}
*/
getViews(): (View | ViewBuilder)[];
/**
* Set the view IDs to open as split panes by default when the document is opened.
* Pass an array of view IDs that match the IDs defined in `views()`.
* If specified with 2+ valid view IDs, the document will open in split-pane mode.
*
* @param viewIds - Array of view IDs to open as split panes
* @returns document builder with defaultPanes config. See {@link DocumentBuilder}
*
* @example
* ```ts
* S.document()
* .schemaType('article')
* .views([
* S.view.form().id('editor'),
* S.view.component(PreviewPane).id('preview').title('Preview')
* ])
* .defaultPanes(['editor', 'preview']) // Opens both as split panes
* ```
*/
defaultPanes(viewIds: string[]): DocumentBuilder;
/** Serialize Document builder
* @param options - serialization options. See {@link SerializeOptions}
* @returns document node based on path, index and hint provided in options. See {@link DocumentNode}
*/
serialize({
path,
index,
hint
}?: SerializeOptions): DocumentNode;
/** Clone Document builder
* @param withSpec - partial document node specification used to extend the cloned builder. See {@link PartialDocumentNode}
* @returns document builder based on context and spec provided. See {@link DocumentBuilder}
*/
clone(withSpec?: PartialDocumentNode): DocumentBuilder;
}
/** @internal */
declare function documentFromEditor(context: StructureContext, spec?: EditorNode): DocumentBuilder;
/** @internal */
declare function documentFromEditorWithInitialValue({
resolveDocumentNode,
templates
}: StructureContext, templateId: string, parameters?: Record<string, unknown>): DocumentBuilder;
/**
* A `InitialValueTemplateItemBuilder` is used to build a document node with an initial value set.
*
* @public
*/
declare class InitialValueTemplateItemBuilder implements Serializable<InitialValueTemplateItem> {
/** Initial Value template item option object. See {@link InitialValueTemplateItem} */
protected spec: Partial<InitialValueTemplateItem>;
protected _context: StructureContext;
constructor(
/**
* Structure context. See {@link StructureContext}
*/
_context: StructureContext, spec?: Partial<InitialValueTemplateItem>);
/** Set initial value template item builder ID
* @param id - initial value template item ID
* @returns initial value template item based on ID provided. See {@link InitialValueTemplateItemBuilder}
*/
id(id: string): InitialValueTemplateItemBuilder;
/** Get initial value template item builder ID
* @returns initial value template item ID. See {@link InitialValueTemplateItem}
*/
getId(): Partial<InitialValueTemplateItem>['id'];
/** Set initial value template item title
* @param title - initial value template item title
* @returns initial value template item based on title provided. See {@link InitialValueTemplateItemBuilder}
*/
title(title: string): InitialValueTemplateItemBuilder;
/** Get initial value template item title
* @returns initial value template item title. See {@link InitialValueTemplateItem}
*/
getTitle(): Partial<InitialValueTemplateItem>['title'];
/** Set initial value template item description
* @param description - initial value template item description
* @returns initial value template item builder based on description provided. See {@link InitialValueTemplateItemBuilder}
*/
description(description: string): InitialValueTemplateItemBuilder;
/** Get initial value template item description
* @returns initial value template item description. See {@link InitialValueTemplateItem}
*/
getDescription(): Partial<InitialValueTemplateItem>['description'];
/** Set initial value template ID
* @param templateId - initial value template item template ID
* @returns initial value template item based builder on template ID provided. See {@link InitialValueTemplateItemBuilder}
*/
templateId(templateId: string): InitialValueTemplateItemBuilder;
/** Get initial value template item template ID
* @returns initial value template item ID. See {@link InitialValueTemplateItem}
*/
getTemplateId(): Partial<InitialValueTemplateItem>['templateId'];
/** Get initial value template item template parameters
* @param parameters - initial value template item parameters
* @returns initial value template item builder based on parameters provided. See {@link InitialValueTemplateItemBuilder}
*/
parameters(parameters: {
[key: string]: any;
}): InitialValueTemplateItemBuilder;
/** Get initial value template item template parameters
* @returns initial value template item parameters. See {@link InitialValueTemplateItem}
*/
getParameters(): Partial<InitialValueTemplateItem>['parameters'];
/** Serialize initial value template item
* @param options - serialization options. See {@link SerializeOptions}
* @returns initial value template item object based on the path, index and hint provided in options. See {@link InitialValueTemplateItem}
*/
serialize({
path,
index,
hint
}?: SerializeOptions): InitialValueTemplateItem;
/** Clone generic view builder (allows for options overriding)
* @param withSpec - initial value template item builder options. See {@link InitialValueTemplateItemBuilder}
* @returns initial value template item builder based on the context and options provided. See {@link InitialValueTemplateItemBuilder}
*/
clone(withSpec?: Partial<InitialValueTemplateItem>): InitialValueTemplateItemBuilder;
}
/** @internal */
declare function defaultInitialValueTemplateItems(context: StructureContext): InitialValueTemplateItemBuilder[];
/** @internal */
declare function maybeSerializeInitialValueTemplateItem(item: InitialValueTemplateItem | InitialValueTemplateItemBuilder, index: number, path: SerializePath): InitialValueTemplateItem;
/** @internal */
declare function menuItemsFromInitialValueTemplateItems(context: StructureContext, templateItems: InitialValueTemplateItem[]): MenuItem[];
/** @internal */
declare function maybeSerializeMenuItemGroup(item: MenuItemGroup | MenuItemGroupBuilder, index: number, path: SerializePath): MenuItemGroup;
/**
* Interface for menu item groups
* @public
*/
interface MenuItemGroup {
/** Menu group Id */
id: string;
/** Menu group title */
title: string;
i18n?: I18nTextRecord$1<'title'>;
}
/**
* Class for building menu item groups.
*
* @public
*/
declare class MenuItemGroupBuilder implements Serializable<MenuItemGroup> {
/** Menu item group ID */
protected _id: string;
/** Menu item group title */
protected _title: string;
protected _i18n?: I18nTextRecord$1<'title'>;
protected _context: StructureContext;
constructor(
/**
* Structure context. See {@link StructureContext}
*/
_context: StructureContext, spec?: MenuItemGroup);
/**
* Set menu item group ID
* @param id - menu item group ID
* @returns menu item group builder based on ID provided. See {@link MenuItemGroupBuilder}
*/
id(id: string): MenuItemGroupBuilder;
/**
* Get menu item group ID
* @returns menu item group ID
*/
getId(): string;
/**
* Set menu item group title
* @param title - menu item group title
* @returns menu item group builder based on title provided. See {@link MenuItemGroupBuilder}
*/
title(title: string): MenuItemGroupBuilder;
/**
* Get menu item group title
* @returns menu item group title
*/
getTitle(): string;
/**
* Set the i18n key and namespace used to populate the localized title.
* @param i18n - object with i18n key and related namespace
* @returns menu item group builder based on i18n info provided. See {@link MenuItemGroupBuilder}
*/
i18n(i18n: I18nTextRecord$1<'title'>): MenuItemGroupBuilder;
/**
* Get the i18n key and namespace used to populate the localized title.
* @returns the i18n key and namespace used to populate the localized title.
*/
getI18n(): I18nTextRecord$1<'title'> | undefined;
/**
* Serialize menu item group builder
* @param options - serialization options (path). See {@link SerializeOptions}
* @returns menu item group based on path provided in options. See {@link MenuItemGroup}
*/
serialize(options?: SerializeOptions): MenuItemGroup;
}
/** @internal */
declare const shallowIntentChecker: IntentChecker;
/**
* Interface for list display options
*
* @public */
interface ListDisplayOptions {
/** Check if list display should show icons */
showIcons?: boolean;
}
/**
* Interface for base generic list
*
* @public
*/
interface BaseGenericList extends StructureNode {
/** List layout key. */
defaultLayout?: PreviewLayoutKey;
/** Can handle intent. See {@link IntentChecker} */
canHandleIntent?: IntentChecker;
/** List display options. See {@link ListDisplayOptions} */
displayOptions?: ListDisplayOptions;
/** List child. See {@link Child} */
child: Child;
/** List initial values array. See {@link InitialValueTemplateItem} and {@link InitialValueTemplateItemBuilder} */
initialValueTemplates?: (InitialValueTemplateItem | InitialValueTemplateItemBuilder)[];
}
/**
* Interface for generic list
*
* @public
*/
interface GenericList extends BaseGenericList {
/** List type */
type: string;
/** List menu items array. See {@link MenuItem} */
menuItems: MenuItem[];
/** List menu item groups array. See {@link MenuItemGroup} */
menuItemGroups: MenuItemGroup[];
}
/**
* Interface for buildable generic list
*
* @public
*/
interface BuildableGenericList extends Partial<BaseGenericList> {
/** List menu items array. See {@link MenuItem} and {@link MenuItemBuilder} */
menuItems?: (MenuItem | MenuItemBuilder)[];
/** List menu items groups array. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */
menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[];
}
/**
* Interface for generic list input
* Allows builders and only requires things not inferrable
*
* @public */
interface GenericListInput extends StructureNode {
/** Input id */
id: string;
/** Input title */
title: string;
/** Input menu items groups. See {@link MenuItem} and {@link MenuItemBuilder} */
menuItems?: (MenuItem | MenuItemBuilder)[];
/** Input menu items groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */
menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[];
/** Input initial value array. See {@link InitialValueTemplateItem} and {@link InitialValueTemplateItemBuilder} */
initialValueTemplates?: (InitialValueTemplateItem | InitialValueTemplateItemBuilder)[];
/** Input default layout. */
defaultLayout?: PreviewLayoutKey;
/** If input can handle intent. See {@link IntentChecker} */
canHandleIntent?: IntentChecker;
/** Input child of type {@link Child} */
child?: Child;
}
/**
* Class for building generic lists
*
* @public
*/
declare abstract class GenericListBuilder<TList extends BuildableGenericList, ConcreteImpl> implements Serializable<GenericList> {
/** Check if initial value templates are set */
protected initialValueTemplatesSpecified: boolean;
/** Generic list option object */
protected spec: TList;
/** Set generic list ID
* @param id - generic list ID
* @returns generic list builder based on ID provided.
*/
id(id: string): ConcreteImpl;
/** Get generic list ID
* @returns generic list ID
*/
getId(): TList['id'];
/** Set generic list title
* @param title - generic list title
* @returns generic list builder based on title and ID provided.
*/
title(title: string): ConcreteImpl;
/** Get generic list title
* @returns generic list title
*/
getTitle(): TList['title'];
/** Set the i18n key and namespace used to populate the localized title.
* @param i18n - the key and namespaced used to populate the localized title.
* @returns component builder based on i18n key and ns provided
*/
i18n(i18n: I18nTextRecord$1<'title'>): ConcreteImpl;
/** Get i18n key and namespace used to populate the localized title
* @returns the i18n key and namespace used to populate the localized title
*/
getI18n(): TList['i18n'];
/** Set generic list layout
* @param defaultLayout - generic list layout key.
* @returns generic list builder based on layout provided.
*/
defaultLayout(defaultLayout: PreviewLayoutKey): ConcreteImpl;
/** Get generic list layout
* @returns generic list layout
*/
getDefaultLayout(): TList['defaultLayout'];
/** Set generic list menu items
* @param menuItems - generic list menu items. See {@link MenuItem} and {@link MenuItemBuilder}
* @returns generic list builder based on menu items provided.
*/
menuItems(menuItems: (MenuItem | MenuItemBuilder)[] | undefined): ConcreteImpl;
/** Get generic list menu items
* @returns generic list menu items
*/
getMenuItems(): TList['menuItems'];
/** Set generic list menu item groups
* @param menuItemGroups - generic list menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder}
* @returns generic list builder based on menu item groups provided.
*/
menuItemGroups(menuItemGroups: (MenuItemGroup | MenuItemGroupBuilder)[]): ConcreteImpl;
/** Get generic list menu item groups
* @returns generic list menu item groups
*/
getMenuItemGroups(): TList['menuItemGroups'];
/** Set generic list child
* @param child - generic list child. See {@link Child}
* @returns generic list builder based on child provided (clone).
*/
child(child: Child): ConcreteImpl;
/** Get generic list child
* @returns generic list child
*/
getChild(): TList['child'];
/** Set generic list can handle intent
* @param canHandleIntent - generic list intent checker. See {@link IntentChecker}
* @returns generic list builder based on can handle intent provided.
*/
canHandleIntent(canHandleIntent?: IntentChecker): ConcreteImpl;
/** Get generic list can handle intent
* @returns generic list can handle intent
*/
getCanHandleIntent(): TList['canHandleIntent'];
/** Set generic list display options
* @param enabled - allow / disallow for showing icons
* @returns generic list builder based on display options (showIcons) provided.
*/
showIcons(enabled?: boolean): ConcreteImpl;
/** Get generic list display options
* @returns generic list display options (specifically showIcons)
*/
getShowIcons(): boolean | undefined;
/** Set generic list initial value templates
* @param templates - generic list initial value templates. See {@link InitialValueTemplateItemBuilder}
* @returns generic list builder based on templates provided.
*/
initialValueTemplates(templates: InitialValueTemplateItem | InitialValueTemplateItemBuilder | Array<InitialValueTemplateItem | InitialValueTemplateItemBuilder>): ConcreteImpl;
/** Get generic list initial value templates
* @returns generic list initial value templates
*/
getInitialValueTemplates(): TList['initialValueTemplates'];
/** Serialize generic list
* @param options - serialization options. See {@link SerializeOptions}
* @returns generic list object based on path provided in options. See {@link GenericList}
*/
serialize(options?: SerializeOptions): GenericList;
/** Clone generic list builder (allows for options overriding)
* @param _withSpec - generic list options.
* @returns generic list builder.
*/
abstract clone(_withSpec?: object): ConcreteImpl;
}
/**
* Partial document list
*
* @public
*/
interface PartialDocumentList extends BuildableGenericList {
/** Document list options. See {@link DocumentListOptions} */
options?: DocumentListOptions;
/** Schema type name */
schemaTypeName?: string;
}
/**
* Interface for document list input
*
* @public
*/
interface DocumentListInput extends GenericListInput {
/** Document list options. See {@link DocumentListOptions} */
options: DocumentListOptions;
}
/**
* Interface for document list
*
* @public
*/
interface DocumentList extends GenericList {
type: 'documentList';
/** Document list options. See {@link DocumentListOptions} */
options: DocumentListOptions;
/** Document list child. See {@link Child} */
child: Child;
/** Document schema type name */
schemaTypeName?: string;
}
/**
* Interface for document List options
*
* @public
*/
interface DocumentListOptions {
/** Document list filter */
filter: string;
/** Document list parameters */
params?: Record<string, unknown>;
/** Document list API version */
apiVersion?: string;
/** Document list API default ordering array. */
defaultOrdering?: SortOrderingItem[];
}
/**
* Class for building document list
*
* @public
*/
declare class DocumentListBuilder extends GenericListBuilder<PartialDocumentList, DocumentListBuilder> {
/** Document list options. See {@link PartialDocumentList} */
protected spec: PartialDocumentList;
protected _context: StructureContext;
constructor(
/**
* Structure context. See {@link StructureContext}
*/
_context: StructureContext, spec?: DocumentListInput);
/** Set API version
* @param apiVersion - API version
* @returns document list builder based on the options and API version provided. See {@link DocumentListBuilder}
*/
apiVersion(apiVersion: string): DocumentListBuilder;
/** Get API version
* @returns API version
*/
getApiVersion(): string | undefined;
/** Set Document list filter
* @param filter - GROQ-filter used to determine which documents to display. Do not support joins, since they operate on individual documents, and will ignore order-clauses and projections. See {@link https://www.sanity.io/docs/realtime-updates}
* @returns document list builder based on the options and filter provided. See {@link DocumentListBuilder}
*/
filter(filter: string): DocumentListBuilder;
/** Get Document list filter
* @returns filter
*/
getFilter(): string | undefined;
/** Set Document list schema type name
* @param type - schema type name.
* @returns document list builder based on the schema type name provided. See {@link DocumentListBuilder}
*/
schemaType(type: SchemaType | string): DocumentListBuilder;
/** Get Document list schema type name
* @returns schema type name
*/
getSchemaType(): string | undefined;
/** Set Document list options' parameters
* @param params - parameters
* @returns document list builder based on the options provided. See {@link DocumentListBuilder}
*/
params(params: Record<string, unknown>): DocumentListBuilder;
/** Get Document list options' parameters
* @returns options
*/
getParams(): Record<string, unknown> | undefined;
/** Set Document list default ordering
* @param ordering - default sort ordering array. See {@link SortOrderingItem}
* @returns document list builder based on ordering provided. See {@link DocumentListBuilder}
*/
defaultOrdering(ordering: SortOrderingItem[]): DocumentListBuilder;
/** Get Document list default ordering
* @returns default ordering. See {@link SortOrderingItem}
*/
getDefaultOrdering(): SortOrderingItem[] | undefined;
/** Serialize Document list
* @param options - serialization options. See {@link SerializeOptions}
* @returns document list object based on path provided in options. See {@link DocumentList}
*/
serialize(options?: SerializeOptions): DocumentList;
/** Clone Document list builder (allows for options overriding)
* @param withSpec - override document list spec. See {@link PartialDocumentList}
* @returns document list builder. See {@link DocumentListBuilder}
*/
clone(withSpec?: PartialDocumentList): DocumentListBuilder;
/** Get Document list spec
* @returns document list spec. See {@link PartialDocumentList}
*/
getSpec(): PartialDocumentList;
}
/** @internal */
declare function getTypeNamesFromFilter(filter: string, params?: Record<string, unknown>): string[];
/**
* Unserialized list item child.
* See {@link Collection}, {@link CollectionBuilder}, {@link ChildResolver} and {@link ItemChild}
*
* @public
*/
type UnserializedListItemChild = Collection | CollectionBuilder | ChildResolver | Observable<ItemChild>;
/**
* Child of List Item
* See {@link Collection}, {@link ChildResolver}, {@link ItemChild}
* @public
*/
type ListItemChild = Collection | ChildResolver | Observable<ItemChild> | undefined;
/**
* Interface for serialize list item options
*
* @public
*/
interface ListItemSerializeOptions extends SerializeOptions {
/** Check if list item title is optional */
titleIsOptional?: boolean;
}
/**
* Interface for ist item display options
*
* @public */
interface ListItemDisplayOptions {
/** Check if list item display should show icon */
showIcon?: boolean;
}
/**
* interface for list item input
*
* @public */
interface ListItemInput {
/** List item id */
id: string;
/** List item title */
title?: string;
/** List item icon */
icon?: React.ComponentType | React.ReactNode;
/** List item child. See {@link ListItemChild} */
child?: ListItemChild;
/** List item display options. See {@link ListItemDisplayOptions} */
displayOptions?: ListItemDisplayOptions;
/** List item schema type. See {@link SchemaType} */
schemaType?: SchemaType | string;
}
/**
* Interface for List Item
*
* @public */
interface ListItem {
/** List item id */
id: string;
/** List item type */
type: string;
/**
* The i18n key and namespace used to populate the localized title. This is
* the recommend way to set the title if you are localizing your studio.
*/
i18n?: I18nTextRecord$1<'title'>;
/** List item title. Note that the `i18n` key and namespace will take precedence. */
title?: string;
/** List item icon */
icon?: React.ComponentType | React.ReactNode;
/** List item child. See {@link ListItemChild} */
child?: ListItemChild;
/** List item display options. See {@link ListItemDisplayOptions} */
displayOptions?: ListItemDisplayOptions;
/** List item schema type. See {@link SchemaType} */
schemaType?: SchemaType;
}
/**
* Interface for unserialized list items.
*
* @public
*/
interface UnserializedListItem {
/** List item ID */
id: string;
/** List item title */
title: string;
/**
* The i18n key and namespace used to populate the localized title. This is
* the recommend way to set the title if you are localizing your studio.
*/
i18n?: I18nTextRecord$1<'title'>;
/** List item icon */
icon?: React.ComponentType | React.ReactNode;
/** List item child. See {@link UnserializedListItemChild} */
child?: UnserializedListItemChild;
/** List item display options. See {@link ListItemDisplayOptions} */
displayOptions?: ListItemDisplayOptions;
/** List item schema. See {@link SchemaType} */
schemaType?: SchemaType | string;
}
/**
* Partial list item. See {@link UnserializedListItem}
*
* @public */
type PartialListItem = Partial<UnserializedListItem>;
/**
* Class for building list items
*
* @public */
declare class ListItemBuilder implements Serializable<ListItem> {
/** List item option object. See {@link PartialListItem} */
protected spec: PartialListItem;
protected _context: StructureContext;
constructor(
/**
* Structure context. See {@link StructureContext}
*/
_context: StructureContext, spec?: ListItemInput);
/**
* Set list item ID
* @returns list item builder based on ID provided. See {@link ListItemBuilder}
*/
id(id: string): ListItemBuilder;
/**
* Get list item ID
* @returns list item ID. See {@link PartialListItem}
*/
getId(): PartialListItem['id'];
/**
* Set list item title
* @returns list item builder based on title provided. See {@link ListItemBuilder}
*/
title(title: string): ListItemBuilder;
/**
* Get list item title
* @returns list item title. See {@link PartialListItem}
*/
getTitle(): PartialListItem['title'];
/** Set the i18n key and namespace used to populate the localized title.
* @param i18n - the key and namespaced used to populate the localized title.
* @returns component builder based on i18n key and ns provided
*/
i18n(i18n: I18nTextRecord$1<'title'>): ListItemBuilder;
/** Get i18n key and namespace used to populate the localized title
* @returns the i18n key and namespace used to populate the localized title
*/
getI18n(): I18nTextRecord$1<'title'> | undefined;
/**
* Set list item icon
* @returns list item builder based on icon provided. See {@link ListItemBuilder}
*/
icon(icon: React.ComponentType | React.ReactNode): ListItemBuilder;
/**
* Set if list item should show icon
* @returns list item builder based on showIcon provided. See {@link ListItemBuilder}
*/
showIcon(enabled?: boolean): ListItemBuilder;
/**
* Check if list item should show icon
* @returns true if it should show the icon, false if not, undefined if not set
*/
getShowIcon(): boolean | undefined;
/**
*Get list item icon
* @returns list item icon. See {@link PartialListItem}
*/
getIcon(): PartialListItem['icon'];
/**
* Set list item child
* @param child - list item child. See {@link UnserializedListItemChild}
* @returns list item builder based on child provided. See {@link ListItemBuilder}
*/
child(child: UnserializedListItemChild): ListItemBuilder;
/**
* Get list item child
* @returns list item child. See {@link PartialListItem}
*/
getChild(): PartialListItem['child'];
/**
* Set list item schema type
* @param schemaType - list item schema type. See {@link SchemaType}
* @returns list item builder based on schema type provided. See {@link ListItemBuilder}
*/
schemaType(schemaType: SchemaType | string): ListItemBuilder;
/**
* Get list item schema type
* @returns list item schema type. See {@link PartialListItem}
*/
getSchemaType(): PartialListItem['schemaType'];
/** Serialize list item builder
* @param options - serialization options. See {@link ListItemSerializeOptions}
* @returns list item node based on path provided in options. See {@link ListItem}
*/
serialize(options?: ListItemSerializeOptions): ListItem;
/** Clone list item builder
* @param withSpec - partial list item options. See {@link PartialListItem}
* @returns list item builder based on context and spec provided. See {@link ListItemBuilder}
*/
clone(withSpec?: PartialListItem): ListItemBuilder;
}
/**
* Interface for document list item input
*
* @public
*/
interface DocumentListItemInput extends ListItemInput {
/** Document list item input schema type. See {@link SchemaType} */
schemaType: SchemaType | string;
}
/**
* Interface for document list item
*
* @public
*/
interface DocumentListItem extends ListItem {
/** Document schema type. See {@link SchemaType} */
schemaType: SchemaType;
/** Document ID */
_id: string;
}
/**
* Partial document list item
*
* @public
*/
type PartialDocumentListItem = Partial<UnserializedListItem>;
/**
* Class for building a document list item
*
* @public
*/
declare class DocumentListItemBuilder extends ListItemBuilder {
/** Document list options. See {@link PartialDocumentListItem} */
protected spec: PartialDocumentListItem;
protected _context: StructureContext;
constructor(
/**
* Structure context. See {@link StructureContext}
*/
_context: StructureContext, spec?: DocumentListItemInput);
/**
* Serialize document list item
* @param options - serialization options. See {@link SerializeOptions}
* @returns document list item object based on path provided in options. See {@link DocumentListItem}
*/
serialize(options?: SerializeOptions): DocumentListItem;
/** Clone Document list item builder (allows for options overriding)
* @param withSpec - Document list item builder options. See {@link PartialDocumentListItem}
* @returns document list item builder. See {@link DocumentListItemBuilder}
*/
clone(withSpec?: PartialDocumentListItem): DocumentListItemBuilder;
}
/** @internal */
declare function isDocumentListItem(item: unknown): item is DocumentListItem;
/**
* Interface for document type list input
*
* @public
*/
interface DocumentTypeListInput extends Partial<GenericListInput> {
/** Document type list input schema type. See {@link SchemaType} */
schemaType: SchemaType | string;
}
/**
* Class for building a document type list
*
* @public
*/
declare class DocumentTypeListBuilder extends DocumentListBuilder {
/** Document list options. See {@link PartialDocumentList} */
protected spec: PartialDocumentList;
protected _context: StructureContext;
constructor(
/**
* Structure context. See {@link StructureContext}
*/
_context: StructureContext, spec?: DocumentListInput);
/**
* Set Document type list child
* @param child - Child component. See {@link Child}
* @returns document type list builder based on child component provided without default intent handler. See {@link DocumentTypeListBuilder}
*/
child(child: Child): DocumentTypeListBuilder;
/** Clone Document type list builder (allows for options overriding)
* @param withSpec - Document type list builder options. See {@link PartialDocumentList}
* @returns document type list builder. See {@link DocumentTypeListBuilder}
*/
clone(withSpec?: PartialDocumentList): DocumentTypeListBuilder;
/** Clone Document type list builder (allows for options overriding) and remove default intent handler
* @param withSpec - Document type list builder options. See {@link PartialDocumentList}
* @returns document type list builder without default intent handler. See {@link DocumentTypeListBuilder}
*/
cloneWithoutDefaultIntentHandler(withSpec?: PartialDocumentList): DocumentTypeListBuilder;
}
/**
* Interface for List
*
* @public
*/
interface List extends GenericList {
type: 'list';
/** List items. See {@link ListItem} and {@link Divider} */
items: (ListItem | Divider)[];
}
/**
* Interface for list input
*
* @public
*/
interface ListInput extends GenericListInput {
/** List input items array. See {@link ListItem}, {@link ListItemBuilder} and {@link Divider} */
items?: (ListItem | ListItemBuilder | Divider | DividerBuilder)[];
}
/**
* Interface for buildable list
*
* @public
*/
interface BuildableList extends BuildableGenericList {
/** List items. See {@link ListItem}, {@link ListItemBuilder} and {@link Divider} */
items?: (ListItem | ListItemBuilder | Divider | DividerBuilder)[];
}
/**
* A `ListBuilder` is used to build a list of items in the structure tool.
*
* @public */
declare class ListBuilder extends GenericListBuilder<BuildableList, ListBuilder> {
/** buildable list option object. See {@link BuildableList} */
protected spec: BuildableList;
protected _context: StructureContext;
constructor(
/**
* Structure context. See {@link StructureContext}
*/
_context: StructureContext, spec?: ListInput);
/**
* Set list builder based on items provided
* @param items - list items. See {@link ListItemBuilder}, {@link ListItem} and {@link Divider}
* @returns list builder based on items provided. See {@link ListBuilder}
*/
items(items: (ListItemBuilder | ListItem | Divider | DividerBuilder)[]): ListBuilder;
/** Get list builder items
* @returns list items. See {@link BuildableList}
*/
getItems(): BuildableList['items'];
/** Serialize list builder
* @param options - serialization options. See {@link SerializeOptions}
* @returns list based on path in options. See {@link List}
*/
serialize(options?: SerializeOptions): List;
/**
* Clone list builder and return new list builder based on context and spec provided
* @param withSpec - list options. See {@link BuildableList}
* @returns new list builder based on context and spec provided. See {@link ListBuilder}
*/
clone(withSpec?: BuildableList): ListBuilder;
}
/**
* View. See {@link FormView} and {@link ComponentView}
*
* @public
*/
type View = FormView | ComponentView;
/**
* User view component
*
* @public */
type UserViewComponent<TOptions = Record<string, any>> = React.ComponentType<{
document: {
draft: SanityDocument | null;
displayed: Partial<SanityDocument>;
historical: Partial<SanityDocument> | null;
published: SanityDocument | null;
};
documentId: string;
options: TOptions;
schemaType: SchemaType;
}>;
/**
* User defined component
*
* @public
*/
type UserComponent = React.ComponentType<{
/** Component child. See {@link ComponentBuilder} */child?: ComponentBuilder; /** Component child item ID */
childItemId?: string; /** Component ID */
id: string; /** Is component active */
isActive?: boolean; /** Is component selected */
isSelected?: boolean; /** item ID */
itemId: string; /** Component options */
options?: Record<string, unknown>; /** Pane key */
paneKey: string; /** URL parameters */
urlParams: Record<string, string | undefined> | undefined;
}>;
/**
* Interface for the structure builder context.
*
* @public
*/
interface StructureContext extends Source {
/** Resolve document method
* @returns a document node builder, or null/undefined if no document node should be returned.
* See {@link DocumentBuilder}
*/
resolveDocumentNode: (/** an object holding the documentId and schemaType for the document node being resolved. */
options: {
documentId?: string;
schemaType: string;
}) => DocumentBuilder;
/** Get structure builder
* @returns a structure builder. See {@link StructureBuilder}
*/
getStructureBuilder: () => StructureBuilder;
/**
* The stacked array of perspective ids ordered chronologically to represent the state of documents at the given point in time.
* It can be used as the perspective param in the client to get the correct view of the documents.
* ["published"] | ["drafts"] | ["releaseId2", "releaseId1", "drafts"]
* See {@link PerspectiveStack}
*/
perspectiveStack: PerspectiveStack;
}
/**
* An object holding the documentId and schemaType for the document node being resolved.
*
* @public
*/
interface DefaultDocumentNodeContext extends ConfigContext {
/**
* The id of the sanity document
*/
documentId?: string;
/**
* the schema of the sanity document
*/
schemaType: string;
}
/**
* A resolver function used to return the default document node used when editing documents.
*
* @public
*
* @returns a document node builder, or null/undefined if no document node should be returned.
*
*/
type DefaultDocumentNodeResolver = (
/**
* S - an instance of the structure builder, that can be used to build the lists/items/panes for the structure tool
* context - an object holding various context that may be used to customize the structure, for instance the current user.
* Defaults to
* ```ts
* (S) => S.defaults()
* ```
* See {@link StructureBuilder}
*/
S: StructureBuilder,
/**
* An object holding the documentId and schemaType for the document node being resolved.
* See {@link DefaultDocumentNodeContext}
*/
options: DefaultDocumentNodeContext) => DocumentBuilder | null | undefined;
/**
* Interface for the structure builder.
*
* @public
*/
interface StructureBuilder {
/**
* @internal
*/
component: (spec?: ComponentInput | UserComponent) => ComponentBuilder;
/** By giving an object of options with documentID and its schema type receive the the respective Document builder
* @param options - an object holding the documentId and schemaType for the document node being resolved.
* @returns a Document builder. See {@link DocumentBuilder}
*/
defaultDocument: (options: {
documentId?: stri