@sanity/sdk-react 0.0.0-alpha.18 → 0.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +54 -111
  2. package/dist/_chunks-es/useLogOut.js +24 -53
  3. package/dist/_chunks-es/useLogOut.js.map +1 -1
  4. package/dist/assets/bundle-CcAyERuZ.css +11 -0
  5. package/dist/components.d.ts +172 -69
  6. package/dist/components.js +277 -197
  7. package/dist/components.js.map +1 -1
  8. package/dist/hooks.d.ts +49 -4307
  9. package/dist/hooks.js +67 -646
  10. package/dist/hooks.js.map +1 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +2 -10
  13. package/dist/index.js.map +1 -1
  14. package/package.json +42 -36
  15. package/src/_exports/components.ts +13 -3
  16. package/src/_exports/hooks.ts +2 -45
  17. package/src/_exports/index.ts +10 -1
  18. package/src/components/DocumentGridLayout/DocumentGridLayout.stories.tsx +113 -0
  19. package/src/components/DocumentGridLayout/DocumentGridLayout.test.tsx +42 -0
  20. package/src/components/DocumentGridLayout/DocumentGridLayout.tsx +21 -0
  21. package/src/components/DocumentListLayout/DocumentListLayout.stories.tsx +105 -0
  22. package/src/components/DocumentListLayout/DocumentListLayout.test.tsx +42 -0
  23. package/src/components/DocumentListLayout/DocumentListLayout.tsx +12 -0
  24. package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.md +49 -0
  25. package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.stories.tsx +39 -0
  26. package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.test.tsx +30 -0
  27. package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.tsx +171 -0
  28. package/src/components/Login/LoginLinks.test.tsx +12 -3
  29. package/src/components/Login/LoginLinks.tsx +29 -14
  30. package/src/components/auth/AuthBoundary.test.tsx +17 -4
  31. package/src/components/auth/AuthBoundary.tsx +4 -20
  32. package/src/components/auth/Login.test.tsx +16 -2
  33. package/src/components/auth/Login.tsx +30 -11
  34. package/src/components/auth/LoginCallback.test.tsx +17 -2
  35. package/src/components/auth/LoginCallback.tsx +10 -5
  36. package/src/components/auth/LoginError.test.tsx +17 -2
  37. package/src/components/auth/LoginError.tsx +16 -11
  38. package/src/components/auth/LoginFooter.test.tsx +16 -2
  39. package/src/components/auth/LoginFooter.tsx +24 -8
  40. package/src/components/auth/LoginLayout.test.tsx +16 -2
  41. package/src/components/auth/LoginLayout.tsx +38 -8
  42. package/src/{context → components/context}/SanityProvider.test.tsx +2 -2
  43. package/src/components/context/SanityProvider.tsx +42 -0
  44. package/src/css/css.config.js +220 -0
  45. package/src/css/paramour.css +2347 -0
  46. package/src/css/styles.css +11 -0
  47. package/src/hooks/auth/useAuthState.tsx +5 -4
  48. package/src/hooks/auth/useAuthToken.tsx +1 -1
  49. package/src/hooks/auth/useCurrentUser.tsx +4 -27
  50. package/src/hooks/auth/useHandleCallback.tsx +0 -1
  51. package/src/hooks/auth/useLogOut.tsx +1 -1
  52. package/src/hooks/auth/useLoginUrls.tsx +0 -1
  53. package/src/hooks/client/useClient.test.tsx +130 -0
  54. package/src/hooks/client/useClient.ts +30 -8
  55. package/src/hooks/context/useSanityInstance.test.tsx +2 -2
  56. package/src/hooks/context/useSanityInstance.ts +8 -24
  57. package/src/hooks/documentCollection/useDocuments.test.ts +130 -0
  58. package/src/hooks/documentCollection/useDocuments.ts +87 -0
  59. package/src/hooks/helpers/createCallbackHook.tsx +2 -3
  60. package/src/hooks/helpers/createStateSourceHook.test.tsx +0 -66
  61. package/src/hooks/helpers/createStateSourceHook.tsx +10 -29
  62. package/src/hooks/preview/usePreview.test.tsx +10 -19
  63. package/src/hooks/preview/usePreview.tsx +13 -67
  64. package/dist/_chunks-es/SanityInstanceContext.js +0 -6
  65. package/dist/_chunks-es/SanityInstanceContext.js.map +0 -1
  66. package/dist/context.d.ts +0 -47
  67. package/dist/context.js +0 -15
  68. package/dist/context.js.map +0 -1
  69. package/src/_exports/context.ts +0 -2
  70. package/src/components/SDKProvider.test.tsx +0 -79
  71. package/src/components/SDKProvider.tsx +0 -42
  72. package/src/components/SanityApp.test.tsx +0 -156
  73. package/src/components/SanityApp.tsx +0 -90
  74. package/src/components/auth/authTestHelpers.tsx +0 -11
  75. package/src/components/utils.ts +0 -22
  76. package/src/context/SanityInstanceContext.ts +0 -4
  77. package/src/context/SanityProvider.tsx +0 -50
  78. package/src/hooks/_synchronous-groq-js.mjs +0 -4
  79. package/src/hooks/comlink/useFrameConnection.test.tsx +0 -157
  80. package/src/hooks/comlink/useFrameConnection.ts +0 -130
  81. package/src/hooks/comlink/useManageFavorite.test.ts +0 -106
  82. package/src/hooks/comlink/useManageFavorite.ts +0 -98
  83. package/src/hooks/comlink/useRecordDocumentHistoryEvent.test.ts +0 -77
  84. package/src/hooks/comlink/useRecordDocumentHistoryEvent.ts +0 -75
  85. package/src/hooks/comlink/useWindowConnection.test.ts +0 -125
  86. package/src/hooks/comlink/useWindowConnection.ts +0 -94
  87. package/src/hooks/datasets/useDatasets.ts +0 -37
  88. package/src/hooks/document/useApplyActions.test.ts +0 -25
  89. package/src/hooks/document/useApplyActions.ts +0 -74
  90. package/src/hooks/document/useDocument.test.ts +0 -81
  91. package/src/hooks/document/useDocument.ts +0 -107
  92. package/src/hooks/document/useDocumentEvent.test.ts +0 -63
  93. package/src/hooks/document/useDocumentEvent.ts +0 -54
  94. package/src/hooks/document/useDocumentSyncStatus.test.ts +0 -16
  95. package/src/hooks/document/useDocumentSyncStatus.ts +0 -30
  96. package/src/hooks/document/useEditDocument.test.ts +0 -179
  97. package/src/hooks/document/useEditDocument.ts +0 -195
  98. package/src/hooks/document/usePermissions.ts +0 -82
  99. package/src/hooks/infiniteList/useInfiniteList.test.tsx +0 -152
  100. package/src/hooks/infiniteList/useInfiniteList.ts +0 -174
  101. package/src/hooks/paginatedList/usePaginatedList.test.tsx +0 -259
  102. package/src/hooks/paginatedList/usePaginatedList.ts +0 -290
  103. package/src/hooks/projection/useProjection.test.tsx +0 -218
  104. package/src/hooks/projection/useProjection.ts +0 -135
  105. package/src/hooks/projects/useProject.ts +0 -45
  106. package/src/hooks/projects/useProjects.ts +0 -41
  107. package/src/hooks/query/useQuery.test.tsx +0 -188
  108. package/src/hooks/query/useQuery.ts +0 -103
  109. package/src/hooks/users/useUsers.test.ts +0 -163
  110. package/src/hooks/users/useUsers.ts +0 -107
  111. package/src/utils/getEnv.ts +0 -21
  112. package/src/version.ts +0 -8
  113. package/src/vite-env.d.ts +0 -10
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["../src/hooks/auth/useAuthToken.tsx","../src/hooks/auth/useCurrentUser.tsx","../src/hooks/client/useClient.ts","../src/hooks/comlink/useFrameConnection.ts","../src/hooks/comlink/useWindowConnection.ts","../src/hooks/comlink/useManageFavorite.ts","../src/hooks/comlink/useRecordDocumentHistoryEvent.ts","../src/hooks/datasets/useDatasets.ts","../src/hooks/document/useApplyActions.ts","../src/hooks/document/useDocument.ts","../src/hooks/document/useDocumentEvent.ts","../src/hooks/document/useDocumentSyncStatus.ts","../src/hooks/document/useEditDocument.ts","../src/hooks/document/usePermissions.ts","../src/hooks/query/useQuery.ts","../src/hooks/infiniteList/useInfiniteList.ts","../src/hooks/paginatedList/usePaginatedList.ts","../src/hooks/preview/usePreview.tsx","../src/hooks/projection/useProjection.ts","../src/hooks/projects/useProject.ts","../src/hooks/projects/useProjects.ts","../src/hooks/users/useUsers.ts"],"sourcesContent":["import {getTokenState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * Hook to get the currently logged in user\n * @internal\n * @returns The current user or null if not authenticated\n */\nexport const useAuthToken = createStateSourceHook(getTokenState)\n","import {type CurrentUser, getCurrentUserState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\ntype UseCurrentUser = {\n /**\n * @public\n *\n * Provides the currently authenticated user’s profile information.\n *\n * @category Users\n * @returns The current user data\n *\n * @example Rendering a basic user profile\n * ```\n * const user = useCurrentUser()\n *\n * return (\n * <figure>\n * <img src={user?.profileImage} alt=`Profile image for ${user?.name}` />\n * <h2>{user?.name}</h2>\n * </figure>\n * )\n * ```\n */\n (): CurrentUser | null\n}\n\n/**\n * @public\n * @TODO This should not return null — users of a custom app will always be authenticated via Core\n */\nexport const useCurrentUser: UseCurrentUser = createStateSourceHook(getCurrentUserState)\n","import {getClientState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * A React hook that provides a client that subscribes to changes in your application,\n * such as user authentication changes.\n *\n * @remarks\n * The hook uses `useSyncExternalStore` to safely subscribe to changes\n * and ensure consistency between server and client rendering.\n *\n * @category Platform\n * @returns A Sanity client\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const client = useClient({apiVersion: '2024-11-12'})\n * const [document, setDocument] = useState(null)\n * useEffect(async () => {\n * const doc = client.fetch('*[_id == \"myDocumentId\"]')\n * setDocument(doc)\n * }, [])\n * return <div>{JSON.stringify(document) ?? 'Loading...'}</div>\n * }\n * ```\n *\n * @public\n */\nexport const useClient = createStateSourceHook({\n getState: getClientState,\n getResourceId: (e) => e.resourceId,\n})\n","import {type Status} from '@sanity/comlink'\nimport {\n type FrameMessage,\n getOrCreateChannel,\n getOrCreateController,\n releaseChannel,\n type WindowMessage,\n} from '@sanity/sdk'\nimport {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @internal\n */\nexport type FrameMessageHandler<TWindowMessage extends WindowMessage> = (\n event: TWindowMessage['data'],\n) => TWindowMessage['response'] | Promise<TWindowMessage['response']>\n\n/**\n * @internal\n */\nexport interface UseFrameConnectionOptions<TWindowMessage extends WindowMessage> {\n name: string\n connectTo: string\n targetOrigin: string\n onMessage?: {\n [K in TWindowMessage['type']]: (data: Extract<TWindowMessage, {type: K}>['data']) => void\n }\n heartbeat?: boolean\n}\n\n/**\n * @internal\n */\nexport interface FrameConnection<TFrameMessage extends FrameMessage> {\n connect: (frameWindow: Window) => () => void // Return cleanup function\n sendMessage: <T extends TFrameMessage['type']>(\n ...params: Extract<TFrameMessage, {type: T}>['data'] extends undefined\n ? [type: T]\n : [type: T, data: Extract<TFrameMessage, {type: T}>['data']]\n ) => void\n status: Status\n}\n\n/**\n * @internal\n */\nexport function useFrameConnection<\n TFrameMessage extends FrameMessage,\n TWindowMessage extends WindowMessage,\n>(options: UseFrameConnectionOptions<TWindowMessage>): FrameConnection<TFrameMessage> {\n const {onMessage, targetOrigin, name, connectTo, heartbeat} = options\n const instance = useSanityInstance()\n const [status, setStatus] = useState<Status>('idle')\n\n const controller = useMemo(\n () => getOrCreateController(instance, targetOrigin),\n [instance, targetOrigin],\n )\n\n const channel = useMemo(\n () =>\n getOrCreateChannel(instance, {\n name,\n connectTo,\n heartbeat,\n }),\n [instance, name, connectTo, heartbeat],\n )\n\n useEffect(() => {\n if (!channel) return\n\n const unsubscribe = channel.onStatus((event) => {\n setStatus(event.status)\n })\n\n return unsubscribe\n }, [channel])\n\n useEffect(() => {\n if (!channel || !onMessage) return\n\n const unsubscribers: Array<() => void> = []\n\n Object.entries(onMessage).forEach(([type, handler]) => {\n // type assertion, but we've already constrained onMessage to have the correct handler type\n const unsubscribe = channel.on(type, handler as FrameMessageHandler<TWindowMessage>)\n unsubscribers.push(unsubscribe)\n })\n\n return () => {\n unsubscribers.forEach((unsub) => unsub())\n }\n }, [channel, onMessage])\n\n const connect = useCallback(\n (frameWindow: Window) => {\n const removeTarget = controller?.addTarget(frameWindow)\n return () => {\n removeTarget?.()\n }\n },\n [controller],\n )\n\n const sendMessage = useCallback(\n <T extends TFrameMessage['type']>(\n type: T,\n data?: Extract<TFrameMessage, {type: T}>['data'],\n ) => {\n channel?.post(type, data)\n },\n [channel],\n )\n\n // cleanup channel on unmount\n useEffect(() => {\n return () => {\n releaseChannel(instance, name)\n }\n }, [name, instance])\n\n return {\n connect,\n sendMessage,\n status,\n }\n}\n","import {type Status} from '@sanity/comlink'\nimport {type FrameMessage, getOrCreateNode, releaseNode, type WindowMessage} from '@sanity/sdk'\nimport {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @internal\n */\nexport type WindowMessageHandler<TFrameMessage extends FrameMessage> = (\n event: TFrameMessage['data'],\n) => TFrameMessage['response']\n\n/**\n * @internal\n */\nexport interface UseWindowConnectionOptions<TMessage extends FrameMessage> {\n name: string\n connectTo: string\n onMessage?: Record<TMessage['type'], WindowMessageHandler<TMessage>>\n}\n\n/**\n * @internal\n */\nexport interface WindowConnection<TMessage extends WindowMessage> {\n sendMessage: <TType extends TMessage['type']>(\n type: TType,\n data?: Extract<TMessage, {type: TType}>['data'],\n ) => void\n status: Status\n}\n\n/**\n * @internal\n */\nexport function useWindowConnection<\n TWindowMessage extends WindowMessage,\n TFrameMessage extends FrameMessage,\n>(options: UseWindowConnectionOptions<TFrameMessage>): WindowConnection<TWindowMessage> {\n const {name, onMessage, connectTo} = options\n const instance = useSanityInstance()\n const [status, setStatus] = useState<Status>('idle')\n\n const node = useMemo(\n () => getOrCreateNode(instance, {name, connectTo}),\n [instance, name, connectTo],\n )\n\n useEffect(() => {\n const unsubscribe = node.onStatus((newStatus) => {\n setStatus(newStatus)\n })\n\n return unsubscribe\n }, [node, instance, name])\n\n useEffect(() => {\n if (!onMessage) return\n\n const unsubscribers: Array<() => void> = []\n\n Object.entries(onMessage).forEach(([type, handler]) => {\n const unsubscribe = node.on(type, handler as WindowMessageHandler<TFrameMessage>)\n unsubscribers.push(unsubscribe)\n })\n\n return () => {\n unsubscribers.forEach((unsub) => unsub())\n }\n }, [node, onMessage])\n\n const sendMessage = useCallback(\n <TType extends WindowMessage['type']>(\n type: TType,\n data?: Extract<WindowMessage, {type: TType}>['data'],\n ) => {\n node?.post(type, data)\n },\n [node],\n )\n\n // cleanup node on unmount\n useEffect(() => {\n return () => {\n releaseNode(instance, name)\n }\n }, [instance, name])\n\n return {\n sendMessage,\n status,\n }\n}\n","import {type Events, SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {type DocumentHandle, type FrameMessage} from '@sanity/sdk'\nimport {useCallback, useState} from 'react'\n\nimport {useWindowConnection} from './useWindowConnection'\n\n// should we import this whole type from the message protocol?\n\ninterface ManageFavorite {\n favorite: () => void\n unfavorite: () => void\n isFavorited: boolean\n isConnected: boolean\n}\n\n/**\n * @beta\n *\n * ## useManageFavorite\n * This hook provides functionality to add and remove documents from favorites,\n * and tracks the current favorite status of the document.\n * @category Core UI Communication\n * @param documentHandle - The document handle containing document ID and type, like `{_id: '123', _type: 'book'}`\n * @returns An object containing:\n * - `favorite` - Function to add document to favorites\n * - `unfavorite` - Function to remove document from favorites\n * - `isFavorited` - Boolean indicating if document is currently favorited\n * - `isConnected` - Boolean indicating if connection to Core UI is established\n *\n * @example\n * ```tsx\n * function MyDocumentAction(props: DocumentActionProps) {\n * const {_id, _type} = props\n * const {favorite, unfavorite, isFavorited, isConnected} = useManageFavorite({\n * _id,\n * _type\n * })\n *\n * return (\n * <Button\n * disabled={!isConnected}\n * onClick={() => isFavorited ? unfavorite() : favorite()}\n * text={isFavorited ? 'Remove from favorites' : 'Add to favorites'}\n * />\n * )\n * }\n * ```\n */\nexport function useManageFavorite({_id, _type}: DocumentHandle): ManageFavorite {\n const [isFavorited, setIsFavorited] = useState(false) // should load this from a comlink fetch\n const {sendMessage, status} = useWindowConnection<Events.FavoriteMessage, FrameMessage>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n })\n\n const handleFavoriteAction = useCallback(\n (action: 'added' | 'removed', setFavoriteState: boolean) => {\n if (!_id || !_type) return\n\n try {\n const message: Events.FavoriteMessage = {\n type: 'core/v1/events/favorite',\n data: {\n eventType: action,\n documentId: _id,\n documentType: _type,\n },\n }\n\n sendMessage(message.type, message.data)\n setIsFavorited(setFavoriteState)\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Failed to update favorite status')\n // eslint-disable-next-line no-console\n console.error(\n `Failed to ${action === 'added' ? 'favorite' : 'unfavorite'} document:`,\n error,\n )\n throw error\n }\n },\n [_id, _type, sendMessage],\n )\n\n const favorite = useCallback(() => handleFavoriteAction('added', true), [handleFavoriteAction])\n\n const unfavorite = useCallback(\n () => handleFavoriteAction('removed', false),\n [handleFavoriteAction],\n )\n\n return {\n favorite,\n unfavorite,\n isFavorited,\n isConnected: status === 'connected',\n }\n}\n","import {type Events, SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {type DocumentHandle, type FrameMessage} from '@sanity/sdk'\nimport {useCallback} from 'react'\n\nimport {useWindowConnection} from './useWindowConnection'\n\ninterface DocumentInteractionHistory {\n recordEvent: (eventType: 'viewed' | 'edited' | 'created' | 'deleted') => void\n isConnected: boolean\n}\n\n/**\n * @public\n * Hook for managing document interaction history in Sanity Studio.\n * This hook provides functionality to record document interactions.\n * @param documentHandle - The document handle containing document ID and type, like `{_id: '123', _type: 'book'}`\n * @returns An object containing:\n * - `recordEvent` - Function to record document interactions\n * - `isConnected` - Boolean indicating if connection to Studio is established\n *\n * @example\n * ```tsx\n * function MyDocumentAction(props: DocumentActionProps) {\n * const {_id, _type} = props\n * const {recordEvent, isConnected} = useRecordDocumentHistoryEvent({\n * _id,\n * _type\n * })\n *\n * return (\n * <Button\n * disabled={!isConnected}\n * onClick={() => recordEvent('viewed')}\n * text={'Viewed'}\n * />\n * )\n * }\n * ```\n */\nexport function useRecordDocumentHistoryEvent({\n _id,\n _type,\n}: DocumentHandle): DocumentInteractionHistory {\n const {sendMessage, status} = useWindowConnection<Events.HistoryMessage, FrameMessage>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n })\n\n const recordEvent = useCallback(\n (eventType: 'viewed' | 'edited' | 'created' | 'deleted') => {\n try {\n const message: Events.HistoryMessage = {\n type: 'core/v1/events/history',\n data: {\n eventType,\n documentId: _id,\n documentType: _type,\n },\n }\n\n sendMessage(message.type, message.data)\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to record history event:', error)\n throw error\n }\n },\n [_id, _type, sendMessage],\n )\n\n return {\n recordEvent,\n isConnected: status === 'connected',\n }\n}\n","import {type DatasetsResponse} from '@sanity/client'\nimport {getDatasetsState, resolveDatasets, type SanityInstance, type StateSource} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\ntype UseDatasets = {\n /**\n *\n * Returns metadata for each dataset in your organization.\n *\n * @category Datasets\n * @returns The metadata for your organization's datasets\n *\n * @example\n * ```tsx\n * const datasets = useDatasets()\n *\n * return (\n * <select>\n * {datasets.map((dataset) => (\n * <option key={dataset.name}>{dataset.name}</option>\n * ))}\n * </select>\n * )\n * ```\n *\n */\n (): DatasetsResponse\n}\n\n/** @public */\nexport const useDatasets: UseDatasets = createStateSourceHook({\n // remove `undefined` since we're suspending when that is the case\n getState: getDatasetsState as (instance: SanityInstance) => StateSource<DatasetsResponse>,\n shouldSuspend: (instance) => getDatasetsState(instance).getCurrent() === undefined,\n suspender: resolveDatasets,\n})\n","import {\n type ActionsResult,\n applyActions,\n type ApplyActionsOptions,\n type DocumentAction,\n type ResourceId,\n} from '@sanity/sdk'\nimport {type SanityDocument} from '@sanity/types'\n\nimport {createCallbackHook} from '../helpers/createCallbackHook'\n\n/**\n *\n * @beta\n *\n * Provides a callback for applying one or more actions to a document.\n *\n * @category Documents\n * @param resourceId - The resource ID of the document to apply actions to. If not provided, the document will use the default resource.\n * @returns A function that takes one more more {@link DocumentAction}s and returns a promise that resolves to an {@link ActionsResult}.\n * @example Publish or unpublish a document\n * ```\n * import { publishDocument, unpublishDocument } from '@sanity/sdk'\n * import { useApplyActions } from '@sanity/sdk-react'\n *\n * const apply = useApplyActions()\n * const myDocument = { _id: 'my-document-id', _type: 'my-document-type' }\n *\n * return (\n * <button onClick={() => apply(publishDocument(myDocument))}>Publish</button>\n * <button onClick={() => apply(unpublishDocument(myDocument))}>Unpublish</button>\n * )\n * ```\n *\n * @example Create and publish a new document\n * ```\n * import { createDocument, publishDocument } from '@sanity/sdk'\n * import { useApplyActions } from '@sanity/sdk-react'\n *\n * const apply = useApplyActions()\n *\n * const handleCreateAndPublish = () => {\n * const handle = { _id: window.crypto.randomUUID(), _type: 'my-document-type' }\n * apply([\n * createDocument(handle),\n * publishDocument(handle),\n * ])\n * }\n *\n * return (\n * <button onClick={handleCreateAndPublish}>\n * I’m feeling lucky\n * </button>\n * )\n * ```\n */\nexport function useApplyActions(\n resourceId?: ResourceId,\n): <TDocument extends SanityDocument>(\n action: DocumentAction<TDocument> | DocumentAction<TDocument>[],\n options?: ApplyActionsOptions,\n) => Promise<ActionsResult<TDocument>>\n\n/** @beta */\nexport function useApplyActions(\n resourceId?: ResourceId,\n): (\n action: DocumentAction | DocumentAction[],\n options?: ApplyActionsOptions,\n) => Promise<ActionsResult> {\n return _useApplyActions(resourceId)()\n}\n\nconst _useApplyActions = (resourceId?: ResourceId) => createCallbackHook(applyActions, resourceId)\n","import {\n type DocumentHandle,\n getDocumentState,\n getResourceId,\n type JsonMatch,\n type JsonMatchPath,\n resolveDocument,\n} from '@sanity/sdk'\nimport {type SanityDocument} from '@sanity/types'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * @beta\n *\n * ## useDocument(doc, path)\n * Read and subscribe to nested values in a document\n * @category Documents\n * @param doc - The document to read state from. If you pass a `DocumentHandle` with a `resourceId` in the DocumentResourceId format (`document:projectId.dataset:documentId`)\n * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.\n * @param path - The path to the nested value to read from\n * @returns The value at the specified path\n * @example\n * ```tsx\n * import {type DocumentHandle, useDocument} from '@sanity/sdk-react'\n *\n * function OrderLink({documentHandle}: {documentHandle: DocumentHandle}) {\n * const title = useDocument(documentHandle, 'title')\n * const id = useDocument(documentHandle, '_id')\n *\n * return (\n * <a href=`/order/${id}`>Order {title} today!</a>\n * )\n * }\n * ```\n *\n */\nexport function useDocument<\n TDocument extends SanityDocument,\n TPath extends JsonMatchPath<TDocument>,\n>(doc: DocumentHandle<TDocument>, path: TPath): JsonMatch<TDocument, TPath> | undefined\n\n/**\n * @beta\n * ## useDocument(doc)\n * Read and subscribe to an entire document\n * @param doc - The document to read state from\n * @returns The document state as an object\n * @example\n * ```tsx\n * import {type SanityDocument, type DocumentHandle, useDocument} from '@sanity/sdk-react'\n *\n * interface Book extends SanityDocument {\n * title: string\n * author: string\n * summary: string\n * }\n *\n * function DocumentView({documentHandle}: {documentHandle: DocumentHandle}) {\n * const book = useDocument<Book>(documentHandle)\n *\n * return (\n * <article>\n * <h1>{book?.title}</h1>\n * <address>By {book?.author}</address>\n *\n * <h2>Summary</h2>\n * {book?.summary}\n *\n * <h2>Order</h2>\n * <a href=`/order/${book._id}`>Order {book?.title} today!</a>\n * </article>\n * )\n * }\n * ```\n *\n */\nexport function useDocument<TDocument extends SanityDocument>(\n doc: DocumentHandle<TDocument>,\n): TDocument | null\n\n/**\n * @beta\n * Reads and subscribes to a document’s realtime state, incorporating both local and remote changes.\n * When called with a `path` argument, the hook will return the nested value’s state.\n * When called without a `path` argument, the entire document’s state will be returned.\n *\n * @remarks\n * `useDocument` is designed to be used within a realtime context in which local updates to documents\n * need to be displayed before they are persisted to the remote copy. This can be useful within a collaborative\n * or realtime editing interface where local changes need to be reflected immediately.\n *\n * However, this hook can be too resource intensive for applications where static document values simply\n * need to be displayed (or when changes to documents don’t need to be reflected immediately);\n * consider using `usePreview` or `useQuery` for these use cases instead. These hooks leverage the Sanity\n * Live Content API to provide a more efficient way to read and subscribe to document state.\n */\nexport function useDocument(doc: DocumentHandle, path?: string): unknown {\n return _useDocument(doc, path)\n}\n\nconst _useDocument = createStateSourceHook<[doc: DocumentHandle, path?: string], unknown>({\n getState: getDocumentState,\n shouldSuspend: (instance, doc) => getDocumentState(instance, doc._id).getCurrent() === undefined,\n suspender: resolveDocument,\n getResourceId: (doc) => getResourceId(doc.resourceId),\n})\n","import {\n type DocumentEvent,\n type DocumentHandle,\n getResourceId,\n subscribeDocumentEvents,\n} from '@sanity/sdk'\nimport {useCallback, useEffect, useInsertionEffect, useRef} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n *\n * @beta\n *\n * Subscribes an event handler to events in your application’s document store, such as document\n * creation, deletion, and updates.\n *\n * @category Documents\n * @param handler - The event handler to register.\n * @param doc - The document to subscribe to events for. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)\n * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.\n * @example\n * ```\n * import {useDocumentEvent} from '@sanity/sdk-react'\n * import {type DocumentEvent} from '@sanity/sdk'\n *\n * useDocumentEvent((event) => {\n * if (event.type === DocumentEvent.DocumentDeletedEvent) {\n * alert(`Document with ID ${event.documentId} deleted!`)\n * } else {\n * console.log(event)\n * }\n * })\n * ```\n */\nexport function useDocumentEvent(\n handler: (documentEvent: DocumentEvent) => void,\n doc: DocumentHandle,\n): void {\n const ref = useRef(handler)\n\n useInsertionEffect(() => {\n ref.current = handler\n })\n\n const stableHandler = useCallback((documentEvent: DocumentEvent) => {\n return ref.current(documentEvent)\n }, [])\n\n const instance = useSanityInstance(getResourceId(doc.resourceId))\n useEffect(() => {\n return subscribeDocumentEvents(instance, stableHandler)\n }, [instance, stableHandler])\n}\n","import {type DocumentHandle, getDocumentSyncStatus} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\ntype UseDocumentSyncStatus = {\n /**\n * Exposes the document’s sync status between local and remote document states.\n *\n * @category Documents\n * @param doc - The document handle to get sync status for. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)\n * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.\n * @returns `true` if local changes are synced with remote, `false` if the changes are not synced, and `undefined` if the document is not found\n * @example Disable a Save button when there are no changes to sync\n * ```\n * const myDocumentHandle = { _id: 'documentId', _type: 'documentType', resourceId: 'document:projectId:dataset:documentId' }\n * const documentSynced = useDocumentSyncStatus(myDocumentHandle)\n *\n * return (\n * <button disabled={documentSynced}>\n * Save Changes\n * </button>\n * )\n * ```\n */\n (doc: DocumentHandle): boolean | undefined\n}\n\n/** @beta */\nexport const useDocumentSyncStatus: UseDocumentSyncStatus =\n createStateSourceHook(getDocumentSyncStatus)\n","import {\n type ActionsResult,\n type DocumentHandle,\n editDocument,\n getDocumentState,\n getResourceId,\n type JsonMatch,\n type JsonMatchPath,\n resolveDocument,\n} from '@sanity/sdk'\nimport {type SanityDocument} from '@sanity/types'\nimport {useCallback} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\nimport {useApplyActions} from './useApplyActions'\n\nconst ignoredKeys = ['_id', '_type', '_createdAt', '_updatedAt', '_rev']\n\ntype Updater<TValue> = TValue | ((nextValue: TValue) => TValue)\n\n/**\n *\n * @beta\n *\n * ## useEditDocument(doc, path)\n * Edit a nested value within a document\n *\n * @category Documents\n * @param doc - The document to be edited; either as a document handle or the document’s ID a string\n * @param path - The path to the nested value to be edited\n * @returns A function to update the nested value. Accepts either a new value, or an updater function that exposes the previous value and returns a new value.\n * @example Update a document’s name by providing the new value directly\n * ```\n * const handle = { _id: 'documentId', _type: 'documentType' }\n * const name = useDocument(handle, 'name')\n * const editName = useEditDocument(handle, 'name')\n *\n * function handleNameChange(event: React.ChangeEvent<HTMLInputElement>) {\n * editName(event.target.value)\n * }\n *\n * return (\n * <input type='text' value={name} onChange={handleNameChange} />\n * )\n * ```\n *\n * @example Update a count on a document by providing an updater function\n * ```\n * const handle = { _id: 'documentId', _type: 'documentType' }\n * const count = useDocument(handle, 'count')\n * const editCount = useEditDocument(handle, 'count')\n *\n * function incrementCount() {\n * editCount(previousCount => previousCount + 1)\n * }\n *\n * return (\n * <>\n * <button onClick={incrementCount}>\n * Increment\n * </button>\n * Current count: {count}\n * </>\n * )\n * ```\n */\nexport function useEditDocument<\n TDocument extends SanityDocument,\n TPath extends JsonMatchPath<TDocument>,\n>(\n doc: DocumentHandle<TDocument>,\n path: TPath,\n): (nextValue: Updater<JsonMatch<TDocument, TPath>>) => Promise<ActionsResult<TDocument>>\n\n/**\n *\n * @beta\n *\n * ## useEditDocument(doc)\n * Edit an entire document\n * @param doc - The document to be edited; either as a document handle or the document’s ID a string. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)\n * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.\n * @returns A function to update the document state. Accepts either a new document state, or an updater function that exposes the previous document state and returns the new document state.\n * @example\n * ```\n * const myDocumentHandle = { _id: 'documentId', _type: 'documentType' }\n *\n * const myDocument = useDocument(myDocumentHandle)\n * const { title, price } = myDocument\n *\n * const editMyDocument = useEditDocument(myDocumentHandle)\n *\n * function handleFieldChange(e: React.ChangeEvent<HTMLInputElement>) {\n * const {name, value} = e.currentTarget\n * // Use an updater function to update the document state based on the previous state\n * editMyDocument(previousDocument => ({\n * ...previousDocument,\n * [name]: value\n * }))\n * }\n *\n * function handleSaleChange(e: React.ChangeEvent<HTMLInputElement>) {\n * const { checked } = e.currentTarget\n * if (checked) {\n * // Use an updater function to add a new salePrice field;\n * // set it at a 20% discount off the normal price\n * editMyDocument(previousDocument => ({\n * ...previousDocument,\n * salePrice: previousDocument.price * 0.8,\n * }))\n * } else {\n * // Get the document state without the salePrice field\n * const { salePrice, ...rest } = myDocument\n * // Update the document state to remove the salePrice field\n * editMyDocument(rest)\n * }\n * }\n *\n * return (\n * <>\n * <form onSubmit={e => e.preventDefault()}>\n * <input name='title' type='text' value={title} onChange={handleFieldChange} />\n * <input name='price' type='number' value={price} onChange={handleFieldChange} />\n * <input\n * name='salePrice'\n * type='checkbox'\n * checked={Object(myDocument).hasOwnProperty('salePrice')}\n * onChange={handleSaleChange}\n * />\n * </form>\n * <pre><code>\n * {JSON.stringify(myDocument, null, 2)}\n * </code></pre>\n * </>\n * )\n * ```\n */\nexport function useEditDocument<TDocument extends SanityDocument>(\n doc: DocumentHandle<TDocument>,\n): (nextValue: Updater<TDocument>) => Promise<ActionsResult<TDocument>>\n\n/**\n *\n * @beta\n *\n * Enables editing of a document’s state.\n * When called with a `path` argument, the hook will return a function for updating a nested value.\n * When called without a `path` argument, the hook will return a function for updating the entire document.\n */\nexport function useEditDocument(\n doc: DocumentHandle,\n path?: string,\n): (updater: Updater<unknown>) => Promise<ActionsResult> {\n const resourceId = getResourceId(doc.resourceId)!\n const documentId = doc._id\n const instance = useSanityInstance(resourceId)\n const apply = useApplyActions(resourceId)\n const isDocumentReady = useCallback(\n () => getDocumentState(instance, documentId).getCurrent() !== undefined,\n [instance, documentId],\n )\n if (!isDocumentReady()) throw resolveDocument(instance, documentId)\n\n return (updater: Updater<unknown>) => {\n if (path) {\n const nextValue =\n typeof updater === 'function'\n ? updater(getDocumentState(instance, documentId, path).getCurrent())\n : updater\n\n return apply(editDocument(doc, {set: {[path]: nextValue}}))\n }\n\n const current = getDocumentState(instance, documentId).getCurrent()\n const nextValue = typeof updater === 'function' ? updater(current) : updater\n\n if (typeof nextValue !== 'object' || !nextValue) {\n throw new Error(\n `No path was provided to \\`useEditDocument\\` and the value provided was not a document object.`,\n )\n }\n\n const allKeys = Object.keys({...current, ...nextValue})\n const editActions = allKeys\n .filter((key) => !ignoredKeys.includes(key))\n .filter((key) => current?.[key] !== nextValue[key])\n .map((key) =>\n key in nextValue\n ? editDocument(doc, {set: {[key]: nextValue[key]}})\n : editDocument(doc, {unset: [key]}),\n )\n\n return apply(editActions)\n }\n}\n","import {\n type DocumentAction,\n getPermissionsState,\n getResourceId,\n type PermissionsResult,\n} from '@sanity/sdk'\nimport {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {filter, firstValueFrom} from 'rxjs'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n *\n * @beta\n *\n * Check if the current user has the specified permissions for the given document actions.\n *\n * @category Permissions\n * @param actions - One more more calls to a particular document action function for a given document\n * @returns An object that specifies whether the action is allowed; if the action is not allowed, an explanatory message and list of reasons is also provided.\n *\n * @example Checking for permission to publish a document\n * ```ts\n * import {usePermissions, useApplyActions} from '@sanity/sdk-react'\n * import {publishDocument} from '@sanity/sdk'\n *\n * export function PublishButton({doc}: {doc: DocumentHandle}) {\n * const canPublish = usePermissions(publishDocument(doc))\n * const applyAction = useApplyActions()\n *\n * return (\n * <>\n * <button\n * disabled={!canPublish.allowed}\n * onClick={() => applyAction(publishDocument(doc))}\n * popoverTarget={`${canPublish.allowed ? undefined : 'publishButtonPopover'}`}\n * >\n * Publish\n * </button>\n * {!canPublish.allowed && (\n * <div popover id=\"publishButtonPopover\">\n * {canPublish.message}\n * </div>\n * )}\n * </>\n * )\n * }\n * ```\n */\nexport function usePermissions(actions: DocumentAction | DocumentAction[]): PermissionsResult {\n // if actions is an array, we need to check each action to see if the resourceId is the same\n if (Array.isArray(actions)) {\n const resourceIds = actions.map((action) => action.resourceId)\n const uniqueResourceIds = new Set(resourceIds)\n if (uniqueResourceIds.size !== 1) {\n throw new Error('All actions must have the same resourceId')\n }\n }\n const resourceId = Array.isArray(actions)\n ? getResourceId(actions[0].resourceId)\n : getResourceId(actions.resourceId)\n\n const instance = useSanityInstance(resourceId)\n const isDocumentReady = useCallback(\n () => getPermissionsState(instance, actions).getCurrent() !== undefined,\n [actions, instance],\n )\n if (!isDocumentReady()) {\n throw firstValueFrom(\n getPermissionsState(instance, actions).observable.pipe(\n filter((result) => result !== undefined),\n ),\n )\n }\n\n const {subscribe, getCurrent} = useMemo(\n () => getPermissionsState(instance, actions),\n [actions, instance],\n )\n\n return useSyncExternalStore(subscribe, getCurrent) as PermissionsResult\n}\n","import {\n getQueryKey,\n getQueryState,\n parseQueryKey,\n type QueryOptions,\n resolveQuery,\n} from '@sanity/sdk'\nimport {useEffect, useMemo, useState, useSyncExternalStore, useTransition} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * Executes GROQ queries against a Sanity dataset.\n *\n * This hook provides a convenient way to fetch and subscribe to real-time updates\n * for your Sanity content. Changes made to the dataset’s content will trigger\n * automatic updates.\n *\n * @remarks\n * The returned `isPending` flag indicates when a React transition is in progress,\n * which can be used to show loading states for query changes.\n *\n * @beta\n * @category GROQ\n * @param query - GROQ query string to execute\n * @param options - Optional configuration for the query\n * @returns Object containing the query result and a pending state flag\n *\n * @example Basic usage\n * ```tsx\n * const {data, isPending} = useQuery<Movie[]>('*[_type == \"movie\"]')\n * ```\n *\n * @example Using parameters\n * ```tsx\n * // With parameters\n * const {data} = useQuery<Movie>('*[_type == \"movie\" && _id == $id][0]', {\n * params: { id: 'movie-123' }\n * })\n * ```\n *\n * @example With a loading state for transitions\n * ```tsx\n * const {data, isPending} = useQuery<Movie[]>('*[_type == \"movie\"]')\n * return (\n * <div>\n * {isPending && <div>Updating...</div>}\n * <ul>\n * {data.map(movie => <li key={movie._id}>{movie.title}</li>)}\n * </ul>\n * </div>\n * )\n * ```\n *\n */\nexport function useQuery<T>(query: string, options?: QueryOptions): {data: T; isPending: boolean} {\n const instance = useSanityInstance(options?.resourceId)\n // Use React's useTransition to avoid UI jank when queries change\n const [isPending, startTransition] = useTransition()\n\n // Get the unique key for this query and its options\n const queryKey = getQueryKey(query, options)\n // Use a deferred state to avoid immediate re-renders when the query changes\n const [deferredQueryKey, setDeferredQueryKey] = useState(queryKey)\n // Parse the deferred query key back into a query and options\n const deferred = useMemo(() => parseQueryKey(deferredQueryKey), [deferredQueryKey])\n\n // Create an AbortController to cancel in-flight requests when needed\n const [ref, setRef] = useState<AbortController>(new AbortController())\n\n // When the query or options change, start a transition to update the query\n useEffect(() => {\n if (queryKey === deferredQueryKey) return\n\n startTransition(() => {\n // Abort any in-flight requests for the previous query\n if (ref && !ref.signal.aborted) {\n ref.abort()\n setRef(new AbortController())\n }\n\n setDeferredQueryKey(queryKey)\n })\n }, [deferredQueryKey, queryKey, ref])\n\n // Get the state source for this query from the query store\n const {getCurrent, subscribe} = useMemo(\n () => getQueryState(instance, deferred.query, deferred.options),\n [instance, deferred],\n )\n\n // If data isn't available yet, suspend rendering until it is\n // This is the React Suspense integration - throwing a promise\n // will cause React to show the nearest Suspense fallback\n if (getCurrent() === undefined) {\n throw resolveQuery(instance, deferred.query, {...deferred.options, signal: ref.signal})\n }\n\n // Subscribe to updates and get the current data\n // useSyncExternalStore ensures the component re-renders when the data changes\n const data = useSyncExternalStore(subscribe, getCurrent) as T\n return {data, isPending}\n}\n","import {type DocumentHandle, type QueryOptions} from '@sanity/sdk'\nimport {type SortOrderingItem} from '@sanity/types'\nimport {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {useQuery} from '../query/useQuery'\n\nconst DEFAULT_BATCH_SIZE = 25\nconst DEFAULT_PERSPECTIVE = 'drafts'\n\n/**\n * Result structure returned from the infinite list query\n * @internal\n */\ninterface InfiniteListQueryResult {\n count: number\n data: DocumentHandle[]\n}\n\n/**\n * Configuration options for the useInfiniteList hook\n *\n * @beta\n * @category Types\n */\nexport interface InfiniteListOptions extends QueryOptions {\n /**\n * GROQ filter expression to apply to the query\n */\n filter?: string\n /**\n * Number of items to load per batch (defaults to 25)\n */\n batchSize?: number\n /**\n * Sorting configuration for the results\n */\n orderings?: SortOrderingItem[]\n /**\n * Text search query to filter results\n */\n search?: string\n}\n\n/**\n * Return value from the useInfiniteList hook\n *\n * @beta\n * @category Types\n */\nexport interface InfiniteList {\n /**\n * Array of document handles for the current batch\n */\n data: DocumentHandle[]\n /**\n * Whether there are more items available to load\n */\n hasMore: boolean\n /**\n * Total count of items matching the query\n */\n count: number\n /**\n * Whether a query is currently in progress\n */\n isPending: boolean\n /**\n * Function to load the next batch of results\n */\n loadMore: () => void\n}\n\n/**\n * Retrieves batches of {@link DocumentHandle}s, narrowed by optional filters, text searches, and custom ordering,\n * with infinite scrolling support. The number of document handles returned per batch is customizable,\n * and additional batches can be loaded using the supplied `loadMore` function.\n *\n * @beta\n * @category Documents\n * @param options - Configuration options for the infinite list\n * @returns An object containing the list of document handles, the loading state, the total count of retrived document handles, and a function to load more\n * @example\n * ```tsx\n * const {data, hasMore, isPending, loadMore} = useInfiniteList({\n * filter: '_type == \"post\"',\n * search: searchTerm,\n * batchSize: 10,\n * orderings: [{field: '_createdAt', direction: 'desc'}]\n * })\n *\n * return (\n * <div>\n * Total documents: {count}\n * <ol>\n * {data.map((doc) => (\n * <li key={doc._id}>\n * <MyDocumentComponent doc={doc} />\n * </li>\n * ))}\n * </ol>\n * {hasMore && <button onClick={loadMore}>Load More</button>}\n * </div>\n * )\n * ```\n *\n */\nexport function useInfiniteList({\n batchSize = DEFAULT_BATCH_SIZE,\n params,\n search,\n filter,\n orderings,\n ...options\n}: InfiniteListOptions): InfiniteList {\n const perspective = options.perspective ?? DEFAULT_PERSPECTIVE\n const [limit, setLimit] = useState(batchSize)\n\n // Reset the limit to the current batchSize whenever any query parameters\n // (filter, search, params, orderings) or batchSize changes\n const key = JSON.stringify({filter, search, params, orderings, batchSize})\n useEffect(() => {\n setLimit(batchSize)\n }, [key, batchSize])\n\n const filterClause = useMemo(() => {\n const conditions: string[] = []\n\n // Add search query if specified\n if (search?.trim()) {\n conditions.push(`[@] match text::query(\"${search.trim()}\")`)\n }\n\n // Add additional filter if specified\n if (filter) {\n conditions.push(`(${filter})`)\n }\n\n return conditions.length ? `[${conditions.join(' && ')}]` : ''\n }, [filter, search])\n\n const orderClause = orderings\n ? `| order(${orderings\n .map((ordering) =>\n [ordering.field, ordering.direction.toLowerCase()]\n .map((str) => str.trim())\n .filter(Boolean)\n .join(' '),\n )\n .join(',')})`\n : ''\n\n const dataQuery = `*${filterClause}${orderClause}[0...${limit}]{_id,_type}`\n const countQuery = `count(*${filterClause})`\n\n const {\n data: {count, data},\n isPending,\n } = useQuery<InfiniteListQueryResult>(`{\"count\":${countQuery},\"data\":${dataQuery}}`, {\n ...options,\n params,\n perspective,\n })\n\n const hasMore = data.length < count\n\n const loadMore = useCallback(() => {\n setLimit((prev) => Math.min(prev + batchSize, count))\n }, [count, batchSize])\n\n return useMemo(\n () => ({data, hasMore, count, isPending, loadMore}),\n [data, hasMore, count, isPending, loadMore],\n )\n}\n","import {type DocumentHandle, type QueryOptions} from '@sanity/sdk'\nimport {type SortOrderingItem} from '@sanity/types'\nimport {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {useQuery} from '../query/useQuery'\n\nconst DEFAULT_PERSPECTIVE = 'drafts'\n\n/**\n * Configuration options for the usePaginatedList hook\n *\n * @beta\n * @category Types\n */\nexport interface PaginatedListOptions extends QueryOptions {\n /**\n * GROQ filter expression to apply to the query\n */\n filter?: string\n /**\n * Number of items to display per page (defaults to 25)\n */\n pageSize?: number\n /**\n * Sorting configuration for the results\n */\n orderings?: SortOrderingItem[]\n /**\n * Text search query to filter results\n */\n search?: string\n}\n\n/**\n * Return value from the usePaginatedList hook\n *\n * @beta\n * @category Types\n */\nexport interface PaginatedList {\n /**\n * Array of document handles for the current page\n */\n data: DocumentHandle[]\n /**\n * Whether a query is currently in progress\n */\n isPending: boolean\n\n /**\n * Number of items displayed per page\n */\n pageSize: number\n /**\n * Current page number (1-indexed)\n */\n currentPage: number\n /**\n * Total number of pages available\n */\n totalPages: number\n\n /**\n * Starting index of the current page (0-indexed)\n */\n startIndex: number\n /**\n * Ending index of the current page (exclusive, 0-indexed)\n */\n endIndex: number\n /**\n * Total count of items matching the query\n */\n count: number\n\n /**\n * Navigate to the first page\n */\n firstPage: () => void\n /**\n * Whether there is a first page available to navigate to\n */\n hasFirstPage: boolean\n\n /**\n * Navigate to the previous page\n */\n previousPage: () => void\n /**\n * Whether there is a previous page available to navigate to\n */\n hasPreviousPage: boolean\n\n /**\n * Navigate to the next page\n */\n nextPage: () => void\n /**\n * Whether there is a next page available to navigate to\n */\n hasNextPage: boolean\n\n /**\n * Navigate to the last page\n */\n lastPage: () => void\n /**\n * Whether there is a last page available to navigate to\n */\n hasLastPage: boolean\n\n /**\n * Navigate to a specific page number\n * @param pageNumber - The page number to navigate to (1-indexed)\n */\n goToPage: (pageNumber: number) => void\n}\n\n/**\n * Retrieves pages of {@link DocumentHandle}s, narrowed by optional filters, text searches, and custom ordering,\n * with support for traditional paginated interfaces. The number of document handles returned per page is customizable,\n * while page navigation is handled via the included navigation functions.\n *\n * @beta\n * @category Documents\n * @param options - Configuration options for the paginated list\n * @returns An object containing the current page of document handles, the loading and pagination state, and navigation functions\n * @example\n * ```tsx\n * const {\n * data,\n * isPending,\n * currentPage,\n * totalPages,\n * nextPage,\n * previousPage,\n * hasNextPage,\n * hasPreviousPage\n * } = usePaginatedList({\n * filter: '_type == \"post\"',\n * search: searchTerm,\n * pageSize: 10,\n * orderings: [{field: '_createdAt', direction: 'desc'}]\n * })\n *\n * return (\n * <>\n * <table>\n * {data.map(doc => (\n * <MyTableRowComponent key={doc._id} doc={doc} />\n * ))}\n * </table>\n * <>\n * {hasPreviousPage && <button onClick={previousPage}>Previous</button>}\n * {currentPage} / {totalPages}\n * {hasNextPage && <button onClick={nextPage}>Next</button>}\n * </>\n * </>\n * )\n * ```\n *\n */\nexport function usePaginatedList({\n filter = '',\n pageSize = 25,\n params = {},\n orderings,\n search,\n ...options\n}: PaginatedListOptions = {}): PaginatedList {\n const [pageIndex, setPageIndex] = useState(0)\n const key = JSON.stringify({filter, search, params, orderings, pageSize})\n // Reset the pageIndex to 0 whenever any query parameters (filter, search,\n // params, orderings) or pageSize changes\n useEffect(() => {\n setPageIndex(0)\n }, [key])\n\n const startIndex = pageIndex * pageSize\n const endIndex = (pageIndex + 1) * pageSize\n const perspective = options.perspective ?? DEFAULT_PERSPECTIVE\n\n const filterClause = useMemo(() => {\n const conditions: string[] = []\n\n // Add search query if specified\n if (search?.trim()) {\n conditions.push(`[@] match text::query(\"${search.trim()}\")`)\n }\n\n // Add additional filter if specified\n if (filter) {\n conditions.push(`(${filter})`)\n }\n\n return conditions.length ? `[${conditions.join(' && ')}]` : ''\n }, [filter, search])\n\n const orderClause = orderings\n ? `| order(${orderings\n .map((ordering) =>\n [ordering.field, ordering.direction.toLowerCase()]\n .map((str) => str.trim())\n .filter(Boolean)\n .join(' '),\n )\n .join(',')})`\n : ''\n\n const dataQuery = `*${filterClause}${orderClause}[${startIndex}...${endIndex}]{_id,_type}`\n const countQuery = `count(*${filterClause})`\n\n const {\n data: {data, count},\n isPending,\n } = useQuery<{data: DocumentHandle[]; count: number}>(\n `{\"data\":${dataQuery},\"count\":${countQuery}}`,\n {\n ...options,\n perspective,\n params,\n },\n )\n\n const totalPages = Math.ceil(count / pageSize)\n const currentPage = pageIndex + 1\n\n // Navigation methods\n const firstPage = useCallback(() => setPageIndex(0), [])\n const previousPage = useCallback(() => setPageIndex((prev) => Math.max(prev - 1, 0)), [])\n const nextPage = useCallback(\n () => setPageIndex((prev) => Math.min(prev + 1, totalPages - 1)),\n [totalPages],\n )\n const lastPage = useCallback(() => setPageIndex(totalPages - 1), [totalPages])\n const goToPage = useCallback(\n (pageNumber: number) => {\n if (pageNumber < 1 || pageNumber > totalPages) return\n setPageIndex(pageNumber - 1)\n },\n [totalPages],\n )\n\n // Boolean flags for page availability\n const hasFirstPage = pageIndex > 0\n const hasPreviousPage = pageIndex > 0\n const hasNextPage = pageIndex < totalPages - 1\n const hasLastPage = pageIndex < totalPages - 1\n\n return useMemo(\n () => ({\n data,\n isPending,\n pageSize,\n currentPage,\n totalPages,\n startIndex,\n endIndex,\n count,\n firstPage,\n hasFirstPage,\n previousPage,\n hasPreviousPage,\n nextPage,\n hasNextPage,\n lastPage,\n hasLastPage,\n goToPage,\n }),\n [\n data,\n isPending,\n pageSize,\n currentPage,\n totalPages,\n startIndex,\n endIndex,\n count,\n firstPage,\n hasFirstPage,\n previousPage,\n hasPreviousPage,\n nextPage,\n hasNextPage,\n lastPage,\n hasLastPage,\n goToPage,\n ],\n )\n}\n","import {type DocumentHandle, getPreviewState, type PreviewValue, resolvePreview} from '@sanity/sdk'\nimport {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {distinctUntilChanged, EMPTY, Observable, startWith, switchMap} from 'rxjs'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @beta\n * @category Types\n */\nexport interface UsePreviewOptions {\n document: DocumentHandle\n ref?: React.RefObject<unknown>\n}\n\n/**\n * @beta\n * @category Types\n */\nexport interface UsePreviewResults {\n /** The results of resolving the document’s preview values */\n results: PreviewValue\n /** True when preview values are being refreshed */\n isPending: boolean\n}\n\n/**\n * @beta\n *\n * Returns the preview values of a document (specified via a `DocumentHandle`),\n * including the document’s `title`, `subtitle`, `media`, and `status`. These values are live and will update in realtime.\n * To reduce unnecessary network requests for resolving the preview values, an optional `ref` can be passed to the hook so that preview\n * resolution will only occur if the `ref` is intersecting the current viewport.\n *\n * @category Documents\n * @param options - The document handle for the document you want to resolve preview values for, and an optional ref\n * @returns The preview values for the given document and a boolean to indicate whether the resolution is pending\n *\n * @example Combining with useDocuments to render a collection of document previews\n * ```\n * // PreviewComponent.jsx\n * export default function PreviewComponent({ document }) {\n * const { results: { title, subtitle, media }, isPending } = usePreview({ document })\n * return (\n * <article style={{ opacity: isPending ? 0.5 : 1}}>\n * {media?.type === 'image-asset' ? <img src={media.url} alt='' /> : ''}\n * <h2>{title}</h2>\n * <p>{subtitle}</p>\n * </article>\n * )\n * }\n *\n * // DocumentList.jsx\n * const { results, isPending } = useDocuments({ filter: '_type == \"movie\"' })\n * return (\n * <div>\n * <h1>Movies</h1>\n * <ul>\n * {isPending ? 'Loading…' : results.map(movie => (\n * <li key={movie._id}>\n * <Suspense fallback='Loading…'>\n * <PreviewComponent document={movie} />\n * </Suspense>\n * </li>\n * ))}\n * </ul>\n * </div>\n * )\n * ```\n */\nexport function usePreview({document: {_id, _type}, ref}: UsePreviewOptions): UsePreviewResults {\n const instance = useSanityInstance()\n\n const stateSource = useMemo(\n () => getPreviewState(instance, {document: {_id, _type}}),\n [instance, _id, _type],\n )\n\n // Create subscribe function for useSyncExternalStore\n const subscribe = useCallback(\n (onStoreChanged: () => void) => {\n const subscription = new Observable<boolean>((observer) => {\n // for environments that don't have an intersection observer\n if (typeof IntersectionObserver === 'undefined' || typeof HTMLElement === 'undefined') {\n return\n }\n\n const intersectionObserver = new IntersectionObserver(\n ([entry]) => observer.next(entry.isIntersecting),\n {rootMargin: '0px', threshold: 0},\n )\n if (ref?.current && ref.current instanceof HTMLElement) {\n intersectionObserver.observe(ref.current)\n }\n return () => intersectionObserver.disconnect()\n })\n .pipe(\n startWith(false),\n distinctUntilChanged(),\n switchMap((isVisible) =>\n isVisible\n ? new Observable<void>((obs) => {\n return stateSource.subscribe(() => obs.next())\n })\n : EMPTY,\n ),\n )\n .subscribe({next: onStoreChanged})\n\n return () => subscription.unsubscribe()\n },\n [stateSource, ref],\n )\n\n // Create getSnapshot function to return current state\n const getSnapshot = useCallback(() => {\n const currentState = stateSource.getCurrent()\n if (currentState.results === null) throw resolvePreview(instance, {document: {_id, _type}})\n return currentState as UsePreviewResults\n }, [_id, _type, instance, stateSource])\n\n return useSyncExternalStore(subscribe, getSnapshot)\n}\n","import {\n type DocumentHandle,\n getProjectionState,\n resolveProjection,\n type ValidProjection,\n} from '@sanity/sdk'\nimport {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {distinctUntilChanged, EMPTY, Observable, startWith, switchMap} from 'rxjs'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\ninterface UseProjectionOptions {\n document: DocumentHandle\n projection: ValidProjection\n ref?: React.RefObject<unknown>\n}\n\ninterface UseProjectionResults<TResult extends object> {\n results: TResult\n isPending: boolean\n}\n\n/**\n * @beta\n *\n * Returns the projection values of a document (specified via a `DocumentHandle`),\n * based on the provided projection string. These values are live and will update in realtime.\n * To reduce unnecessary network requests for resolving the projection values, an optional `ref` can be passed to the hook so that projection\n * resolution will only occur if the `ref` is intersecting the current viewport.\n *\n * @category Documents\n * @param options - The document handle for the document you want to project values from, the projection string, and an optional ref\n * @returns The projection values for the given document and a boolean to indicate whether the resolution is pending\n *\n * @example Using a projection to display specific document fields\n * ```\n * // ProjectionComponent.jsx\n * export default function ProjectionComponent({ document }) {\n * const ref = useRef(null)\n * const { results: { title, description, authors }, isPending } = useProjection({\n * document,\n * projection: '{title, \"description\": pt::text(\"description\"), \"authors\": array::join(authors[]->name, \", \")}',\n * ref\n * })\n *\n * return (\n * <article ref={ref} style={{ opacity: isPending ? 0.5 : 1}}>\n * <h2>{title}</h2>\n * <p>{description}</p>\n * <p>{authors}</p>\n * </article>\n * )\n * }\n * ```\n *\n * @example Combining with useInfiniteList to render a collection with specific fields\n * ```\n * // DocumentList.jsx\n * const { data } = useInfiniteList({ filter: '_type == \"article\"' })\n * return (\n * <div>\n * <h1>Articles</h1>\n * <ul>\n * {data.map(article => (\n * <li key={article._id}>\n * <Suspense fallback='Loading…'>\n * <ProjectionComponent\n * document={article}\n * />\n * </Suspense>\n * </li>\n * ))}\n * </ul>\n * </div>\n * )\n * ```\n */\nexport function useProjection<TResult extends object>({\n document: {_id, _type},\n projection,\n ref,\n}: UseProjectionOptions): UseProjectionResults<TResult> {\n const instance = useSanityInstance()\n\n const stateSource = useMemo(\n () => getProjectionState<TResult>(instance, {document: {_id, _type}, projection}),\n [instance, _id, _type, projection],\n )\n\n // Create subscribe function for useSyncExternalStore\n const subscribe = useCallback(\n (onStoreChanged: () => void) => {\n const subscription = new Observable<boolean>((observer) => {\n // for environments that don't have an intersection observer\n if (typeof IntersectionObserver === 'undefined' || typeof HTMLElement === 'undefined') {\n return\n }\n\n const intersectionObserver = new IntersectionObserver(\n ([entry]) => observer.next(entry.isIntersecting),\n {rootMargin: '0px', threshold: 0},\n )\n if (ref?.current && ref.current instanceof HTMLElement) {\n intersectionObserver.observe(ref.current)\n }\n return () => intersectionObserver.disconnect()\n })\n .pipe(\n startWith(false),\n distinctUntilChanged(),\n switchMap((isVisible) =>\n isVisible\n ? new Observable<void>((obs) => {\n return stateSource.subscribe(() => obs.next())\n })\n : EMPTY,\n ),\n )\n .subscribe({next: onStoreChanged})\n\n return () => subscription.unsubscribe()\n },\n [stateSource, ref],\n )\n\n // Create getSnapshot function to return current state\n const getSnapshot = useCallback(() => {\n const currentState = stateSource.getCurrent()\n if (currentState.results === null)\n throw resolveProjection(instance, {document: {_id, _type}, projection})\n return currentState as UseProjectionResults<TResult>\n }, [_id, _type, projection, instance, stateSource])\n\n return useSyncExternalStore(subscribe, getSnapshot)\n}\n","import {\n getProjectState,\n resolveProject,\n type SanityInstance,\n type SanityProject,\n type StateSource,\n} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\ntype UseProject = {\n /**\n *\n * Returns metadata for a given project\n *\n * @category Projects\n * @param projectId - The ID of the project to retrieve metadata for\n * @returns The metadata for the project\n * @example\n * ```tsx\n * function ProjectMetadata({ projectId }: { projectId: string }) {\n * const project = useProject(projectId)\n *\n * return (\n * <figure style={{ backgroundColor: project.metadata.color || 'lavender'}}>\n * <h1>{project.displayName}</h1>\n * </figure>\n * )\n * }\n * ```\n */\n (projectId: string): SanityProject\n}\n\n/** @public */\nexport const useProject: UseProject = createStateSourceHook({\n // remove `undefined` since we're suspending when that is the case\n getState: getProjectState as (\n instance: SanityInstance,\n projectId: string,\n ) => StateSource<SanityProject>,\n shouldSuspend: (instance, projectId) =>\n getProjectState(instance, projectId).getCurrent() === undefined,\n suspender: resolveProject,\n})\n","import {type SanityProject} from '@sanity/client'\nimport {getProjectsState, resolveProjects, type SanityInstance, type StateSource} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * @public\n * @category Types\n */\nexport type ProjectWithoutMembers = Omit<SanityProject, 'members'>\n\ntype UseProjects = {\n /**\n *\n * Returns metadata for each project in your organization.\n *\n * @category Projects\n * @returns An array of metadata (minus the projects’ members) for each project in your organization\n * @example\n * ```tsx\n * const projects = useProjects()\n *\n * return (\n * <select>\n * {projects.map((project) => (\n * <option key={project.id}>{project.displayName}</option>\n * ))}\n * </select>\n * )\n * ```\n */\n (): ProjectWithoutMembers[]\n}\n\n/** @public */\nexport const useProjects: UseProjects = createStateSourceHook({\n // remove `undefined` since we're suspending when that is the case\n getState: getProjectsState as (instance: SanityInstance) => StateSource<ProjectWithoutMembers[]>,\n shouldSuspend: (instance) => getProjectsState(instance).getCurrent() === undefined,\n suspender: resolveProjects,\n})\n","import {createUsersStore, type ResourceType, type SanityUser} from '@sanity/sdk'\nimport {useCallback, useEffect, useState, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @public\n * @category Types\n */\nexport interface UseUsersParams {\n /**\n * The type of resource to fetch users for.\n */\n resourceType: ResourceType\n /**\n * The ID of the resource to fetch users for.\n */\n resourceId: string\n /**\n * The limit of users to fetch.\n */\n limit?: number\n}\n\n/**\n * @public\n * @category Types\n */\nexport interface UseUsersResult {\n /**\n * The users fetched.\n */\n users: SanityUser[]\n /**\n * Whether there are more users to fetch.\n */\n hasMore: boolean\n /**\n * Load more users.\n */\n loadMore: () => void\n}\n\n/**\n *\n * @public\n *\n * Retrieves the users for a given resource (either a project or an organization).\n *\n * @category Users\n * @param params - The resource type and its ID, and the limit of users to fetch\n * @returns A list of users, a boolean indicating whether there are more users to fetch, and a function to load more users\n *\n * @example\n * ```\n * const { users, hasMore, loadMore } = useUsers({\n * resourceType: 'organization',\n * resourceId: 'my-org-id',\n * limit: 10,\n * })\n *\n * return (\n * <div>\n * {users.map(user => (\n * <figure key={user.sanityUserId}>\n * <img src={user.profile.imageUrl} alt='' />\n * <figcaption>{user.profile.displayName}</figcaption>\n * <address>{user.profile.email}</address>\n * </figure>\n * ))}\n * {hasMore && <button onClick={loadMore}>Load More</button>}\n * </div>\n * )\n * ```\n */\nexport function useUsers(params: UseUsersParams): UseUsersResult {\n const instance = useSanityInstance(params.resourceId)\n const [store] = useState(() => createUsersStore(instance))\n\n useEffect(() => {\n store.setOptions({\n resourceType: params.resourceType,\n resourceId: params.resourceId,\n })\n }, [params.resourceType, params.resourceId, store])\n\n const subscribe = useCallback(\n (onStoreChanged: () => void) => {\n if (store.getState().getCurrent().initialFetchCompleted === false) {\n store.resolveUsers()\n }\n const unsubscribe = store.getState().subscribe(onStoreChanged)\n\n return () => {\n unsubscribe()\n store.dispose()\n }\n },\n [store],\n )\n\n const getSnapshot = useCallback(() => store.getState().getCurrent(), [store])\n\n const {users, hasMore} = useSyncExternalStore(subscribe, getSnapshot) || {}\n\n return {users, hasMore, loadMore: store.loadMore}\n}\n"],"names":["useAuthToken","createStateSourceHook","getTokenState","useCurrentUser","getCurrentUserState","useClient","getState","getClientState","getResourceId","e","resourceId","useFrameConnection","options","$","_c","onMessage","targetOrigin","name","connectTo","heartbeat","instance","useSanityInstance","status","setStatus","useState","t0","t1","getOrCreateController","controller","t2","t3","getOrCreateChannel","channel","t4","t5","onStatus","event","useEffect","t6","t7","unsubscribers","Object","entries","forEach","t8","type","handler","unsubscribe_0","on","push","unsubscribe","_temp","frameWindow","removeTarget","addTarget","connect","t9","type_0","data","post","sendMessage","t10","t11","releaseChannel","t12","unsub","useWindowConnection","getOrCreateNode","node","newStatus","releaseNode","useManageFavorite","_id","_type","isFavorited","setIsFavorited","Symbol","for","SDK_NODE_NAME","SDK_CHANNEL_NAME","action","setFavoriteState","message","eventType","documentId","documentType","err","error","Error","handleFavoriteAction","favorite","unfavorite","isConnected","useRecordDocumentHistoryEvent","recordEvent","useDatasets","getDatasetsState","shouldSuspend","getCurrent","undefined","suspender","resolveDatasets","useApplyActions","_useApplyActions","createCallbackHook","applyActions","useDocument","doc","path","_useDocument","getDocumentState","resolveDocument","useDocumentEvent","ref","useRef","current","useInsertionEffect","documentEvent","stableHandler","subscribeDocumentEvents","useDocumentSyncStatus","getDocumentSyncStatus","ignoredKeys","useEditDocument","apply","updater","nextValue","editDocument","set","nextValue_0","editActions","keys","filter","key_0","key","map","key_1","unset","includes","usePermissions","actions","Array","isArray","resourceIds","Set","size","getPermissionsState","firstValueFrom","observable","pipe","_temp2","subscribe","useSyncExternalStore","result","useQuery","query","isPending","startTransition","useTransition","queryKey","getQueryKey","deferredQueryKey","setDeferredQueryKey","deferred","useMemo","parseQueryKey","setRef","AbortController","signal","aborted","abort","getQueryState","resolveQuery","DEFAULT_BATCH_SIZE","DEFAULT_PERSPECTIVE","useInfiniteList","orderings","params","search","batchSize","perspective","limit","setLimit","JSON","stringify","conditions","trim","length","join","filterClause","orderClause","dataQuery","countQuery","count","hasMore","prev","Math","min","loadMore","ordering","field","direction","toLowerCase","Boolean","str","usePaginatedList","pageSize","pageIndex","setPageIndex","startIndex","endIndex","totalPages","ceil","currentPage","firstPage","t13","_temp3","previousPage","t14","prev_0","nextPage","t15","lastPage","t16","pageNumber","goToPage","hasFirstPage","hasPreviousPage","hasNextPage","hasLastPage","t17","t18","max","usePreview","document","getPreviewState","stateSource","onStoreChanged","subscription","Observable","observer","IntersectionObserver","HTMLElement","intersectionObserver","entry","next","isIntersecting","rootMargin","threshold","observe","disconnect","startWith","distinctUntilChanged","switchMap","isVisible","obs","EMPTY","currentState","results","resolvePreview","useProjection","projection","getProjectionState","resolveProjection","useProject","getProjectState","projectId","resolveProject","useProjects","getProjectsState","resolveProjects","useUsers","createUsersStore","store","resourceType","setOptions","initialFetchCompleted","resolveUsers","dispose","getSnapshot","users"],"mappings":";;;;;;;AASaA,MAAAA,eAAeC,sBAAsBC,aAAa,GCuBlDC,iBAAiCF,sBAAsBG,mBAAmB,GCF1EC,YAAYJ,sBAAsB;AAAA,EAC7CK,UAAUC;AAAAA,EACVC,eAAgBC,OAAMA,EAAEC;AAC1B,CAAC;ACeM,SAAAC,mBAAAC,SAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA,GAIL;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAA8DP,SAC9DQ,WAAiBC,kBAAkB,GACn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useCurrentUser.tsx","../src/hooks/documentCollection/useDocuments.ts","../src/hooks/preview/usePreview.tsx"],"sourcesContent":["import {getTokenState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * Hook to get the currently logged in user\n * @public\n * @returns The current user or null if not authenticated\n */\nexport const useAuthToken = createStateSourceHook(getTokenState)\n","import {getCurrentUserState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * Hook to get the currently logged in user\n * @public\n * @returns The current user or null if not authenticated\n */\nexport const useCurrentUser = createStateSourceHook(getCurrentUserState)\n","import {createDocumentListStore, type DocumentHandle, type DocumentListOptions} from '@sanity/sdk'\nimport {useCallback, useEffect, useState, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @public\n */\nexport interface UseDocuments {\n loadMore: () => void\n results: DocumentHandle[]\n isPending: boolean\n hasMore: boolean\n count: number\n}\n\ntype DocumentListStore = ReturnType<typeof createDocumentListStore>\ntype DocumentListState = ReturnType<DocumentListStore['getState']>['getCurrent']\nconst STABLE_EMPTY = {\n results: [],\n isPending: false,\n hasMore: false,\n count: 0,\n}\n\n/**\n * Hook to get the list of documents for specified options\n *\n * @public\n *\n * @param options - options for the document list\n * @returns result of the document list and function to load more\n */\nexport function useDocuments(options: DocumentListOptions = {}): UseDocuments {\n const instance = useSanityInstance()\n\n // NOTE: useState is used because it guaranteed to return a stable reference\n // across renders\n const [ref] = useState<{\n storeInstance: DocumentListStore | null\n getCurrent: DocumentListState\n initialOptions: DocumentListOptions\n }>(() => ({\n storeInstance: null,\n getCurrent: () => STABLE_EMPTY,\n initialOptions: options,\n }))\n\n // serialize options to ensure it only calls `setOptions` when the values\n // themselves changes (in cases where devs put config inline)\n const serializedOptions = JSON.stringify(options)\n useEffect(() => {\n ref.storeInstance?.setOptions(JSON.parse(serializedOptions))\n }, [ref, serializedOptions])\n\n const subscribe = useCallback(\n (onStoreChanged: () => void) => {\n // to match the lifecycle of `useSyncExternalState`, we create the store\n // instance after subscribe and mutate the ref to connect everything\n ref.storeInstance = createDocumentListStore(instance)\n ref.storeInstance.setOptions(ref.initialOptions)\n const state = ref.storeInstance.getState()\n ref.getCurrent = state.getCurrent\n const unsubscribe = state.subscribe(onStoreChanged)\n\n return () => {\n // unsubscribe to clean up the state subscriptions\n unsubscribe()\n // dispose of the instance\n ref.storeInstance?.dispose()\n }\n },\n [instance, ref],\n )\n\n const getSnapshot = useCallback(() => {\n return ref.getCurrent()\n }, [ref])\n\n const state = useSyncExternalStore(subscribe, getSnapshot)\n\n const loadMore = useCallback(() => {\n ref.storeInstance?.loadMore()\n }, [ref])\n\n return {loadMore, ...state}\n}\n","import {type DocumentHandle, getPreviewState, type PreviewValue, resolvePreview} from '@sanity/sdk'\nimport {type RefObject, useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {distinctUntilChanged, EMPTY, Observable, startWith, switchMap} from 'rxjs'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @alpha\n */\nexport interface UsePreviewOptions {\n document: DocumentHandle\n ref?: RefObject<HTMLElement>\n}\n\n/**\n * @alpha\n */\nexport function usePreview({\n document: {_id, _type},\n ref,\n}: UsePreviewOptions): [PreviewValue, boolean] {\n const instance = useSanityInstance()\n\n const stateSource = useMemo(\n () => getPreviewState(instance, {document: {_id, _type}}),\n [instance, _id, _type],\n )\n\n // Create subscribe function for useSyncExternalStore\n const subscribe = useCallback(\n (onStoreChanged: () => void) => {\n const subscription = new Observable<boolean>((observer) => {\n // for environments that don't have an intersection observer\n if (typeof IntersectionObserver === 'undefined') return\n\n const intersectionObserver = new IntersectionObserver(\n ([entry]) => observer.next(entry.isIntersecting),\n {rootMargin: '0px', threshold: 0},\n )\n if (ref?.current) intersectionObserver.observe(ref.current)\n return () => intersectionObserver.disconnect()\n })\n .pipe(\n startWith(false),\n distinctUntilChanged(),\n switchMap((isVisible) =>\n isVisible\n ? new Observable<void>((obs) => {\n return stateSource.subscribe(() => obs.next())\n })\n : EMPTY,\n ),\n )\n .subscribe({next: onStoreChanged})\n\n return () => subscription.unsubscribe()\n },\n [stateSource, ref],\n )\n\n // Create getSnapshot function to return current state\n const getSnapshot = useCallback(() => {\n const previewTuple = stateSource.getCurrent()\n if (!previewTuple[0]) throw resolvePreview(instance, {document: {_id, _type}})\n return previewTuple as [PreviewValue, boolean]\n }, [_id, _type, instance, stateSource])\n\n return useSyncExternalStore(subscribe, getSnapshot)\n}\n"],"names":["state"],"mappings":";;;;;AASa,MAAA,eAAe,sBAAsB,aAAa,GCAlD,iBAAiB,sBAAsB,mBAAmB,GCSjE,eAAe;AAAA,EACnB,SAAS,CAAC;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AACT;AAUgB,SAAA,aAAa,UAA+B,IAAkB;AAC5E,QAAM,WAAW,kBAAkB,GAI7B,CAAC,GAAG,IAAI,SAIX,OAAO;AAAA,IACR,eAAe;AAAA,IACf,YAAY,MAAM;AAAA,IAClB,gBAAgB;AAAA,EAChB,EAAA,GAII,oBAAoB,KAAK,UAAU,OAAO;AAChD,YAAU,MAAM;AACd,QAAI,eAAe,WAAW,KAAK,MAAM,iBAAiB,CAAC;AAAA,EAAA,GAC1D,CAAC,KAAK,iBAAiB,CAAC;AAE3B,QAAM,YAAY;AAAA,IAChB,CAAC,mBAA+B;AAG1B,UAAA,gBAAgB,wBAAwB,QAAQ,GACpD,IAAI,cAAc,WAAW,IAAI,cAAc;AACzCA,YAAAA,SAAQ,IAAI,cAAc,SAAS;AACzC,UAAI,aAAaA,OAAM;AACjB,YAAA,cAAcA,OAAM,UAAU,cAAc;AAElD,aAAO,MAAM;AAEC,uBAEZ,IAAI,eAAe,QAAQ;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,UAAU,GAAG;AAAA,EAGV,GAAA,cAAc,YAAY,MACvB,IAAI,WAAW,GACrB,CAAC,GAAG,CAAC,GAEF,QAAQ,qBAAqB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AW,WAAW;AACpD;"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * This version is provided by pkg-utils at build time
3
- * @internal
2
+ * An example function that will be removed.
3
+ * @public
4
4
  */
