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,864 lines (1,754 loc) • 460 kB
TypeScript
/// <reference types="react" />
import {$Tuple} from 'react-i18next/helpers'
import {ArrayDiff as ArrayDiff_2} from '@sanity/diff'
import {ArraySchemaType} from '@sanity/types'
import {AssetMetadataType} from '@sanity/types'
import {AssetSource} from '@sanity/types'
import {AssetSourceSpec} from '@sanity/types'
import {AvatarPosition} from '@sanity/ui'
import {AvatarProps} from '@sanity/ui'
import {AvatarSize} from '@sanity/ui'
import {AvatarStatus} from '@sanity/ui'
import {BadgeProps} from '@sanity/ui'
import {BifurClient} from '@sanity/bifur-client'
import {BlockDecoratorDefinition} from '@sanity/types'
import {BlockListDefinition} from '@sanity/types'
import {BlockStyleDefinition} from '@sanity/types'
import {BooleanDiff as BooleanDiff_2} from '@sanity/diff'
import {BooleanSchemaType} from '@sanity/types'
import {BoxProps} from '@sanity/ui'
import {BrowserHistory} from 'history'
import {ButtonProps as ButtonProps_2} from '@sanity/ui'
import {ButtonTone} from '@sanity/ui'
import {CardProps} from '@sanity/ui'
import {ClientConfig} from '@sanity/client'
import {ClientPerspective} from '@sanity/client'
import {ColorHueKey} from '@sanity/color'
import {ColorTintKey} from '@sanity/color'
import {ColorTints} from '@sanity/color'
import {Component} from 'react'
import {ComponentProps} from 'react'
import {ComponentType} from 'react'
import {ConditionalProperty} from '@sanity/types'
import {Context} from 'react'
import {CrossDatasetReferenceSchemaType} from '@sanity/types'
import {CrossDatasetReferenceValue} from '@sanity/types'
import {CrossDatasetType} from '@sanity/types'
import {CSSProperties} from 'react'
import {CurrentUser} from '@sanity/types'
import {DefinedTelemetryLog} from '@sanity/telemetry'
import {DeprecatedProperty} from '@sanity/types'
import {DialogProps} from '@sanity/ui'
import {Diff as Diff_2} from '@sanity/diff'
import {Dispatch} from 'react'
import {EditorChange} from '@sanity/portable-text-editor'
import {ElementType} from 'react'
import {ExecutionProps} from 'styled-components'
import {FallbackNs} from 'react-i18next'
import {File as File_2} from '@sanity/types'
import {FileAsset} from '@sanity/types'
import {FileSchemaType} from '@sanity/types'
import {FileValue} from '@sanity/types'
import {FlatNamespace} from 'i18next'
import {FocusEvent as FocusEvent_2} from 'react'
import {FocusEventHandler} from 'react'
import {FormEventHandler} from 'react'
import {FormNodeValidation} from '@sanity/types'
import {ForwardRefExoticComponent} from 'react'
import {GeopointValue} from '@sanity/types'
import {HashHistory} from 'history'
import {History as History_2} from 'history'
import {HotkeyOptions} from '@sanity/portable-text-editor'
import {HotkeysProps as HotkeysProps_2} from '@sanity/ui'
import {HTMLAttributes} from 'react'
import {HTMLProps} from 'react'
import {i18n} from 'i18next'
import {I18nTextRecord} from '@sanity/types'
import {Image as Image_2} from '@sanity/types'
import {ImageAsset} from '@sanity/types'
import {ImageSchemaType} from '@sanity/types'
import type imageUrlBuilder from '@sanity/image-url'
import {ImageUrlFitMode} from '@sanity/types'
import {ImageValue} from '@sanity/types'
import {IndexTuple} from '@sanity/types'
import {InitialValueProperty} from '@sanity/types'
import {InitialValueResolverContext} from '@sanity/types'
import {IntrinsicTypeName} from '@sanity/types'
import {ItemDiff as ItemDiff_2} from '@sanity/diff'
import {JSX as JSX_2} from 'react/jsx-runtime'
import {JSXElementConstructor} from 'react'
import {KeyedSegment} from '@sanity/types'
import {KeyPrefix} from 'i18next'
import {MemoizedFunction} from 'lodash'
import {MemoryHistory} from 'history'
import {MendozaEffectPair} from '@sanity/types'
import {MenuButtonProps as MenuButtonProps_2} from '@sanity/ui'
import {MutableRefObject} from 'react'
import {Mutation} from '@sanity/mutator'
import {NamedExoticComponent} from 'react'
import {Namespace} from 'i18next'
import {NullDiff as NullDiff_2} from '@sanity/diff'
import {NumberDiff as NumberDiff_2} from '@sanity/diff'
import {NumberSchemaType} from '@sanity/types'
import {ObjectDiff as ObjectDiff_2} from '@sanity/diff'
import {ObjectField} from '@sanity/types'
import {ObjectFieldType} from '@sanity/types'
import {ObjectSchemaType} from '@sanity/types'
import {Observable} from 'rxjs'
import {OnCopyFn} from '@sanity/portable-text-editor'
import {OnPasteFn} from '@sanity/portable-text-editor'
import {OperatorFunction} from 'rxjs'
import {PatchOperations} from '@sanity/types'
import {Path} from '@sanity/types'
import {PathSegment} from '@sanity/types'
import {Placement} from '@sanity/ui'
import {PopoverProps as PopoverProps_2} from '@sanity/ui'
import {PortableTextBlock} from '@sanity/types'
import {PortableTextEditor} from '@sanity/portable-text-editor'
import {PortableTextObject} from '@sanity/types'
import {PortableTextTextBlock} from '@sanity/types'
import {PrepareViewOptions} from '@sanity/types'
import {PreviewConfig} from '@sanity/types'
import {PreviewValue} from '@sanity/types'
import {PropsWithChildren} from 'react'
import {PureComponent} from 'react'
import {RangeDecoration} from '@sanity/portable-text-editor'
import {ReactChild} from 'react'
import {ReactElement} from 'react'
import {ReactNode} from 'react'
import {RefAttributes} from 'react'
import {Reference} from '@sanity/types'
import {ReferenceSchemaType} from '@sanity/types'
import {ReferenceValue} from '@sanity/types'
import {ResizeObserverEntry as ResizeObserverEntry_2} from '@juggle/resize-observer'
import {ResponsivePaddingProps} from '@sanity/ui'
import {ResponsiveWidthProps} from '@sanity/ui'
import {Role} from '@sanity/types'
import {RootTheme} from '@sanity/ui/theme'
import {SanityClient} from '@sanity/client'
import {SanityDocument} from '@sanity/types'
import {SanityDocument as SanityDocument_2} from '@sanity/client'
import {SanityDocumentLike} from '@sanity/types'
import {Schema} from '@sanity/types'
import {SchemaType} from '@sanity/types'
import {SchemaTypeDefinition} from '@sanity/types'
import {ScrollToOptions as ScrollToOptions_2} from '@tanstack/react-virtual'
import {SetStateAction} from 'react'
import {SlugSchemaType} from '@sanity/types'
import {SlugValue} from '@sanity/types'
import {SortOrdering} from '@sanity/types'
import {StringDiff as StringDiff_2} from '@sanity/diff'
import {StringSchemaType} from '@sanity/types'
import {StringSegmentChanged as StringSegmentChanged_2} from '@sanity/diff'
import {StringSegmentUnchanged as StringSegmentUnchanged_2} from '@sanity/diff'
import {Subject} from 'rxjs'
import {Subscriber} from 'nano-pubsub'
import {SVGProps} from 'react'
import {Text as Text_2} from '@sanity/ui'
import {TextProps} from '@sanity/ui'
import {TextSchemaType} from '@sanity/types'
import {TFunction} from 'i18next'
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
import {ThemeColorSchemeKey as ThemeColorSchemeKey_2} from '@sanity/ui'
import {ThrottleSettings} from 'lodash'
import {TooltipProps as TooltipProps_2} from '@sanity/ui'
import {TransactionLogEventWithEffects} from '@sanity/types'
import {TransactionLogEventWithMutations} from '@sanity/types'
import {TypeChangeDiff as TypeChangeDiff_2} from '@sanity/diff'
import {UploadState} from '@sanity/types'
import {User} from '@sanity/types'
import {ValidationMarker} from '@sanity/types'
/** @internal */
export declare function __tmp_wrap_presenceStore(context: {
bifur: BifurClient
connectionStatusStore: ConnectionStatusStore
userStore: UserStore
}): PresenceStore
/**
* @hidden
* @beta */
export declare interface ActionComponent<ActionProps> {
(props: ActionProps): DocumentActionDescription | null
}
/** @internal */
export declare type ActionHook<T, K> = (args: T) => K | null
/**
* @hidden
* @beta */
export declare interface ActiveToolLayoutProps {
renderDefault: (props: ActiveToolLayoutProps) => React.ReactElement
activeTool: Tool
}
/** @internal */
export declare function ActiveWorkspaceMatcher({
children,
LoadingComponent,
NotFoundComponent,
unstable_history: historyProp,
}: ActiveWorkspaceMatcherProps): JSX_2.Element
/** @internal */
export declare const ActiveWorkspaceMatcherContext: Context<ActiveWorkspaceMatcherContextValue | null>
/** @internal */
export declare interface ActiveWorkspaceMatcherContextValue {
activeWorkspace: WorkspaceSummary
setActiveWorkspace: (workspaceName: string) => void
}
/** @internal */
export declare interface ActiveWorkspaceMatcherProps {
children: ReactNode
unstable_history?: RouterHistory
NotFoundComponent: ComponentType<{
onNavigateToDefaultWorkspace: () => void
}>
LoadingComponent: ComponentType
}
/**
* @beta
* @hidden
*/
export declare const AddonDatasetContext: Context<AddonDatasetContextValue | null>
/**
* @beta
* @hidden
*/
export declare interface AddonDatasetContextValue {
/**
* Addon dataset client, currently called `comments` dataset.
*/
client: SanityClient | null
isCreatingDataset: boolean
/**
* Function to create the addon dataset if it does not exist.
*/
createAddonDataset: () => Promise<SanityClient | null>
ready: boolean
}
/**
* This provider sets the addon dataset client, currently called `comments` dataset.
* It also exposes a `createAddonDataset` function that can be used to create the addon dataset if it does not exist.
* @beta
* @hidden
*/
export declare function AddonDatasetProvider(props: AddonDatasetSetupProviderProps): JSX_2.Element
declare interface AddonDatasetSetupProviderProps {
children: React.ReactNode
}
/**
* @hidden
* @beta */
export declare type Annotation = AnnotationDetails | null
/**
* Annotation connected to a change
*
*
* @hidden
* @beta
*/
export declare type AnnotationDetails = {
chunk: Chunk
timestamp: string
author: string
}
/**
* @hidden
* @beta */
export declare interface ApiConfig {
projectId: string
dataset: string
}
/** @internal */
export declare type ArrayDiff<V = unknown> = ArrayDiff_2<Annotation, V>
/**
* @hidden
* @public */
export declare interface ArrayFieldProps extends BaseFieldProps {
schemaType: ArraySchemaType
value: unknown[] | undefined
collapsed?: boolean
collapsible?: boolean
onCollapse: () => void
onExpand: () => void
inputProps: ArrayOfObjectsInputProps
}
/**
* These are the props an implementation of the ArrayFunctions component will receive
*
*
* @hidden
* @beta
*/
export declare interface ArrayInputFunctionsProps<Item, SchemaType extends ArraySchemaType> {
children?: ReactNode
onItemAppend: (itemValue: Item) => void
onChange: (event: PatchEvent) => void
onValueCreate: (type: SchemaType) => Item
onItemPrepend: (itemValue: Item) => void
readOnly?: boolean
schemaType: SchemaType
value?: Item[]
}
/**
* @hidden
* @beta */
export declare interface ArrayInputInsertEvent<Item> {
items: Item[]
position: 'before' | 'after'
referenceItem: KeyedSegment | number
skipInitialValue?: boolean
open?: boolean
}
/**
* @hidden
* @beta */
export declare interface ArrayInputMoveItemEvent {
fromIndex: number
toIndex: number
}
/**
* @hidden
* @beta */
export declare interface ArrayItemError {
kind: 'error'
key: string
index: number
error: InvalidItemTypeError
}
/**
* Diff extensions for presentational concerns
*
* @internal
*/
export declare interface ArrayItemMetadata {
fromType?: SchemaType
toType?: SchemaType
}
/**
* @hidden
* Array of predefined object options input
* Note: this input can handle only object values
*
*
* @hidden
* @beta
*/
export declare function ArrayOfObjectOptionsInput(props: ArrayOfObjectsInputProps): JSX_2.Element
/**
*
* @hidden
* @beta
*/
export declare interface ArrayOfObjectsComponents {
annotation?: ComponentType<BlockAnnotationProps>
block?: ComponentType<BlockProps>
diff?: ComponentType<any>
field?: ComponentType<ArrayFieldProps>
inlineBlock?: ComponentType<BlockProps>
input?: ComponentType<ArrayOfObjectsInputProps>
item?: ComponentType<ObjectItemProps>
preview?: ComponentType<PreviewProps>
}
/** @public */
export declare interface ArrayOfObjectsFormNode<
T extends any[] = unknown[],
S extends ArraySchemaType = ArraySchemaType,
> extends BaseFormNode<T, S> {
/** The focus path of the form node. */
focusPath: Path
/**
* @hidden
* @beta */
members: ArrayOfObjectsMember[]
}
/**
* @hidden
* @beta */
export declare function ArrayOfObjectsFunctions<
Item extends ObjectItem,
SchemaType extends ArraySchemaType,
>(props: ArrayInputFunctionsProps<Item, SchemaType>): JSX_2.Element
/**
*
* @hidden
* @beta
*/
export declare function ArrayOfObjectsInput(props: ArrayOfObjectsInputProps): JSX_2.Element
/**
* Convenience component for rendering an "array of objects"-item
* @internal
*/
export declare function ArrayOfObjectsInputMember(
props: ArrayOfObjectsMemberProps,
): JSX_2.Element | null
/**
* Convenience component for wrapping an array of objects
* @internal
*/
export declare function ArrayOfObjectsInputMembers(
props: ArrayOfObjectsInputMembersProps,
): JSX_2.Element
/** @internal */
export declare interface ArrayOfObjectsInputMembersProps {
members: ArrayOfObjectsMember[]
renderAnnotation?: RenderAnnotationCallback
renderBlock?: RenderBlockCallback
renderInlineBlock?: RenderBlockCallback
renderInput: RenderInputCallback
renderField: RenderFieldCallback
renderItem: RenderArrayOfObjectsItemCallback
renderPreview: RenderPreviewCallback
}
/**
* @hidden
* @public */
export declare interface ArrayOfObjectsInputProps<
T extends {
_key: string
} = {
_key: string
},
S extends ArraySchemaType = ArraySchemaType,
> extends BaseInputProps,
ArrayOfObjectsFormNode<T[], S> {
/**
* @hidden
* @beta */
arrayFunctions?: ComponentType<ArrayInputFunctionsProps<T, S>>
/**
* @hidden
* @beta */
onChange: (patch: FormPatch | FormPatch[] | PatchEvent) => void
/**
* @hidden
* @beta */
onItemAppend: (item: T) => void
/**
* @hidden
* @beta */
onItemPrepend: (item: T) => void
/**
* @hidden
* @beta */
onItemRemove: (itemKey: string) => void
/**
* @hidden
* @beta */
onItemMove: (event: ArrayInputMoveItemEvent) => void
/**
* @hidden
* @beta */
onInsert: (event: ArrayInputInsertEvent<T>) => void
/**
* @hidden
* @beta */
resolveInitialValue: (type: SchemaType, params: Record<string, unknown>) => Promise<T>
/**
* @hidden
* @beta */
resolveUploader: UploaderResolver<ObjectSchemaType>
/**
* @hidden
* @beta */
onUpload: (event: UploadEvent) => void
/**
* @hidden
* @beta */
onPathFocus: (path: Path) => void
/**
* for array inputs using expand/collapse semantics for items
*
* @hidden
* @beta
*/
onItemCollapse: (itemKey: string) => void
/**
* @hidden
* @beta */
onItemExpand: (itemKey: string) => void
/**
* for array inputs using modal open/close semantics for items
*
* @hidden
* @beta
*/
onItemOpen: (path: Path) => void
/**
* @hidden
* @beta */
onItemClose: () => void
/**
* @hidden
* @beta */
renderAnnotation?: RenderAnnotationCallback
/**
* @hidden
* @beta */
renderBlock?: RenderBlockCallback
/**
* @hidden
* @beta */
renderInlineBlock?: RenderBlockCallback
/**
* @hidden
* @beta */
renderField: RenderFieldCallback
/**
* @hidden
* @beta */
renderInput: RenderInputCallback
/**
* @hidden
* @beta */
renderItem: RenderArrayOfObjectsItemCallback
/**
* @hidden
* @beta */
renderPreview: RenderPreviewCallback
/**
* @hidden
* @beta */
elementProps: ComplexElementProps
}
/**
*
* @hidden
* @beta
*/
export declare function ArrayOfObjectsItem(props: MemberItemProps): JSX_2.Element
/**
* @hidden
* @beta */
export declare interface ArrayOfObjectsItemMember<
Node extends ObjectArrayFormNode = ObjectArrayFormNode,
> {
kind: 'item'
key: string
index: number
collapsed: boolean | undefined
collapsible: boolean | undefined
open: boolean
parentSchemaType: ArraySchemaType
/**
* @hidden
* @beta */
item: Node
}
/**
* @hidden
* @beta */
export declare type ArrayOfObjectsMember = ArrayOfObjectsItemMember | ArrayItemError
/** @internal */
export declare interface ArrayOfObjectsMemberProps {
member: ArrayOfObjectsMember
renderAnnotation?: RenderAnnotationCallback
renderBlock?: RenderBlockCallback
renderField: RenderFieldCallback
renderInlineBlock?: RenderBlockCallback
renderInput: RenderInputCallback
renderItem: RenderArrayOfObjectsItemCallback
renderPreview: RenderPreviewCallback
}
/**
*
* @hidden
* @beta
*/
export declare function ArrayOfOptionsInput(
props: ArrayOfObjectsInputProps | ArrayOfPrimitivesInputProps,
): JSX_2.Element
/**
* Array of predefined primitive options input
* Note: this input can only handle primitive values
*
*
* @hidden
* @beta
*/
export declare function ArrayOfPrimitiveOptionsInput(
props: ArrayOfPrimitivesInputProps,
): JSX_2.Element
/**
*
* @hidden
* @beta
*/
export declare interface ArrayOfPrimitivesComponents {
diff?: ComponentType<any>
field?: ComponentType<ArrayOfPrimitivesFieldProps>
input?: ComponentType<ArrayOfPrimitivesInputProps>
item?: ComponentType<PrimitiveItemProps>
preview?: ComponentType<PreviewProps>
}
/**
* @hidden
* @beta */
export declare type ArrayOfPrimitivesElementType<T extends any[]> = T extends (infer K)[]
? K
: unknown
/**
* @hidden
* @public */
export declare interface ArrayOfPrimitivesFieldProps extends BaseFieldProps {
schemaType: ArraySchemaType
value: unknown[] | undefined
collapsed?: boolean
collapsible?: boolean
onCollapse: () => void
onExpand: () => void
inputProps: ArrayOfPrimitivesInputProps
}
/** @public */
export declare interface ArrayOfPrimitivesFormNode<
T extends (string | number | boolean)[] = (string | number | boolean)[],
S extends ArraySchemaType = ArraySchemaType,
> extends BaseFormNode<T, S> {
/** The focus path of the form node. */
focusPath: Path
/**
* @hidden
* @beta */
members: ArrayOfPrimitivesMember[]
}
/**
* @hidden
* @beta */
export declare function ArrayOfPrimitivesFunctions<
MemberType extends string | boolean | number,
SchemaType extends ArraySchemaType,
>(props: ArrayInputFunctionsProps<MemberType, SchemaType>): JSX_2.Element
/**
* Note: this should be a class component until React provides support for a hook version of getSnapshotBeforeUpdate
*
* @hidden
* @beta
*/
export declare class ArrayOfPrimitivesInput extends PureComponent<
ArrayOfPrimitivesInputProps,
State
> {
_element: HTMLElement | null
constructor(props: ArrayOfPrimitivesInputProps)
handleAppend: (itemValue: PrimitiveValue) => void
handlePrepend: (itemValue: PrimitiveValue) => void
handleSortEnd: (event: {fromIndex: number; toIndex: number}) => void
handleItemMoveStart: () => void
handleItemMoveEnd: () => void
focus(): void
getSnapshotBeforeUpdate(prevProps: ArrayOfPrimitivesInputProps):
| {
prevFocusedIndex: PathSegment
restoreSelection: {
text: string
start: number | null
end: number | null
value: string
}
}
| {
prevFocusedIndex?: undefined
restoreSelection?: undefined
}
| null
componentDidUpdate(
prevProps: ArrayOfPrimitivesInputProps,
prevState: Record<string, unknown>,
snapshot?: {
restoreSelection: {
start: number
end: number
}
prevFocusedIndex: number
},
): void
renderArrayItem: (props: Omit<PrimitiveItemProps, 'renderDefault'>) => JSX_2.Element
render(): JSX_2.Element
}
/**
* @hidden
* @public */
export declare interface ArrayOfPrimitivesInputProps<
T extends string | boolean | number = string | boolean | number,
S extends ArraySchemaType = ArraySchemaType,
> extends BaseInputProps,
ArrayOfPrimitivesFormNode<T[], S> {
/**
* @hidden
* @beta */
arrayFunctions?: ComponentType<ArrayInputFunctionsProps<T, S>>
onSetCollapsed: (collapsed: boolean) => void
/**
* @hidden
* @beta */
onChange: (patch: FormPatch | FormPatch[] | PatchEvent) => void
/**
* @hidden
* @beta */
onItemAppend: (item: ArrayOfPrimitivesElementType<T[]>) => void
/**
* @hidden
* @beta */
onItemPrepend: (item: ArrayOfPrimitivesElementType<T[]>) => void
/**
* @hidden
* @beta */
onItemRemove: (index: number) => void
/**
* @hidden
* @beta */
onMoveItem: (event: ArrayInputMoveItemEvent) => void
/**
* @hidden
* @beta */
onInsert: (event: {items: T[]; position: 'before' | 'after'; referenceIndex: number}) => void
/**
* @hidden
* @beta */
resolveUploader: UploaderResolver<NumberSchemaType | BooleanSchemaType | StringSchemaType>
/**
* @hidden
* @beta */
onUpload: (event: UploadEvent) => void
/**
* @hidden
* @beta */
onIndexFocus: (index: number) => void
/**
* @hidden
* @beta */
renderAnnotation?: RenderAnnotationCallback
/**
* @hidden
* @beta */
renderBlock?: RenderBlockCallback
/**
* @hidden
* @beta */
renderInlineBlock?: RenderBlockCallback
/**
* @hidden
* @beta */
renderInput: RenderInputCallback
/**
* @hidden
* @beta */
renderItem: RenderArrayOfPrimitivesItemCallback
/**
* @hidden
* @beta */
renderPreview: RenderPreviewCallback
/**
* @hidden
* @beta */
elementProps: ComplexElementProps
}
/**
*
* @hidden
* @beta
*/
export declare function ArrayOfPrimitivesItem(props: PrimitiveMemberItemProps): JSX_2.Element
/**
* @hidden
* @beta */
export declare interface ArrayOfPrimitivesItemMember<
Node extends PrimitiveFormNode = PrimitiveFormNode,
> {
kind: 'item'
key: string
index: number
open: boolean
parentSchemaType: ArraySchemaType
/**
* @hidden
* @beta */
item: Node
}
/**
* @hidden
* @beta */
export declare type ArrayOfPrimitivesMember = ArrayOfPrimitivesItemMember | ArrayItemError
/** @internal */
export declare function asLoadable<T>(): OperatorFunction<T, LoadableState<T>>
/**
* @hidden
* @beta
*/
export declare type AssetSourceResolver = ComposableOption<AssetSource[], ConfigContext>
/**
* @hidden
* @beta
*/
export declare type AsyncComposableOption<TValue, TContext> = (
prev: TValue,
context: TContext,
) => Promise<TValue>
/** @internal */
export declare type AsyncConfigPropertyReducer<TValue, TContext> = (
prev: TValue,
config: PluginOptions,
context: TContext,
) => TValue | Promise<TValue>
/**
* Authentication options
*
* @public
*/
export declare interface AuthConfig {
/**
* Login method to use for the studio. Can be one of:
* - `dual` (default) - attempt to use cookies where possible, falling back to
* storing authentication token in `localStorage` otherwise
* - `cookie` - explicitly disable `localStorage` method, relying only on cookies. May fail due
* to cookies being treated as third-party cookies in some browsers, thus the default is `dual`.
* - `token` - explicitly disable cookies, relying only on `localStorage` method
*/
loginMethod?: LoginMethod
/**
* Whether to append the providers specified in `providers` with the default providers from the
* API, or replace the default providers with the ones specified.
*
* @deprecated Use the function form of `providers` instead for more control
*/
mode?: 'append' | 'replace'
/**
* If true, the "Choose login provider" (eg "Google, "GitHub", "E-mail/password") screen
* will be skipped if only a single provider is configured in the `providers` array -
* instead it will redirect unauthenticated users straight to the authenticatino URL.
*/
redirectOnSingle?: boolean
/**
* Array of authentication providers to use, or a function that takes an array of default
* authentication providers (fetched from the Sanity API) and should return a new list of
* providers. This can be used to selectively replace, add or remove providers from the
* list of choices.
*
* @remarks If a static array of providers is provided, the `mode` property is taken into account
* when determining what to do with it - `append` will append the providers to the default set
* of providers, while `replace` will replace the default providers with the ones specified.
*
* If not set, the default providers will be used.
*/
providers?: AuthProvider[] | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>)
/**
* The API hostname for requests. Should usually be left undefined,
* but can be set if using custom cname for API domain.
*/
apiHost?: string
}
/**
* A provider of authentication.
*
* By default, a list of providers for a project will be fetched from the
* {@link https://api.sanity.io/v1/auth/providers | Sanity API}, but you may choose to limit this
* list by explicitly defining the providers you want to allow, or add additional custom providers
* that conforms to the authentication provider specification outlined in
* {@link https://www.sanity.io/docs/third-party-login | the documentation}.
*
* @public
*/
export declare interface AuthProvider {
/**
* URL-friendly identifier/name for the provider, eg `github`
*/
name: string
/**
* Human friendly title for the provider, eg `GitHub`
*/
title: string
/**
* URL for the authentication endpoint that will trigger the authentication flow
*/
url: string
/**
* URL for a logo to display next to the provider in the login screen
*/
logo?: string
}
/**
* The unit an `AuthStore` emits to determine the user's authentication state.
*
* @beta
* @hidden
*/
export declare interface AuthState {
/**
* Similar to a logged-in flag. This state is used in places like the
* `AuthBoundary` to determine whether or not it should render the
* `NotAuthenticatedComponent`. Implementers may choose to set this to `true`
* while also also emitting a `currentUser` of `null` if a `null` user is
* accepted (e.g. a project that doesn't require a login)
*/
authenticated: boolean
/**
* The value of the user logged in or `null` if none is provided
*/
currentUser: CurrentUser | null
/**
* A client that is expected to be pre-configured to allow for any downstream
* requests in the Studio
*/
client: SanityClient
}
/**
* The interface used by the Studio that produces a `SanityClient` and
* `CurrentUser` that gets passed to the resulting `Workspace`s and `Source`s.
*
* NOTE: This interface is primarily for internal use. Refer to
* `createAuthStore` instead.
*
* @beta
* @hidden
*/
export declare interface AuthStore {
/**
* Emits `AuthState`s. This should update when the user's auth state changes.
* E.g. After a login, a new `AuthState` could be emitted with a non-null
* `currentUser` and `authenticated: true`
*
* NOTE: all auth store implementations should emit on subscribe using
* something like shareReplay(1) to ensure all new subscribers get an
* `AuthState` value on subscribe
*/
state: Observable<AuthState>
/**
* Emits auth tokens, or `null` if not configured to use them or they do not exist
*/
token?: Observable<string | null>
/**
* Custom auth stores are expected to implement a UI that initiates the user's
* authentication. For the typical case in `createAuthStore`, this means
* loading the providers and showing them as options to the user.
*/
LoginComponent?: ComponentType<LoginComponentProps>
/**
* Custom auth stores can implement a function that runs when the user logs
* out. The implementation is expected to remove all credentials both locally
* and on the server.
*/
logout?: () => void
/**
* Custom auth stores can implement a function that is designated to run when
* the Studio loads (e.g. to trade a session ID for a token in cookie-less
* mode). Within the Studio, this is called within the `AuthBoundary`.
*/
handleCallbackUrl?: () => Promise<void>
}
/** @internal */
export declare interface AuthStoreOptions extends AuthConfig {
clientFactory?: (options: ClientConfig) => SanityClient
projectId: string
dataset: string
}
/** @internal */
export declare const AutoCollapseMenu: ForwardRefExoticComponent<
Omit<CollapseMenuProps, 'children' | 'collapsed'> & {
menuOptions: ReactElement[]
} & RefAttributes<HTMLDivElement>
>
/** @internal */
export declare type AvailabilityReason = 'READABLE' | 'PERMISSION_DENIED' | 'NOT_FOUND'
/** @internal */
export declare interface AvailabilityResponse {
omitted: {
id: string
reason: 'existence' | 'permission'
}[]
}
declare type BaseButtonProps = Pick<
ButtonProps_2,
| 'as'
| 'icon'
| 'iconRight'
| 'justify'
| 'loading'
| 'mode'
| 'paddingY'
| 'selected'
| 'tone'
| 'type'
| 'width'
> & {
size?: 'default' | 'large'
}
/**
* @hidden
* @public */
export declare interface BaseFieldProps {
/** @beta */
actions?: DocumentFieldAction[]
/** @internal @deprecated DO NOT USE */
__internal_comments?: FieldCommentsProps
/** @internal @deprecated ONLY USED BY AI ASSIST PLUGIN */
__internal_slot?: ReactNode
schemaType: SchemaType
title: string | undefined
description: string | undefined
/**
* @hidden
* @beta */
presence: FormNodePresence[]
validation: FormNodeValidation[]
level: number
inputId: string
value: unknown | undefined
path: Path
name: string
index: number
changed: boolean
children: ReactNode
renderDefault: (props: FieldProps) => ReactElement
}
/**
* @hidden
* @beta */
declare interface BaseFileInputProps extends ObjectInputProps<BaseFileInputValue, FileSchemaType> {
assetSources: AssetSource[]
directUploads?: boolean
observeAsset: (documentId: string) => Observable<FileAsset>
resolveUploader: UploaderResolver
client: SanityClient
t: (key: string, values?: Record<string, string>) => string
}
/**
* @hidden
* @beta */
declare interface BaseFileInputValue extends Partial<File_2> {
_upload?: UploadState
}
/**
* @hidden
* @public
*/
export declare interface BaseFormNode<T = unknown, S extends SchemaType = SchemaType> {
/** The unique identifier of the node. */
id: string
/** The schema type of the node. */
schemaType: S
/** The level of the node in the form hierarchy. */
level: number
/** The path of the node in the form hierarchy. */
path: Path
/**
* @hidden
* @beta */
presence: FormNodePresence[]
/** The validation markers of the node. */
validation: FormNodeValidation[]
/** The value of the node. */
value: T | undefined
/** Whether the node is read-only. */
readOnly?: boolean
/** Whether the node is focused. */
focused?: boolean
/** Whether the node has changes in a draft. */
changed: boolean
}
/**
* @hidden
* @beta */
declare interface BaseImageInputProps
extends ObjectInputProps<BaseImageInputValue, ImageSchemaType> {
assetSources: AssetSource[]
directUploads?: boolean
imageUrlBuilder: ImageUrlBuilder
observeAsset: (documentId: string) => Observable<ImageAsset>
resolveUploader: UploaderResolver
client: SanityClient
t: (key: string, values?: Record<string, string>) => string
}
/**
* @hidden
* @beta */
declare interface BaseImageInputValue extends Partial<Image_2> {
_upload?: UploadState
}
/**
* @hidden
* @public */
export declare interface BaseInputProps {
renderDefault: (props: InputProps) => ReactElement
}
/**
* Base intent parameters
*
* @public
* @todo dedupe with core/structure
*/
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
}
/**
* Props for the base item component.
*
* @public
*/
export declare interface BaseItemProps<T> {
/** The schema type of the item. */
schemaType: SchemaType
/** The key of the item. */
key: string
/** The index of the item. */
index: number
/** The level of the item. */
level: number
/** The value of the item. */
value: unknown
/** The path of the item. */
path: Path
/** The title of the item. */
title: string | undefined
/** The description of the item. */
description: string | undefined
/** The ID of the input element. */
inputId: string
/** The function to call when the item receives focus. */
onFocus: (event: FocusEvent_2) => void
/** The function to call when the item loses focus. */
onBlur: (event: FocusEvent_2) => void
/** Whether the item is read-only. */
readOnly?: boolean
/** Whether the item is focused. */
focused?: boolean
/** The function to call when the item is removed. */
onRemove: () => void
/**
* @hidden
* @beta */
onInsert: (event: Omit<ArrayInputInsertEvent<T>, 'referenceItem'>) => void
/** The children of the item. */
children: ReactNode
/** The validation markers for the item. */
validation: FormNodeValidation[]
/**
* @hidden
* @beta */
presence: FormNodePresence[]
/** The function to call to render the default item. See {@link ItemProps} */
renderDefault: (props: ItemProps) => ReactElement
}
/** @internal */
export declare function BetaBadge(
props: BetaBadgeProps & Omit<HTMLProps<HTMLDivElement>, 'ref'>,
): JSX_2.Element
/** @internal */
export declare type BetaBadgeProps = Omit<BadgeProps, 'mode' | 'tone'>
/**
* Props for rendering a Portable Text annotation
*
* @public
* @remarks If you want to render a mix of the annotated text and non-text content, you have to attribute
* the non-text containers with `contentEditable={false}`. See the second example.
* @example Simple example of customizing the annotation text to render yellow.
* ```ts
* (props: BlockAnnotationProps) =>
* props.renderDefault({
* ...props,
* textElement: <span style={{color: 'yellow'}}>{props.textElement}</span>,
* })
* ```
* @example Simple example of rendering the annotation with a custom modal for editing.
* Note that the form content container is attributed as `contentEditable={false}`.
* This is to signal to the text editor that this content isn't part of the editable text.
* ```ts
* (props: BlockAnnotationProps) => {
* return (
* <>
* // Render the annotated text
* <span onClick={props.onOpen}>
* {props.textElement}
* </span>
* // Render the editing form if the object is opened
* {props.open && (
* <Dialog
* contentEditable={false} // Attribute this as non-editable to the text editor
* header={`Edit ${props.schemaType.title}`}
* id={`dialog-${props.value._key}`}
* onClickOutside={props.onClose}
* onClose={props.onClose}
* >
* <Box margin={2} padding={2}>
* {props.children}
* </Box>
* </Dialog>
* )}
* </>
* )
* }
* ```
* */
export declare interface BlockAnnotationProps {
/**
* Boundary element of the floating toolbar element.
*/
__unstable_floatingBoundary: HTMLElement | null
/**
* Boundary element where the text for this annotation appears.
*/
__unstable_referenceBoundary: HTMLElement | null
/**
* DOM element for the annotated text.
*/
__unstable_referenceElement: HTMLElement | null
/**
* Wether the annotated text node has editor focus.
* @remarks differs from `focused` which is wether the annotation object has form focus.
*/
__unstable_textElementFocus?: boolean
/**
* The input form for the annotation object.
* @remarks If you wrap this in something, you must make sure to put `contentEditable={false}` on the root container.
* Otherwise the editor will think content is part of the editable text and will error.
*/
children: ReactNode
/**
* If the editor form for this annotation object currently have form focus.
*/
focused: boolean
/**
* Markers (meta data) connected to this annotation.
* @deprecated - use `renderBlock` and `renderInlineBlock` interfaces instead
*/
markers: PortableTextMarker[]
/**
* Closes the editing form connected to this annotation.
*/
onClose: () => void
/**
* Opens the editing form connected to this annotation.
*/
onOpen: () => void
/**
* Focus a form node in the object for this annotation.
* @param path - the relative path to the form node to put focus on.
*/
onPathFocus: (path: Path) => void
/**
* Removes the annotation object from the text.
*/
onRemove: () => void
/**
* If the annotation is currently opened for editing.
*/
open: boolean
/**
* The parent schema type. For annotations this this the block type.
*/
parentSchemaType: SchemaType
/**
* The full form path to this annotation from document root.
*/
path: Path
/**
* Form presence for this annotation.
*/
presence: FormNodePresence[]
/**
* Is the annotation object read only?
*/
readOnly: boolean
/**
* Plugin chain render callback.
*/
renderAnnotation?: RenderAnnotationCallback
/**
* Plugin chain render callback.
*/
renderBlock?: RenderBlockCallback
/**
* Plugin chain render callback.
*/
renderDefault: (props: BlockAnnotationProps) => ReactElement
/**
* Plugin chain render callback.
*/
renderField: RenderFieldCallback
/**
* Plugin chain render callback.
*/
renderInlineBlock?: RenderBlockCallback
/**
* Plugin chain render callback.
*/
renderInput: RenderInputCallback
/**
* Plugin chain render callback.
*/
renderItem: RenderArrayOfObjectsItemCallback
/**
* Plugin chain render callback.
*/
renderPreview: RenderPreviewCallback
/**
* The schema type for the annotation object.
*/
schemaType: ObjectSchemaType & {
i18nTitleKey?: string
}
/**
* If the annotated text currently is selected by the user.
*/
selected: boolean
/**
* React element of the text that is being annotated.
*/
textElement: ReactElement
/**
* Form validation for the annotation object.
*/
validation: FormNodeValidation[]
/**
* Value of the annotation object.
*/
value: PortableTextObject
}
/**
* Props for rendering text decorations in Portable Text blocks.
* It could be decorations like bold, italic, subscript etc.
*
* @public
*/
export declare interface BlockDecoratorProps {
/**
* The span node as rendered without the decorator.
*/
children: ReactElement
/**
* If the span node currently is focused by the user.
*/
focused: boolean
/**
* The default render function for this decorator,
* some decorators are proved by default and has a default rendering.
*/
renderDefault: (props: BlockDecoratorProps) => ReactElement
/**
* The decorator schema type. Icon can be found here.
*/
schemaType: BlockDecoratorDefinition
/**
* If the span node text currently is selected by the user.
*/
selected: boolean
/**
* The title of the decorator (e.g. 'Underlined text') for UI-representation.
*/
title: string
/**
* The value of the decorator (e.g. 'underlined') as it
* appears in the child.marks array of the text node.
*/
value: string
}
/**
* @hidden
* @beta */
export declare function BlockImagePreview(props: BlockImagePreviewProps): JSX_2.Element
/**
* @hidden
* @beta */
export declare type BlockImagePreviewProps = Omit<PreviewProps<'blockImage'>, 'renderDefault'>
/**
* Props for rendering a Portable Text block as a list item.
*
* @public
*/
export declare interface BlockListItemProps {
/**
* The block that is rendered as a list item.
*/
block: PortableTextTextBlock
/**
* The block rendered without the list style.
*/
children: ReactElement
/**
* If the block currently is focused by the user.
*/
focused: boolean
/**
* The nesting level of this list item.
*/
level: number
/**
* The default function for rendering this as a list item. Some list types are built in and
* will have a default rendering.
*/
renderDefault: (props: BlockListItemProps) => ReactElement
/**
* The schema type for this list type. Icon can be found here.
*/
schemaType: BlockListDefinition
/**
* If the user currently has a text selection in this block.
*/
selected: boolean
/**
* The title of the list item type (e.g. 'Bullet list') for UI-representation.
*/
title: string
/**
* The value of the list item type (e.g. 'bullet') as it appears in the block.listItem attribute.
*/
value: string
}
/**
* @hidden
* @beta */
export declare function BlockPreview(
props: Omit<PreviewProps<'block'>, 'renderDefault'>,
): JSX_2.Element
/**
* Props for rendering a Portable Text block
*
* @public
*/
export declare interface BlockProps {
/**
* Boundary element of the floating toolbar element.
*/
__unstable_floatingBoundary: HTMLElement | null
/**
* Boundary element for the block.
*/
__unstable_referenceBoundary: HTMLElement | null
/**
* DOM element for the block.
*/
__unstable_referenceElement: HTMLElement | null
/**
* The default rendering of the block (the text).
*/
children: ReactNode
/**
* If the block currently is focused by the user.
*/
focused: boolean
/**
* Markers (meta data) connected to this annotation.
* @deprecated - use `renderBlock` and `renderInlineBlock` interfaces instead
*/
markers: PortableTextMarker[]
/**
* Closes the editing form connected to this block.
* For regular text blocks this is not relevant.
*/
onClose: () => void
/**
* Opens the editing form connected to this block.
* For regular text blocks this is not relevant.
*/
onOpen: () => void
/**
* Focus a form node in this block.
* @param path - the relative path to the form node to put focus on.
*/
onPathFocus: (path: Path) => void
/**
* Removes the block.
*/
onRemove: () => void
/**
* If the block is currently opened for editing.
*/
open: boolean
/**
* The parent schema type (array type).
*/
parentSchemaType: ArraySchemaType | ObjectSchemaType
/**
* The full form path to this block from document root.
*/
path: Path
/**
* Form presence for this block.
*/
presence: FormNodePresence[]
/**
* Is the block object read only?
*/
readOnly: boolean
/**
* Plugin chain render callback.
*/
renderAnnotation?: RenderAnnotationCallback
/**
* Plugin chain render callback.
*/
renderBlock?: RenderBlockCallback
/**
* Plugin chain render callback (default rendering function of the block).
*/
renderDefault: (props: BlockProps) => ReactElement
/**
* Plugin chain render callback.
*/
renderField: RenderFieldCallback
/**
* Plugin chain render callback.
*/
renderInlineBlock?: RenderBlockCallback
/**
* Plugin chain render callback.
*/
renderInput: RenderInputCallback
/**
* Plugin chain render callback.
*/
renderItem: RenderArrayOfObjectsItemCallback
/**
* Plugin chain render callback.
*/
renderPreview: RenderPreviewCallback
/**
* The schema type for the block.
*/
schemaType: ObjectSchemaType
/**
* If the block is in the user's selection.
*/
selected: boolean
/**
* Form validation for the block object.
*/
validation: FormNodeValidation[]
/**
* Value of the block.
*/
value: PortableTextBlock
}
/**
* Props for rendering a text block style.
*
* @public
*/
export declare interface BlockStyleProps {
/**
* The value of the block that is rendered style for.
*/
block: PortableTextTextBlock
/**
* The block as rendered without this style.
*/
children: ReactElement
/**
* If the block currently has focus in the text editor.
*/
focused: boolean
/**
* The default rendering function for this style.
*/
renderDefault: (props: BlockStyleProps) => ReactElement
/**
* The schema type for this style.
*/
schemaType: BlockStyleDefinition
/**
* If the block currently have a text selection.
*/
selected: boolean
/**
* The title of the style (e.g. 'Large Heading') for UI-representation.
*/
title: string
/**
* The value of the style (e.g. 'h1') as it appears in the block's `.style` property value.
*/
value: string
}
/**
*
* @hidden
* @beta
*/
export declare interface BooleanComponents {
diff?: ComponentType<any>
field?: ComponentType<BooleanFieldProps>
input?: ComponentType<BooleanInputProps>
item?: ComponentType<PrimitiveItemProps>
preview?: ComponentType<PreviewProps>
}
/** @internal */
export declare type BooleanDiff = BooleanDiff_2<Annotation>
/**
* @hidden
* @public */
export declare interface BooleanFieldProps extends BaseFieldProps {
schemaType: BooleanSchemaType
value: boolean | undefined
inputProps: BooleanInputProps
}
/** @public */
export declare type BooleanFormNode<S extends BooleanSchemaType = BooleanSchemaType> = BaseFormNode<
boolean,
S
>
/**
*
* @hidden
* @beta
*/
export declare function BooleanInput(props: BooleanInputProps): JSX_2.Element
/**
* @hidden
* @public */
export declare interface BooleanInputProps<S extends BooleanSchemaType = BooleanSchemaType>
extends BaseInputProps,
BooleanFormNode<S> {
/**
* @hidden
* @beta */
onChange: (patch: FormPatch | FormPatch[] | PatchEvent) => void
/**
* A shorthand aggregation of any validation errors the input currently have
* Will be falsey if no error.
* In the case of multiple errors it will be a newline delimited string of each error message
* For advanced use cases use the ´validation´ prop which contains more levels and details
*/
validationError?: string
/**
* @hidden
* @beta */
elementProps: PrimitiveInputElementProps
}
/**
* @hidden
* @beta */
export declare type BufferedDocumentEvent =
| SnapshotEvent
| DocumentRebaseEvent
| DocumentMutationEvent
| CommittedEvent
/** @internal */
export declare interface BufferedDocumentWrapper {
consistency$: Observable<boolean>
remoteSnapshot$: Observable<RemoteSnapshotEvent>
events: Observable<BufferedDocumentEvent>
commitRequest$: Observable<CommitRequest>
patch: (patches: any[]) => MutationPayload[]
create: (document: Partial<SanityDocument>) => MutationPayload
createIfNotExists: (document: SanityDocument) => MutationPayload
createOrReplace: (document: SanityDocument) => MutationPayload
delete: () => MutationPayload
mutate: (mutations: MutationPayload[]) => void
commit: () => void
}
/**
* Build a Sanity UI theme from legacy CSS properties.
*
* @example
* ```tsx
* import {buildLegacyTheme, defineConfig} from 'sanity'
*
* export default defineConfig({
* // project configuration ...
*
* // Customize theming
* theme: buildLegacyTheme({
* '--black': '#000',
* '--gray': '#777',
* '--focus-color': '#00f',
* })
* })
* ```
*
* @param partialLegacyTheme - Properties to override the theme with. See {@link LegacyThemeProps}
* @public
* @deprecated Legacy theming will be deprecated in a future version of Sanity Studio
*/
export declare function buildLegacyTheme(partialLegacyTheme: Partial<LegacyThemeProps>): StudioTheme
/** @internal */
declare type ButtonProps = BaseButtonProps & (ButtonWithText | IconButton)
declare type ButtonWithText = {
text: string
tooltipProps?: TooltipProps | null
icon?: ButtonProps_2['icon']
}
/** @internal */
export declare function ChangeBreadcrumb(props: {
change?: FieldChangeNode
titlePath: ChangeTitlePath
}): JSX_2.Element
/** @internal */
export declare const ChangeConnectorRoot: typeof EnabledChangeConnectorRoot
/**
* This is used to draw the bar that wraps the diff components in the changes panel
*
* @internal
*/
export declare const ChangeFieldWrapper: (props: {
path: Path
children: ReactNode
hasHover: boolean
}) => JSX_2.Element
/** @internal */
export declare function ChangeIndicator(
props: ChangeIndicatorProps & Omit<HTMLProps<HTMLDivElement>, 'as'>,
): JSX_2.Element
/** @internal */
export declare const ChangeIndicatorContext: Context<ChangeIndicatorContextValue>
/** @internal */
export declare interface ChangeIndicatorContextValue {
value?: unknown
focusPath: Path
path: Path
fullPath: Path
isChanged: boolean
}
/** @internal */
export declare interface ChangeIndicatorProps {
path: Path
hasFocus: boolean
isChanged: boolean
withHoverEffect?: boolean
}
/** @internal */
export declare function ChangeList({diff, fields, schemaType}: ChangeListProps): ReactElement | null
/** @internal */
export declare interface ChangeListProps {
schemaType: ObjectSchemaType
diff: ObjectDiff
fields?: string[]
}
/** @internal */
export declare type ChangeNode = GroupChangeNode | FieldChangeNode
/** @internal */
export declare function ChangeResolver(props: ChangeResolverProps): JSX_2.Element | null
/** @internal */
export declare interface ChangeResolverProps {
change: ChangeNode
readOnly?: ConditionalProperty
hidden?: ConditionalProperty
}
/** @internal */
export declare type ChangeTitlePath = (string | FromToIndex)[]
/** @internal */
export declare function ChangeTitleSegment(props: {
change?: F