UNPKG

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,562 lines (1,488 loc) • 133 kB
import {BoxOverflow} from '@sanity/ui' import {CardProps} from '@sanity/ui' import {ComponentProps} from 'react' import {ComponentType} from 'react' import {ConfigContext} from 'sanity' import {DocumentActionComponent} from 'sanity' import {DocumentBadgeComponent} from 'sanity' import {DocumentFieldAction} from 'sanity' import {DocumentFieldActionNode} from 'sanity' import {DocumentFormNode} from 'sanity' import {DocumentInspector} from 'sanity' import {DocumentLanguageFilterComponent} from 'sanity' import {DocumentStore} from 'sanity' import {EditStateFor} from 'sanity' import {ElementType} from 'react' import {ForwardRefExoticComponent} from 'react' import {GeneralPreviewLayoutKey} from 'sanity' import {HTMLProps} from 'react' import {I18nTextRecord} from 'sanity' import {InitialValueTemplateItem} from 'sanity' import {JSX} from 'react' import {LocaleSource} from 'sanity' import {MemoExoticComponent} from 'react' import {NamedExoticComponent} from 'react' import {ObjectSchemaType} from '@sanity/types' import {Observable} from 'rxjs' import {PaneRouterContext} from 'sanity/_singletons' import {PatchEvent} from 'sanity' import {Path} from '@sanity/types' import {PermissionCheckResult} from 'sanity' import {PerspectiveStack} from 'sanity' import {Plugin as Plugin_2} from 'sanity' import {PreviewLayoutKey} from 'sanity' import {ReactNode} from 'react' import {RefAttributes} from 'react' import {ReleaseId} from 'sanity' import {SanityDocument} from '@sanity/types' import {SanityDocumentLike} from '@sanity/types' import {SchemaType} from '@sanity/types' import {SearchParam} from 'sanity/router' import {SortOrdering} from '@sanity/types' import {SortOrderingItem} from '@sanity/types' import {Source} from 'sanity' import {StateTree} from 'sanity' import {TimelineStore} from 'sanity' import {ValidationMarker} from '@sanity/types' /** * @hidden * @beta */ export declare interface BackLinkProps { children?: ReactNode } /** * Interface for base generic list * * @public */ export declare 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)[] } /** * Base intent parameters * * @public * @todo dedupe with core */ export declare 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 */ export declare interface BaseResolvedPaneNode<T extends PaneNode['type']> { id: string type: T title: string i18n?: I18nTextRecord<'title'> menuItems?: PaneMenuItem[] menuItemGroups?: PaneMenuItemGroup[] canHandleIntent?: ( intentName: string, params: Record<string, string | undefined>, options: { pane: PaneNode index: number }, ) => boolean child?: UnresolvedPaneNode } declare interface BaseStructureToolPaneProps<T extends PaneNode['type']> { paneKey: string index: number itemId: string childItemId?: string isSelected?: boolean isActive?: boolean pane: Extract< PaneNode, { type: T } > /** * TODO: COREL - Remove this after updating sanity-assist to use <PerspectiveProvider> * * Allows to override the global version with a specific version or release. * @deprecated use <PerspectiveProvider> instead * @beta */ forcedVersion?: { selectedPerspectiveName: ReleaseId | 'published' | undefined isReleaseLocked: boolean selectedReleaseId: ReleaseId | undefined } /** * @deprecated Avoid specifying a key, instead use `paneKey` if need be */ key?: string } /** * Interface for base view * * @public */ export declare interface BaseView { /** View id */ id: string /** View Title */ title: string /** View Icon */ icon?: React.ComponentType | React.ReactNode } /** * Interface for buildable component * * @public */ export declare interface BuildableComponent extends Partial<StructureNode> { /** Component of type {@link UserComponent} */ component?: UserComponent /** Component child of type {@link Child} */ child?: Child /** Component options */ options?: { [key: string]: unknown } /** Component menu items. See {@link MenuItem} and {@link MenuItemBuilder} */ menuItems?: (MenuItem | MenuItemBuilder)[] /** Component menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */ menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[] canHandleIntent?: IntentChecker } /** * Interface for buildable generic list * * @public */ export declare 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 buildable list * * @public */ export declare interface BuildableList extends BuildableGenericList { /** List items. See {@link ListItem}, {@link ListItemBuilder} and {@link Divider} */ items?: (ListItem | ListItemBuilder | Divider | DividerBuilder)[] } /** @internal */ export declare type Builder = | CollectionBuilder | ComponentBuilder | DocumentBuilder | DocumentListBuilder | DocumentListItemBuilder | ListItemBuilder | MenuItemBuilder | MenuItemGroupBuilder | InitialValueTemplateItemBuilder /** * Child of a structure node * See {@link Collection}, {@link CollectionBuilder} and {@link ChildResolver} * * @public */ export declare type Child = Collection | CollectionBuilder | ChildResolver /** * @hidden * @beta */ export declare interface ChildLinkProps { childId: string childParameters?: Record<string, string> childPayload?: unknown children?: ReactNode } /** * Interface for child observable * * @public */ export declare interface ChildObservable { /** Subscribes to the child observable. See {@link ItemChild} */ subscribe: (child: ItemChild | Promise<ItemChild>) => Record<string, unknown> } /** * Interface for child resolver * * @public */ export declare interface ChildResolver { ( itemId: string, options: ChildResolverOptions, ): ItemChild | Promise<ItemChild> | ChildObservable | Observable<ItemChild> | undefined } /** * Interface for child resolver options * * @public */ export declare interface ChildResolverOptions { /** Child parent */ parent: unknown /** Child index */ index: number splitIndex: number /** Child path */ path: string[] /** Child parameters */ params: Record<string, string | undefined> /** Structure context. See {@link StructureContext} */ structureContext: StructureContext /** Serialize options. See {@link SerializeOptions} */ serializeOptions?: SerializeOptions } /** * Collection * See {@link List}, {@link DocumentList}, {@link EditorNode}, {@link DocumentNode} and {@link Component} * * @public */ export declare type Collection = List | DocumentList | EditorNode | DocumentNode | Component /** * Collection builder * See {@link ListBuilder}, {@link DocumentListBuilder}, {@link DocumentTypeListBuilder}, {@link DocumentBuilder} and {@link ComponentBuilder} * * @public */ export declare type CollectionBuilder = | ListBuilder | DocumentListBuilder | DocumentTypeListBuilder | DocumentBuilder | ComponentBuilder /** * Interface for component * * @public */ export declare interface Component extends StructureNode { /** Component of type {@link UserComponent} */ component: UserComponent /** Component child of type {@link Child} */ child?: Child /** Component menu items, array of type {@link MenuItem} */ menuItems: MenuItem[] /** Component menu item group, array of type {@link MenuItemGroup} */ menuItemGroups: MenuItemGroup[] /** Component options */ options: { [key: string]: unknown } canHandleIntent?: IntentChecker } /** @internal */ export declare const component: ( componentOrSpec?: UserViewComponent | Partial<ComponentView>, ) => ComponentViewBuilder /** * Class for building components * * @public */ export declare class ComponentBuilder implements Serializable<Component> { /** component builder option object */ protected spec: BuildableComponent constructor(spec?: ComponentInput) /** Set Component ID * @param id - component ID * @returns component builder based on ID provided */ id(id: string): ComponentBuilder /** Get ID * @returns ID */ getId(): BuildableComponent['id'] /** Set Component title * @param title - component title * @returns component builder based on title provided (and ID) */ title(title: string): ComponentBuilder /** Get Component title * @returns title */ getTitle(): BuildableComponent['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<'title'>): ComponentBuilder /** 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<'title'> | undefined /** Set Component child * @param child - child component * @returns component builder based on child component provided */ child(child: Child): ComponentBuilder /** Get Component child * @returns child component */ getChild(): BuildableComponent['child'] /** Set component * @param component - user built component * @returns component builder based on component provided */ component(component: UserComponent): ComponentBuilder /** Get Component * @returns component */ getComponent(): BuildableComponent['component'] /** Set Component options * @param options - component options * @returns component builder based on options provided */ options(options: {[key: string]: unknown}): ComponentBuilder /** Get Component options * @returns component options */ getOptions(): NonNullable<BuildableComponent['options']> /** Set Component menu items * @param menuItems - component menu items * @returns component builder based on menuItems provided */ menuItems(menuItems: (MenuItem | MenuItemBuilder)[]): ComponentBuilder /** Get Component menu items * @returns menu items */ getMenuItems(): BuildableComponent['menuItems'] /** Set Component menu item groups * @param menuItemGroups - component menu item groups * @returns component builder based on menuItemGroups provided */ menuItemGroups(menuItemGroups: (MenuItemGroup | MenuItemGroupBuilder)[]): ComponentBuilder /** Get Component menu item groups * @returns menu item groups */ getMenuItemGroups(): BuildableComponent['menuItemGroups'] canHandleIntent(canHandleIntent: IntentChecker): ComponentBuilder /** Serialize component * @param options - serialization options * @returns component object based on path provided in options * */ serialize(options?: SerializeOptions): Component /** Clone component builder (allows for options overriding) * @param withSpec - component builder options * @returns cloned builder */ clone(withSpec?: BuildableComponent): ComponentBuilder } /** * Interface for component input * * @public */ export declare interface ComponentInput extends StructureNode { /** Component of type {@link UserComponent} */ component: UserComponent /** Component child of type {@link Child} */ child?: Child /** Component options */ options?: { [key: string]: unknown } /** Component menu items. See {@link MenuItem} and {@link MenuItemBuilder} */ menuItems?: (MenuItem | MenuItemBuilder)[] /** Component menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */ menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[] } /** * Interface for component views. * * @public */ export declare 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 */ export 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 } /** @internal */ export declare function ConfirmDeleteDialog(props: ConfirmDeleteDialogProps): JSX.Element /** @internal */ export declare interface ConfirmDeleteDialogProps { /** * Incoming document ID used to find other referencing documents. This * field respects draft IDs (e.g. if you pass in a published ID when one * doesn't exist the document title may not show up). */ id: string /** * The schema typename of the incoming document */ type: string /** * The name of the action being done. (e.g. the `'unpublish'` action requires * the same document deletion confirmation). */ action?: 'delete' | 'unpublish' onCancel: () => void onConfirm: () => void } /** @internal */ export declare function createStructureBuilder({ defaultDocumentNode, source, perspectiveStack, }: StructureBuilderOptions): StructureBuilder /** @internal */ export declare interface CustomComponentPaneNode extends BaseResolvedPaneNode<'component'> { component: UserComponent options?: Record<string, unknown> } /** @internal */ export declare const DEFAULT_INTENT_HANDLER: unique symbol /** * An object holding the documentId and schemaType for the document node being resolved. * * @public */ export declare 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. * */ export declare 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 /** @internal */ export declare function defaultInitialValueTemplateItems( context: StructureContext, ): InitialValueTemplateItemBuilder[] /** @internal */ export declare const defaultIntentChecker: IntentChecker /** * A `Divider` is a visual separator in the structure tree. * * @public */ export declare interface Divider { /** * The divider's ID */ id: string type: 'divider' /** * The divider's title */ title?: string /** * The i18n key and namespace used to populate the localized title */ i18n?: I18nTextRecord<'title'> } 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<'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<'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 } /** * A `DocumentBuilder` is used to build a document node. * * @public */ export 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<'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<'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)[] /** 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 } /** * @hidden * @beta */ export declare type DocumentFieldMenuActionNode = DocumentFieldActionNode & { intent?: Intent } /** @internal */ export declare function documentFromEditor( context: StructureContext, spec?: EditorNode, ): DocumentBuilder /** @internal */ export declare function documentFromEditorWithInitialValue( {resolveDocumentNode, templates}: StructureContext, templateId: string, parameters?: Record<string, unknown>, ): DocumentBuilder /** @internal */ export declare function DocumentInspectorHeader( props: DocumentInspectorHeaderProps & Omit<HTMLProps<HTMLDivElement>, 'as' | 'height' | 'ref'>, ): JSX.Element declare interface DocumentInspectorHeaderProps { as?: CardProps['as'] closeButtonLabel: string flex?: CardProps['flex'] onClose: () => void title: ReactNode } /** * Interface for document list * * @public */ export declare 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 } /** * Class for building document list * * @public */ export 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 } /** * Interface for document list input * * @public */ export declare interface DocumentListInput extends GenericListInput { /** Document list options. See {@link DocumentListOptions} */ options: DocumentListOptions } /** * Interface for document list item * * @public */ export declare interface DocumentListItem extends ListItem { /** Document schema type. See {@link SchemaType} */ schemaType: SchemaType /** Document ID */ _id: string } /** * Class for building a document list item * * @public */ export 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 } /** * Interface for document list item input * * @public */ export declare interface DocumentListItemInput extends ListItemInput { /** Document list item input schema type. See {@link SchemaType} */ schemaType: SchemaType | string } /** * Interface for document List options * * @public */ export declare 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[] } /** * @internal */ export declare const DocumentListPane: NamedExoticComponent< BaseStructureToolPaneProps<'documentList'> > /** @internal */ export declare interface DocumentListPaneNode extends BaseResolvedPaneNode<'documentList'> { defaultLayout?: GeneralPreviewLayoutKey displayOptions?: { showIcons?: boolean } initialValueTemplates?: InitialValueTemplateItem[] options: { filter: string defaultOrdering?: Array<{ field: string direction: 'asc' | 'desc' }> params?: Record<string, unknown> apiVersion?: string } schemaTypeName: string source?: string } /** * @internal */ export declare type DocumentListPaneProps = ComponentProps<typeof DocumentListPane> /** * Interface for the document list builder (focused on the document pane) * * @public */ export declare interface DocumentNode extends StructureNode { /** * Document children. See {@link Child} */ child?: Child /** * Options for the document pane */ options: { /** Document Id */ id: string /** Document Type */ type?: string /** Document Template */ template?: string /** Template parameters */ templateParameters?: { [key: string]: any } } /** * View array for the document pane. See {@link View} */ views: View[] } /** * Interface for options of Partial Documents. See {@link PartialDocumentNode} * * @public */ export declare interface DocumentOptions { /** Document Id */ id: string /** Document Type */ type: string /** Document Template */ template?: string /** Template parameters */ templateParameters?: Record<string, unknown> } /** * @internal */ export declare const DocumentPane: NamedExoticComponent<DocumentPaneProviderProps> /** @internal */ declare interface DocumentPaneContextValue { actions: DocumentActionComponent[] | null activeViewId: string | null badges: DocumentBadgeComponent[] | null changesOpen: boolean closeInspector: (inspectorName?: string) => void collapsedFieldSets: StateTree<boolean> | undefined collapsedPaths: StateTree<boolean> | undefined compareValue: Partial<SanityDocument> | null connectionState: 'connecting' | 'reconnecting' | 'connected' displayed: Partial<SanityDocument> | null documentId: string documentIdRaw: string documentType: string editState: EditStateFor | null fieldActions: DocumentFieldAction[] focusPath: Path index: number inspectOpen: boolean inspector: DocumentInspector | null inspectors: DocumentInspector[] menuItemGroups: PaneMenuItemGroup[] onBlur: (blurredPath: Path) => void onChange: (event: PatchEvent) => void onFocus: (pathOrEvent: Path) => void onHistoryClose: () => void onHistoryOpen: () => void onInspectClose: () => void onMenuAction: (item: PaneMenuItem) => void onPaneClose: () => void onPaneSplit?: () => void onPathOpen: (path: Path) => void onSetActiveFieldGroup: (path: Path, groupName: string) => void onSetCollapsedPath: (path: Path, expanded: boolean) => void onSetCollapsedFieldSet: (path: Path, expanded: boolean) => void openInspector: (inspectorName: string, paneParams?: Record<string, string>) => void openPath: Path paneKey: string previewUrl?: string | null ready: boolean schemaType: ObjectSchemaType /** * @deprecated not used anymore * */ setTimelineMode?: undefined /** * @deprecated not used anymore * */ timelineMode?: undefined setTimelineRange(since: string | null, rev: string | null): void setIsDeleting: (state: boolean) => void timelineError: Error | null /** * Soon to be deprecated with the upcoming `releases` changes. */ timelineStore?: TimelineStore title: string | null validation: ValidationMarker[] value: SanityDocumentLike views: View[] formState: DocumentFormNode | null /** * TODO: COREL - Remove this after updating sanity-assist to use <PerspectiveProvider> * * @deprecated use `usePerspective()` instead */ selectedReleaseId: ReleaseId | undefined permissions?: PermissionCheckResult | null isDeleting: boolean isDeleted: boolean isPermissionsLoading: boolean isInitialValueLoading?: boolean unstable_languageFilter: DocumentLanguageFilterComponent[] revisionId: string | null revisionNotFound: boolean lastNonDeletedRevId: string | null lastRevisionDocument: SanityDocument | null } /** @internal */ export declare interface DocumentPaneNode extends BaseResolvedPaneNode<'document'> { options: { id: string type: string template?: string templateParameters?: Record<string, unknown> } source?: string views?: View[] } declare type DocumentPaneOptions = DocumentPaneNode['options'] /** * @internal */ export declare const DocumentPaneProvider: MemoExoticComponent< (props: DocumentPaneProviderProps) => JSX.Element > /** @internal */ export declare type DocumentPaneProviderProps = { children?: React.ReactNode onFocusPath?: (path: Path) => void } & BaseStructureToolPaneProps<'document'> /** * Class for building a document type list * * @public */ export 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 document type list input * * @public */ export declare interface DocumentTypeListInput extends Partial<GenericListInput> { /** Document type list input schema type. See {@link SchemaType} */ schemaType: SchemaType | string } /** * Interface for Editor node * * @public */ export declare interface EditorNode extends StructureNode { /** Editor child. See {@link Child} */ child?: Child /** Editor options */ options: { /** Editor ID */ id: string /** Editor type */ type?: string /** Editor template */ template?: string /** Template parameters */ templateParameters?: { [key: string]: any } } } /** * @hidden * @beta */ export declare interface EditReferenceOptions { parentRefPath: Path id: string type: string version?: ReleaseId template: { id: string params?: Record<string, string | number | boolean> } } /** @internal */ export declare const form: (spec?: Partial<FormView>) => FormViewBuilder /** * Interface for form views. * * @public */ export declare interface FormView extends BaseView { type: 'form' } /** * Class for building a form view. * * @public */ export 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 generic list * * @public */ export declare 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[] } /** * Class for building generic lists * * @public */ export 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<'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 } /** * Interface for generic list input * Allows builders and only requires things not inferrable * * @public */ export declare 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 views. * * @public */ export 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 */ export declare function getOrderingMenuItem( context: StructureContext, {by, title, i18n}: SortOrdering, extendedProjection?: string, ): MenuItemBuilder /** @internal */ export declare function getOrderingMenuItemsForSchemaType( context: StructureContext, typeName: SchemaType | string, ): MenuItemBuilder[] /** @internal */ export declare function getTypeNamesFromFilter( filter: string, params?: Record<string, unknown>, ): string[] /** @internal */ export declare const HELP_URL: { ID_REQUIRED: 'structure-node-id-required' TITLE_REQUIRED: 'structure-title-required' FILTER_REQUIRED: 'structure-filter-required' INVALID_LIST_ITEM: 'structure-invalid-list-item' COMPONENT_REQUIRED: 'structure-view-component-required' DOCUMENT_ID_REQUIRED: 'structure-document-id-required' DOCUMENT_TYPE_REQUIRED: 'structure-document-type-required' SCHEMA_TYPE_REQUIRED: 'structure-schema-type-required' SCHEMA_TYPE_NOT_FOUND: 'structure-schema-type-not-found' LIST_ITEMS_MUST_BE_ARRAY: 'structure-list-items-must-be-array' QUERY_PROVIDED_FOR_FILTER: 'structure-query-provided-for-filter' ACTION_OR_INTENT_REQUIRED: 'structure-action-or-intent-required' LIST_ITEM_IDS_MUST_BE_UNIQUE: 'structure-list-item-ids-must-be-unique' ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE: 'structure-action-and-intent-mutually-exclusive' API_VERSION_REQUIRED_FOR_CUSTOM_FILTER: 'structure-api-version-required-for-custom-filter' } /** * A `InitialValueTemplateItemBuilder` is used to build a document node with an initial value set. * * @public */ export 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 Initi