5
- export declare const REACT_SDK_VERSION: {}
5
+ export declare function main(): void
6
6
 
7
7
  export {}
package/dist/index.js CHANGED
@@ -1,14 +1,6 @@
1
- var version = "0.0.0-alpha.18";
2
- function getEnv(key) {
3
- if (typeof import.meta < "u" && import.meta.env)
4
- return import.meta.env[key];
5
- if (typeof process < "u" && process.env)
6
- return process.env[key];
7
- if (typeof window < "u" && window.ENV)
8
- return window.ENV?.[key];
1
+ function main() {
9
2
  }
10
- const REACT_SDK_VERSION = getEnv("PKG_VERSION") || `${version}-development`;
11
3
  export {
12
- REACT_SDK_VERSION
4
+ main
13
5
  };
14
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils/getEnv.ts","../src/version.ts"],"sourcesContent":["// Local type declaration for Remix\ntype WindowWithEnv = Window &\n typeof globalThis & {\n ENV?: Record<string, unknown>\n }\n\ntype KnownEnvVar = 'DEV' | 'PKG_VERSION'\n\nexport function getEnv(key: KnownEnvVar): unknown {\n if (typeof import.meta !== 'undefined' && import.meta.env) {\n // Vite environment variables\n return (import.meta.env as unknown as Record<string, unknown>)[key]\n } else if (typeof process !== 'undefined' && process.env) {\n // Node.js or server-side environment variables\n return process.env[key]\n } else if (typeof window !== 'undefined' && (window as WindowWithEnv).ENV) {\n // Remix-style client-side environment variables\n return (window as WindowWithEnv).ENV?.[key]\n }\n return undefined\n}\n","import {version} from '../package.json'\nimport {getEnv} from './utils/getEnv'\n\n/**\n * This version is provided by pkg-utils at build time\n * @internal\n */\nexport const REACT_SDK_VERSION = getEnv('PKG_VERSION') || `${version}-development`\n"],"names":["getEnv","key","import","env","process","window","ENV","REACT_SDK_VERSION","version"],"mappings":";AAQO,SAASA,OAAOC,KAA2B;AAC5C,MAAA,OAAOC,cAAgB,OAAeA,YAAYC;AAE5CD,WAAAA,YAAYC,IAA2CF,GAAG;AACzD,MAAA,OAAOG,UAAY,OAAeA,QAAQD;AAE5CC,WAAAA,QAAQD,IAAIF,GAAG;AACb,MAAA,OAAOI,SAAW,OAAgBA,OAAyBC;AAE5DD,WAAAA,OAAyBC,MAAML,GAAG;AAG9C;ACbO,MAAMM,oBAAoBP,OAAO,aAAa,KAAK,GAAGQ,OAAO;"}
1
+ {"version":3,"file":"index.js","sources":["../src/_exports/index.ts"],"sourcesContent":["/**\n * An example function that will be removed.\n * @public\n */\nexport function main(): void {\n //\n}\n\n// export * from './components'\n// export * from './hooks'\n"],"names":[],"mappings":"AAIO,SAAS,OAAa;AAE7B;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/sdk-react",
3
- "version": "0.0.0-alpha.18",
3
+ "version": "0.0.0-alpha.2",
4
4
  "private": false,
5
5
  "description": "Sanity SDK React toolkit for Content OS",
6
6
  "keywords": [
@@ -30,21 +30,16 @@
30
30
  "import": "./dist/index.js",
31
31
  "default": "./dist/index.js"
32
32
  },
33
- "./context": {
34
- "source": "./src/_exports/context.ts",
35
- "import": "./dist/context.js",
36
- "default": "./dist/context.js"
33
+ "./components": {
34
+ "source": "./src/_exports/components.ts",
35
+ "import": "./dist/components.js",
36
+ "default": "./dist/components.js"
37
37
  },
38
38
  "./hooks": {
39
39
  "source": "./src/_exports/hooks.ts",
40
40
  "import": "./dist/hooks.js",
41
41
  "default": "./dist/hooks.js"
42
42
  },
43
- "./components": {
44
- "source": "./src/_exports/components.ts",
45
- "import": "./dist/components.js",
46
- "default": "./dist/components.js"
47
- },
48
43
  "./package.json": "./package.json"
49
44
  },
50
45
  "main": "./dist/index.js",
@@ -52,8 +47,8 @@
52
47
  "types": "./dist/index.d.ts",
53
48
  "typesVersions": {
54
49
  "*": {
55
- "context": [
56
- "./dist/context.d.ts"
50
+ "components": [
51
+ "./dist/components.d.ts"
57
52
  ],
58
53
  "hooks": [
59
54
  "./dist/hooks.d.ts"
@@ -64,45 +59,55 @@
64
59
  "dist",
65
60
  "src"
66
61
  ],
62
+ "lint-staged": {
63
+ "!(*.{ts,tsx})": "prettier --write",
64
+ "*.{ts,tsx}": [
65
+ "eslint --fix",
66
+ "prettier --write"
67
+ ]
68
+ },
67
69
  "browserslist": "extends @sanity/browserslist-config",
68
70
  "prettier": "@sanity/prettier-config",
69
71
  "dependencies": {
72
+ "@paramour/css": "1.0.0-rc.2",
73
+ "@sanity/icons": "^3.5.2",
70
74
  "@sanity/logos": "^2.1.13",
71
- "@sanity/message-protocol": "^0.1.0",
72
- "@sanity/types": "^3.78.1",
75
+ "@sanity/ui": "^2.8.19",
76
+ "@types/lodash-es": "^4.17.12",
77
+ "inter-ui": "^4.1.0",
78
+ "lodash-es": "^4.17.21",
73
79
  "react-error-boundary": "^4.1.2",
80
+ "rollup-plugin-import-css": "^3.5.7",
74
81
  "rxjs": "^7.8.1",
75
- "@sanity/sdk": "0.0.0-alpha.17"
82
+ "zustand": "^5.0.1",
83
+ "@sanity/sdk": "0.0.0-alpha.2"
76
84
  },
77
85
  "devDependencies": {
78
- "@sanity/browserslist-config": "^1.0.5",
79
- "@sanity/client": "^6.28.1",
80
- "@sanity/comlink": "^3.0.1",
81
- "@sanity/pkg-utils": "^6.13.4",
86
+ "@sanity/client": "^6.24.1",
87
+ "@sanity/pkg-utils": "^6.12.2",
82
88
  "@sanity/prettier-config": "^1.0.3",
89
+ "@storybook/react": "^8.4.7",
83
90
  "@testing-library/jest-dom": "^6.6.3",
84
- "@testing-library/react": "^16.2.0",
85
- "@types/react": "^19.0.10",
86
- "@types/react-dom": "^19.0.4",
91
+ "@testing-library/react": "^16.1.0",
92
+ "@types/react": "^18.3.18",
93
+ "@types/react-dom": "^18.3.5",
87
94
  "@vitejs/plugin-react": "^4.3.4",
88
- "@vitest/coverage-v8": "3.0.7",
89
- "babel-plugin-react-compiler": "19.0.0-beta-bafa41b-20250307",
90
- "eslint": "^9.21.0",
95
+ "@vitest/coverage-v8": "2.1.8",
96
+ "eslint": "^9.17.0",
91
97
  "jsdom": "^25.0.1",
92
- "prettier": "^3.5.2",
93
- "react": "^19.0.0",
94
- "react-dom": "^19.0.0",
95
- "typescript": "^5.7.3",
96
- "vite": "^6.2.0",
97
- "vitest": "^3.0.7",
98
+ "lint-staged": "^15.2.10",
99
+ "prettier": "^3.4.2",
100
+ "react": "^18.3.1",
101
+ "react-dom": "^18.3.1",
102
+ "typescript": "^5.7.2",
103
+ "vitest": "^2.1.8",
98
104
  "@repo/config-eslint": "0.0.0",
99
- "@repo/config-test": "0.0.1",
100
- "@repo/package.config": "0.0.1",
101
- "@repo/tsconfig": "0.0.1"
105
+ "@repo/package.config": "0.0.1"
102
106
  },
103
107
  "peerDependencies": {
104
- "react": "^18.0.0 || ^19.0.0",
105
- "react-dom": "^18.0.0 || ^19.0.0"
108
+ "react": "^18.0.0",
109
+ "react-dom": "^18.0.0",
110
+ "styled-components": "^6.1.13"
106
111
  },
107
112
  "engines": {
108
113
  "node": ">=20.0.0"
@@ -117,6 +122,7 @@
117
122
  "docs": "typedoc --out docs --tsconfig ../../tsconfig.tsdoc.json",
118
123
  "format": "prettier --write --cache --ignore-unknown .",
119
124
  "lint": "eslint .",
125
+ "paramour": "npx paramour --config=./src/css/css.config.js --output=./src/css/paramour.css",
120
126
  "test": "vitest run",
121
127
  "test:coverage": "vitest run --coverage",
122
128
  "test:watch": "vitest",
@@ -1,3 +1,13 @@
1
- export {AuthBoundary} from '../components/auth/AuthBoundary'
2
- export {SanityApp, type SanityAppProps} from '../components/SanityApp'
3
- export {SDKProvider, type SDKProviderProps} from '../components/SDKProvider'
1
+ export {AuthBoundary, type AuthBoundaryProps} from '../components/auth/AuthBoundary'
2
+ export {AuthError} from '../components/auth/AuthError'
3
+ export {Login} from '../components/auth/Login'
4
+ export {LoginCallback} from '../components/auth/LoginCallback'
5
+ export {LoginError, type LoginErrorProps} from '../components/auth/LoginError'
6
+ export {LoginLayout, type LoginLayoutProps} from '../components/auth/LoginLayout'
7
+ export type {SanityProviderProps} from '../components/context/SanityProvider'
8
+ export {SanityProvider} from '../components/context/SanityProvider'
9
+ export {DocumentGridLayout} from '../components/DocumentGridLayout/DocumentGridLayout'
10
+ export {DocumentListLayout} from '../components/DocumentListLayout/DocumentListLayout'
11
+ export {DocumentPreviewLayout} from '../components/DocumentPreviewLayout/DocumentPreviewLayout'
12
+ export {type DocumentPreviewLayoutProps} from '../components/DocumentPreviewLayout/DocumentPreviewLayout'
13
+ export {LoginLinks} from '../components/Login/LoginLinks'
@@ -4,49 +4,6 @@ export {useCurrentUser} from '../hooks/auth/useCurrentUser'
4
4
  export {useHandleCallback} from '../hooks/auth/useHandleCallback'
5
5
  export {useLoginUrls} from '../hooks/auth/useLoginUrls'
6
6
  export {useLogOut} from '../hooks/auth/useLogOut'
7
- export {useClient} from '../hooks/client/useClient'
8
- export {
9
- type FrameConnection,
10
- type FrameMessageHandler as MessageHandler,
11
- useFrameConnection,
12
- type UseFrameConnectionOptions,
13
- } from '../hooks/comlink/useFrameConnection'
14
- export {useManageFavorite} from '../hooks/comlink/useManageFavorite'
15
- export {useRecordDocumentHistoryEvent} from '../hooks/comlink/useRecordDocumentHistoryEvent'
16
- export {
17
- useWindowConnection,
18
- type UseWindowConnectionOptions,
19
- type WindowConnection,
20
- type WindowMessageHandler,
21
- } from '../hooks/comlink/useWindowConnection'
22
7
  export {useSanityInstance} from '../hooks/context/useSanityInstance'
23
- export {useDatasets} from '../hooks/datasets/useDatasets'
24
- export {useApplyActions} from '../hooks/document/useApplyActions'
25
- export {useDocument} from '../hooks/document/useDocument'
26
- export {useDocumentEvent} from '../hooks/document/useDocumentEvent'
27
- export {useDocumentSyncStatus} from '../hooks/document/useDocumentSyncStatus'
28
- export {useEditDocument} from '../hooks/document/useEditDocument'
29
- export {usePermissions} from '../hooks/document/usePermissions'
30
- export {
31
- type InfiniteList,
32
- type InfiniteListOptions,
33
- useInfiniteList,
34
- } from '../hooks/infiniteList/useInfiniteList'
35
- export {
36
- type PaginatedList,
37
- type PaginatedListOptions,
38
- usePaginatedList,
39
- } from '../hooks/paginatedList/usePaginatedList'
40
- export {
41
- usePreview,
42
- type UsePreviewOptions,
43
- type UsePreviewResults,
44
- } from '../hooks/preview/usePreview'
45
- export {useProjection} from '../hooks/projection/useProjection'
46
- export {useProject} from '../hooks/projects/useProject'
47
- export {type ProjectWithoutMembers, useProjects} from '../hooks/projects/useProjects'
48
- export {useQuery} from '../hooks/query/useQuery'
49
- export {useUsers, type UseUsersParams, type UseUsersResult} from '../hooks/users/useUsers'
50
- export {type DatasetsResponse, type SanityProject, type SanityProjectMember} from '@sanity/client'
51
- export {type CurrentUser, type DocumentHandle} from '@sanity/sdk'
52
- export {type SanityDocument, type SortOrderingItem} from '@sanity/types'
8
+ export {type UseDocuments, useDocuments} from '../hooks/documentCollection/useDocuments'
9
+ export {usePreview, type UsePreviewOptions} from '../hooks/preview/usePreview'
@@ -1 +1,10 @@
1
- export {REACT_SDK_VERSION} from '../version'
1
+ /**
2
+ * An example function that will be removed.
3
+ * @public
4
+ */
5
+ export function main(): void {
6
+ //
7
+ }
8
+
9
+ // export * from './components'
10
+ // export * from './hooks'
@@ -0,0 +1,113 @@
1
+ import {type Meta, type StoryObj} from '@storybook/react'
2
+
3
+ import {DocumentPreviewLayout} from '../DocumentPreviewLayout/DocumentPreviewLayout.tsx'
4
+ import {DocumentGridLayout} from './DocumentGridLayout.tsx'
5
+
6
+ const meta: Meta<typeof DocumentGridLayout> = {
7
+ title: 'DocumentGridLayout',
8
+ component: DocumentGridLayout,
9
+ }
10
+
11
+ export default meta
12
+ type Story = StoryObj<typeof meta>
13
+
14
+ const mockDocs = [
15
+ {id: '1', title: 'Just a title', url: '#', docType: 'article', status: 'published'},
16
+ {
17
+ id: '2',
18
+ title: 'A title, but also',
19
+ subtitle: 'A subtitle',
20
+ docType: 'article',
21
+ status: 'draft',
22
+ media: {
23
+ type: 'image-asset',
24
+ url: 'https://picsum.photos/75/75',
25
+ },
26
+ },
27
+ {
28
+ id: '3',
29
+ title: 'Hello World',
30
+ subtitle: 'What a nice list I get to live in',
31
+ docType: 'image',
32
+ status: 'published',
33
+ media: {
34
+ type: 'image-asset',
35
+ url: 'https://picsum.photos/80/80',
36
+ },
37
+ },
38
+ {
39
+ id: '4',
40
+ title: 'I’ve been selected',
41
+ subtitle: 'I feel special',
42
+ selected: true,
43
+ docType: 'video',
44
+ status: 'draft',
45
+ media: {
46
+ type: 'image-asset',
47
+ url: 'https://picsum.photos/100/100',
48
+ },
49
+ },
50
+ {
51
+ id: '5',
52
+ title: 'A very long title that at some point might get truncated if it goes for long enough',
53
+ subtitle:
54
+ 'Along with a subtitle that is quite long as well, in order to demonstrate the truncation of its text',
55
+ docType: 'audio',
56
+ status: 'published',
57
+ media: {
58
+ type: 'image-asset',
59
+ url: 'https://picsum.photos/75/75',
60
+ },
61
+ },
62
+ {
63
+ id: '6',
64
+ title: 'Hello World',
65
+ subtitle: 'What a nice list I get to live in',
66
+ docType: 'pdf',
67
+ status: 'published',
68
+ media: {
69
+ type: 'image-asset',
70
+ url: 'https://picsum.photos/75/75',
71
+ },
72
+ },
73
+ {id: '7', title: 'Just a title', url: '#', docType: 'note', status: 'published,'},
74
+ {
75
+ id: '8',
76
+ title: 'A title, but also',
77
+ subtitle: 'A subtitle',
78
+ docType: 'document',
79
+ status: 'draft',
80
+ },
81
+ {
82
+ id: '9',
83
+ title: 'Hello World',
84
+ subtitle: 'What a nice list I get to live in',
85
+ docType: 'biography',
86
+ status: 'published',
87
+ media: {
88
+ type: 'image-asset',
89
+ url: 'https://picsum.photos/200/200',
90
+ },
91
+ },
92
+ ]
93
+
94
+ export const Default: Story = {
95
+ render: () => {
96
+ return (
97
+ <DocumentGridLayout>
98
+ {mockDocs.map((doc) => (
99
+ <li key={doc.id}>
100
+ <DocumentPreviewLayout
101
+ title={doc.title}
102
+ subtitle={doc.subtitle}
103
+ media={doc.media}
104
+ selected={doc.selected}
105
+ docType={doc.docType}
106
+ status={doc.status}
107
+ />
108
+ </li>
109
+ ))}
110
+ </DocumentGridLayout>
111
+ )
112
+ },
113
+ }