@sanity/sdk-react 0.0.0-alpha.3 → 0.0.0-alpha.4

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 (61) hide show
  1. package/README.md +3 -6
  2. package/dist/_chunks-es/context.js +8 -0
  3. package/dist/_chunks-es/context.js.map +1 -0
  4. package/dist/_chunks-es/useLogOut.js +11 -11
  5. package/dist/_chunks-es/useLogOut.js.map +1 -1
  6. package/dist/components.d.ts +10 -186
  7. package/dist/components.js +32 -201
  8. package/dist/components.js.map +1 -1
  9. package/dist/context.d.ts +39 -0
  10. package/dist/context.js +5 -0
  11. package/dist/context.js.map +1 -0
  12. package/dist/hooks.d.ts +92 -1
  13. package/dist/hooks.js +76 -4
  14. package/dist/hooks.js.map +1 -1
  15. package/package.json +16 -15
  16. package/src/_exports/components.ts +2 -13
  17. package/src/_exports/context.ts +2 -0
  18. package/src/_exports/hooks.ts +12 -0
  19. package/src/components/Login/LoginLinks.test.tsx +3 -12
  20. package/src/components/Login/LoginLinks.tsx +14 -29
  21. package/src/components/SanityApp.test.tsx +54 -0
  22. package/src/components/SanityApp.tsx +26 -0
  23. package/src/components/auth/AuthBoundary.test.tsx +3 -10
  24. package/src/components/auth/AuthBoundary.tsx +2 -2
  25. package/src/components/auth/Login.test.tsx +2 -9
  26. package/src/components/auth/Login.tsx +9 -16
  27. package/src/components/auth/LoginCallback.test.tsx +2 -10
  28. package/src/components/auth/LoginCallback.tsx +4 -5
  29. package/src/components/auth/LoginError.test.tsx +2 -9
  30. package/src/components/auth/LoginError.tsx +11 -11
  31. package/src/components/auth/LoginFooter.test.tsx +2 -9
  32. package/src/components/auth/LoginFooter.tsx +9 -23
  33. package/src/components/auth/LoginLayout.test.tsx +2 -9
  34. package/src/components/auth/LoginLayout.tsx +7 -19
  35. package/src/{components/context → context}/SanityProvider.test.tsx +1 -1
  36. package/src/hooks/client/useClient.test.tsx +1 -1
  37. package/src/hooks/comlink/useFrameConnection.test.tsx +122 -0
  38. package/src/hooks/comlink/useFrameConnection.ts +111 -0
  39. package/src/hooks/comlink/useWindowConnection.test.ts +94 -0
  40. package/src/hooks/comlink/useWindowConnection.ts +82 -0
  41. package/src/hooks/context/useSanityInstance.test.tsx +1 -1
  42. package/src/hooks/context/useSanityInstance.ts +2 -2
  43. package/src/hooks/helpers/createCallbackHook.tsx +1 -1
  44. package/src/hooks/helpers/createStateSourceHook.tsx +1 -1
  45. package/src/hooks/preview/usePreview.test.tsx +1 -1
  46. package/src/vite-env.d.ts +10 -0
  47. package/dist/assets/bundle-CcAyERuZ.css +0 -11
  48. package/src/components/DocumentGridLayout/DocumentGridLayout.stories.tsx +0 -113
  49. package/src/components/DocumentGridLayout/DocumentGridLayout.test.tsx +0 -42
  50. package/src/components/DocumentGridLayout/DocumentGridLayout.tsx +0 -21
  51. package/src/components/DocumentListLayout/DocumentListLayout.stories.tsx +0 -105
  52. package/src/components/DocumentListLayout/DocumentListLayout.test.tsx +0 -42
  53. package/src/components/DocumentListLayout/DocumentListLayout.tsx +0 -12
  54. package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.md +0 -49
  55. package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.stories.tsx +0 -39
  56. package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.test.tsx +0 -30
  57. package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.tsx +0 -171
  58. package/src/css/css.config.js +0 -220
  59. package/src/css/paramour.css +0 -2347
  60. package/src/css/styles.css +0 -11
  61. /package/src/{components/context → context}/SanityProvider.tsx +0 -0
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <h1 align="center">Sanity SDK - React</h1>
6
6
  </p>
7
7
 
8
- React components and hooks for creating Sanity applications.
8
+ React hooks for creating Sanity applications.
9
9
 
10
10
  ## Installation
11
11
 
@@ -34,7 +34,7 @@ npm run dev
34
34
  ```tsx
35
35
  // src/App.tsx
36
36
  import {createSanityInstance} from '@sanity/sdk'
37
- import {AuthBoundary, SanityProvider} from '@sanity/sdk-react/components'
37
+ import {SanityProvider} from '@sanity/sdk-react/context'
38
38
  import {useCurrentUser, useLogOut} from '@sanity/sdk-react/hooks'
39
39
  import {Button, Flex, Spinner, Text, ThemeProvider} from '@sanity/ui'
40
40
  import {buildTheme} from '@sanity/ui/theme'
@@ -56,6 +56,7 @@ export function App(): JSX.Element {
56
56
  <ThemeProvider theme={theme}>
57
57
  <Suspense fallback={<Spinner />}>
58
58
  <SanityProvider sanityInstance={sanityInstance}>
59
+ {/* You will need to implement an auth boundary */}
59
60
  <AuthBoundary header={<Text>My Sanity App</Text>}>
60
61
  <Authenticated />
61
62
  </AuthBoundary>
@@ -80,10 +81,6 @@ function Authenticated() {
80
81
  export default App
81
82
  ```
82
83
 
83
- ## Customizing your application
84
-
85
- If you would like to implement a custom look and feel, you can use the hooks in your own components.
86
-
87
84
  ## Available Hooks
88
85
 
89
86
  - `useAuthState` - Get current authentication state
@@ -0,0 +1,8 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createContext } from "react";
3
+ const SanityInstanceContext = createContext(null), SanityProvider = ({ children, sanityInstance }) => /* @__PURE__ */ jsx(SanityInstanceContext.Provider, { value: sanityInstance, children });
4
+ export {
5
+ SanityInstanceContext,
6
+ SanityProvider
7
+ };
8
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../src/context/SanityProvider.tsx"],"sourcesContent":["import {type SanityInstance} from '@sanity/sdk'\nimport {createContext, type ReactElement} from 'react'\n\n/**\n * @public\n */\nexport interface SanityProviderProps {\n children: React.ReactNode\n sanityInstance: SanityInstance\n}\n\nexport const SanityInstanceContext = createContext<SanityInstance | null>(null)\n\n/**\n * Top-level context provider that provides a Sanity configuration instance.\n * This must wrap any Sanity SDK React component.\n * @public\n * @param props - Sanity project and dataset configuration\n * @returns Rendered component\n * @example\n * ```tsx\n * import {createSanityInstance} from '@sanity/sdk'\n * import {ExampleComponent, SanityProvider} from '@sanity/sdk-react'\n *\n * const sanityInstance = createSanityInstance({projectId: 'your-project-id', dataset: 'production'})\n *\n * export default function MyApp() {\n * return (\n * <SanityProvider sanityInstance={sanityInstance}>\n * <ExampleComponent />\n * </SanityProvider>\n * )\n * }\n * ```\n */\nexport const SanityProvider = ({children, sanityInstance}: SanityProviderProps): ReactElement => {\n return (\n <SanityInstanceContext.Provider value={sanityInstance}>\n {children}\n </SanityInstanceContext.Provider>\n )\n}\n"],"names":[],"mappings":";;AAWO,MAAM,wBAAwB,cAAqC,IAAI,GAwBjE,iBAAiB,CAAC,EAAC,UAAU,eAAc,0BAEnD,sBAAsB,UAAtB,EAA+B,OAAO,gBACpC,SACH,CAAA;"}
@@ -1,7 +1,7 @@
1
- import { getAuthState, getLoginUrlsState, fetchLoginUrls, handleCallback, logout } from "@sanity/sdk";
2
- import { createContext, useContext, useMemo, useSyncExternalStore, useCallback } from "react";
3
- import { jsx } from "react/jsx-runtime";
4
- const SanityInstanceContext = createContext(null), SanityProvider = ({ children, sanityInstance }) => /* @__PURE__ */ jsx(SanityInstanceContext.Provider, { value: sanityInstance, children }), useSanityInstance = () => {
1
+ import { getAuthState, handleCallback, getLoginUrlsState, fetchLoginUrls, logout } from "@sanity/sdk";
2
+ import { useContext, useMemo, useSyncExternalStore, useCallback } from "react";
3
+ import { SanityInstanceContext } from "./context.js";
4
+ const useSanityInstance = () => {
5
5
  const sanityInstance = useContext(SanityInstanceContext);
6
6
  if (!sanityInstance)
7
7
  throw new Error("useSanityInstance must be called from within the SanityProvider");
@@ -19,11 +19,6 @@ function createStateSourceHook(stateSourceFactory) {
19
19
  return useHook;
20
20
  }
21
21
  const useAuthState = createStateSourceHook(getAuthState);
22
- function useLoginUrls() {
23
- const instance = useSanityInstance(), { subscribe, getCurrent } = useMemo(() => getLoginUrlsState(instance), [instance]);
24
- if (!getCurrent()) throw fetchLoginUrls(instance);
25
- return useSyncExternalStore(subscribe, getCurrent);
26
- }
27
22
  function createCallbackHook(callback) {
28
23
  function useHook() {
29
24
  const instance = useSanityInstance();
@@ -31,9 +26,14 @@ function createCallbackHook(callback) {
31
26
  }
32
27
  return useHook;
33
28
  }
34
- const useHandleCallback = createCallbackHook(handleCallback), useLogOut = createCallbackHook(logout);
29
+ const useHandleCallback = createCallbackHook(handleCallback);
30
+ function useLoginUrls() {
31
+ const instance = useSanityInstance(), { subscribe, getCurrent } = useMemo(() => getLoginUrlsState(instance), [instance]);
32
+ if (!getCurrent()) throw fetchLoginUrls(instance);
33
+ return useSyncExternalStore(subscribe, getCurrent);
34
+ }
35
+ const useLogOut = createCallbackHook(logout);
35
36
  export {
36
- SanityProvider,
37
37
  createStateSourceHook,
38
38
  useAuthState,
39
39
  useHandleCallback,
@@ -1 +1 @@
1
- {"version":3,"file":"useLogOut.js","sources":["../../src/components/context/SanityProvider.tsx","../../src/hooks/context/useSanityInstance.ts","../../src/hooks/helpers/createStateSourceHook.tsx","../../src/hooks/auth/useAuthState.tsx","../../src/hooks/auth/useLoginUrls.tsx","../../src/hooks/helpers/createCallbackHook.tsx","../../src/hooks/auth/useHandleCallback.tsx","../../src/hooks/auth/useLogOut.tsx"],"sourcesContent":["import {type SanityInstance} from '@sanity/sdk'\nimport {createContext, type ReactElement} from 'react'\n\n/**\n * @public\n */\nexport interface SanityProviderProps {\n children: React.ReactNode\n sanityInstance: SanityInstance\n}\n\nexport const SanityInstanceContext = createContext<SanityInstance | null>(null)\n\n/**\n * Top-level context provider that provides a Sanity configuration instance.\n * This must wrap any Sanity SDK React component.\n * @public\n * @param props - Sanity project and dataset configuration\n * @returns Rendered component\n * @example\n * ```tsx\n * import {createSanityInstance} from '@sanity/sdk'\n * import {ExampleComponent, SanityProvider} from '@sanity/sdk-react'\n *\n * const sanityInstance = createSanityInstance({projectId: 'your-project-id', dataset: 'production'})\n *\n * export default function MyApp() {\n * return (\n * <SanityProvider sanityInstance={sanityInstance}>\n * <ExampleComponent />\n * </SanityProvider>\n * )\n * }\n * ```\n */\nexport const SanityProvider = ({children, sanityInstance}: SanityProviderProps): ReactElement => {\n return (\n <SanityInstanceContext.Provider value={sanityInstance}>\n {children}\n </SanityInstanceContext.Provider>\n )\n}\n","import type {SanityInstance} from '@sanity/sdk'\nimport {useContext} from 'react'\n\nimport {SanityInstanceContext} from '../../components/context/SanityProvider'\n\n/**\n * Hook that provides the current Sanity instance from the context.\n * This must be called from within a `SanityProvider` component.\n * @public\n * @returns the current Sanity instance\n * @example\n * ```tsx\n * const instance = useSanityInstance()\n * ```\n */\nexport const useSanityInstance = (): SanityInstance => {\n const sanityInstance = useContext(SanityInstanceContext)\n if (!sanityInstance) {\n throw new Error('useSanityInstance must be called from within the SanityProvider')\n }\n\n return sanityInstance\n}\n","import type {SanityInstance, StateSource} from '@sanity/sdk'\nimport {useMemo, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\nexport function createStateSourceHook<TParams extends unknown[], TState>(\n stateSourceFactory: (instance: SanityInstance, ...params: TParams) => StateSource<TState>,\n): (...params: TParams) => TState {\n function useHook(...params: TParams) {\n const instance = useSanityInstance()\n const {subscribe, getCurrent} = useMemo(\n () => stateSourceFactory(instance, ...params),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [instance, ...params],\n )\n\n return useSyncExternalStore(subscribe, getCurrent)\n }\n\n return useHook\n}\n","import {getAuthState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * A React hook that subscribes to authentication state changes.\n *\n * This hook provides access to the current authentication state type from the Sanity auth store.\n * It automatically re-renders the component when the authentication state changes.\n *\n * @remarks\n * The hook uses `useSyncExternalStore` to safely subscribe to auth state changes\n * and ensure consistency between server and client rendering.\n *\n * @returns The current authentication state type\n *\n * @example\n * ```tsx\n * function AuthStatus() {\n * const authState = useAuthState()\n * return <div>Current auth state: {authState}</div>\n * }\n * ```\n *\n * @public\n */\nexport const useAuthState = createStateSourceHook(getAuthState)\n","import {type AuthProvider, fetchLoginUrls, getLoginUrlsState} from '@sanity/sdk'\nimport {useMemo, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * A React hook that retrieves the available authentication provider URLs for login.\n *\n * @remarks\n * This hook fetches the login URLs from the Sanity auth store when the component mounts.\n * Each provider object contains information about an authentication method, including its URL.\n * The hook will suspend if the login URLs have not yet loaded.\n *\n * @example\n * ```tsx\n * // LoginProviders component that uses the hook\n * function LoginProviders() {\n * const providers = useLoginUrls()\n *\n * return (\n * <div>\n * {providers.map((provider) => (\n * <a key={provider.name} href={provider.url}>\n * Login with {provider.title}\n * </a>\n * ))}\n * </div>\n * )\n * }\n *\n * // Parent component with Suspense boundary\n * function LoginPage() {\n * return (\n * <Suspense fallback={<div>Loading authentication providers...</div>}>\n * <LoginProviders />\n * </Suspense>\n * )\n * }\n * ```\n *\n * @returns An array of {@link AuthProvider} objects containing login URLs and provider information\n * @public\n */\nexport function useLoginUrls(): AuthProvider[] {\n const instance = useSanityInstance()\n const {subscribe, getCurrent} = useMemo(() => getLoginUrlsState(instance), [instance])\n\n if (!getCurrent()) throw fetchLoginUrls(instance)\n\n return useSyncExternalStore(subscribe, getCurrent as () => AuthProvider[])\n}\n","import type {SanityInstance} from '@sanity/sdk'\nimport {useCallback} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\nexport function createCallbackHook<TParams extends unknown[], TReturn>(\n callback: (instance: SanityInstance, ...params: TParams) => TReturn,\n): () => (...params: TParams) => TReturn {\n function useHook() {\n const instance = useSanityInstance()\n return useCallback((...params: TParams) => callback(instance, ...params), [instance])\n }\n\n return useHook\n}\n","import {handleCallback} from '@sanity/sdk'\n\nimport {createCallbackHook} from '../helpers/createCallbackHook'\n\n/**\n * A React hook that returns a function for handling authentication callbacks.\n *\n * @remarks\n * This hook provides access to the authentication store's callback handler,\n * which processes auth redirects by extracting the session ID and fetching the\n * authentication token. If fetching the long-lived token is successful,\n * `handleCallback` will return a Promise that resolves a new location that\n * removes the short-lived token from the URL. Use this in combination with\n * `history.replaceState` or your own router's `replace` function to update the\n * current location without triggering a reload.\n *\n * @example\n * ```tsx\n * function AuthCallback() {\n * const handleCallback = useHandleCallback()\n * const router = useRouter() // Example router\n *\n * useEffect(() => {\n * async function processCallback() {\n * // Handle the callback and get the cleaned URL\n * const newUrl = await handleCallback(window.location.href)\n *\n * if (newUrl) {\n * // Replace URL without triggering navigation\n * router.replace(newUrl, {shallow: true})\n * }\n * }\n *\n * processCallback().catch(console.error)\n * }, [handleCallback, router])\n *\n * return <div>Completing login...</div>\n * }\n * ```\n *\n * @returns A callback handler function that processes OAuth redirects\n * @public\n */\nexport const useHandleCallback = createCallbackHook(handleCallback)\n","import {logout} from '@sanity/sdk'\n\nimport {createCallbackHook} from '../helpers/createCallbackHook'\n\n/**\n * Hook to log out of the current session\n * @public\n * @returns A function to log out of the current session\n */\nexport const useLogOut = createCallbackHook(logout)\n"],"names":[],"mappings":";;;AAWO,MAAM,wBAAwB,cAAqC,IAAI,GAwBjE,iBAAiB,CAAC,EAAC,UAAU,eAAc,0BAEnD,sBAAsB,UAAtB,EAA+B,OAAO,gBACpC,SACH,CAAA,GCxBS,oBAAoB,MAAsB;AAC/C,QAAA,iBAAiB,WAAW,qBAAqB;AACvD,MAAI,CAAC;AACG,UAAA,IAAI,MAAM,iEAAiE;AAG5E,SAAA;AACT;ACjBO,SAAS,sBACd,oBACgC;AAChC,WAAS,WAAW,QAAiB;AACnC,UAAM,WAAW,kBAAkB,GAC7B,EAAC,WAAW,WAAc,IAAA;AAAA,MAC9B,MAAM,mBAAmB,UAAU,GAAG,MAAM;AAAA;AAAA,MAE5C,CAAC,UAAU,GAAG,MAAM;AAAA,IACtB;AAEO,WAAA,qBAAqB,WAAW,UAAU;AAAA,EAAA;AAG5C,SAAA;AACT;ACMa,MAAA,eAAe,sBAAsB,YAAY;ACiBvD,SAAS,eAA+B;AAC7C,QAAM,WAAW,qBACX,EAAC,WAAW,WAAU,IAAI,QAAQ,MAAM,kBAAkB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAErF,MAAI,CAAC,WAAA,EAAc,OAAM,eAAe,QAAQ;AAEzC,SAAA,qBAAqB,WAAW,UAAkC;AAC3E;AC7CO,SAAS,mBACd,UACuC;AACvC,WAAS,UAAU;AACjB,UAAM,WAAW,kBAAkB;AAC5B,WAAA,YAAY,IAAI,WAAoB,SAAS,UAAU,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC;AAAA,EAAA;AAG/E,SAAA;AACT;AC6Ba,MAAA,oBAAoB,mBAAmB,cAAc,GClCrD,YAAY,mBAAmB,MAAM;"}
1
+ {"version":3,"file":"useLogOut.js","sources":["../../src/hooks/context/useSanityInstance.ts","../../src/hooks/helpers/createStateSourceHook.tsx","../../src/hooks/auth/useAuthState.tsx","../../src/hooks/helpers/createCallbackHook.tsx","../../src/hooks/auth/useHandleCallback.tsx","../../src/hooks/auth/useLoginUrls.tsx","../../src/hooks/auth/useLogOut.tsx"],"sourcesContent":["import {type SanityInstance} from '@sanity/sdk'\nimport {useContext} from 'react'\n\nimport {SanityInstanceContext} from '../../context/SanityProvider'\n\n/**\n * Hook that provides the current Sanity instance from the context.\n * This must be called from within a `SanityProvider` component.\n * @public\n * @returns the current Sanity instance\n * @example\n * ```tsx\n * const instance = useSanityInstance()\n * ```\n */\nexport const useSanityInstance = (): SanityInstance => {\n const sanityInstance = useContext(SanityInstanceContext)\n if (!sanityInstance) {\n throw new Error('useSanityInstance must be called from within the SanityProvider')\n }\n\n return sanityInstance\n}\n","import {type SanityInstance, type StateSource} from '@sanity/sdk'\nimport {useMemo, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\nexport function createStateSourceHook<TParams extends unknown[], TState>(\n stateSourceFactory: (instance: SanityInstance, ...params: TParams) => StateSource<TState>,\n): (...params: TParams) => TState {\n function useHook(...params: TParams) {\n const instance = useSanityInstance()\n const {subscribe, getCurrent} = useMemo(\n () => stateSourceFactory(instance, ...params),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [instance, ...params],\n )\n\n return useSyncExternalStore(subscribe, getCurrent)\n }\n\n return useHook\n}\n","import {getAuthState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * A React hook that subscribes to authentication state changes.\n *\n * This hook provides access to the current authentication state type from the Sanity auth store.\n * It automatically re-renders the component when the authentication state changes.\n *\n * @remarks\n * The hook uses `useSyncExternalStore` to safely subscribe to auth state changes\n * and ensure consistency between server and client rendering.\n *\n * @returns The current authentication state type\n *\n * @example\n * ```tsx\n * function AuthStatus() {\n * const authState = useAuthState()\n * return <div>Current auth state: {authState}</div>\n * }\n * ```\n *\n * @public\n */\nexport const useAuthState = createStateSourceHook(getAuthState)\n","import {type SanityInstance} from '@sanity/sdk'\nimport {useCallback} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\nexport function createCallbackHook<TParams extends unknown[], TReturn>(\n callback: (instance: SanityInstance, ...params: TParams) => TReturn,\n): () => (...params: TParams) => TReturn {\n function useHook() {\n const instance = useSanityInstance()\n return useCallback((...params: TParams) => callback(instance, ...params), [instance])\n }\n\n return useHook\n}\n","import {handleCallback} from '@sanity/sdk'\n\nimport {createCallbackHook} from '../helpers/createCallbackHook'\n\n/**\n * A React hook that returns a function for handling authentication callbacks.\n *\n * @remarks\n * This hook provides access to the authentication store's callback handler,\n * which processes auth redirects by extracting the session ID and fetching the\n * authentication token. If fetching the long-lived token is successful,\n * `handleCallback` will return a Promise that resolves a new location that\n * removes the short-lived token from the URL. Use this in combination with\n * `history.replaceState` or your own router's `replace` function to update the\n * current location without triggering a reload.\n *\n * @example\n * ```tsx\n * function AuthCallback() {\n * const handleCallback = useHandleCallback()\n * const router = useRouter() // Example router\n *\n * useEffect(() => {\n * async function processCallback() {\n * // Handle the callback and get the cleaned URL\n * const newUrl = await handleCallback(window.location.href)\n *\n * if (newUrl) {\n * // Replace URL without triggering navigation\n * router.replace(newUrl, {shallow: true})\n * }\n * }\n *\n * processCallback().catch(console.error)\n * }, [handleCallback, router])\n *\n * return <div>Completing login...</div>\n * }\n * ```\n *\n * @returns A callback handler function that processes OAuth redirects\n * @public\n */\nexport const useHandleCallback = createCallbackHook(handleCallback)\n","import {type AuthProvider, fetchLoginUrls, getLoginUrlsState} from '@sanity/sdk'\nimport {useMemo, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * A React hook that retrieves the available authentication provider URLs for login.\n *\n * @remarks\n * This hook fetches the login URLs from the Sanity auth store when the component mounts.\n * Each provider object contains information about an authentication method, including its URL.\n * The hook will suspend if the login URLs have not yet loaded.\n *\n * @example\n * ```tsx\n * // LoginProviders component that uses the hook\n * function LoginProviders() {\n * const providers = useLoginUrls()\n *\n * return (\n * <div>\n * {providers.map((provider) => (\n * <a key={provider.name} href={provider.url}>\n * Login with {provider.title}\n * </a>\n * ))}\n * </div>\n * )\n * }\n *\n * // Parent component with Suspense boundary\n * function LoginPage() {\n * return (\n * <Suspense fallback={<div>Loading authentication providers...</div>}>\n * <LoginProviders />\n * </Suspense>\n * )\n * }\n * ```\n *\n * @returns An array of {@link AuthProvider} objects containing login URLs and provider information\n * @public\n */\nexport function useLoginUrls(): AuthProvider[] {\n const instance = useSanityInstance()\n const {subscribe, getCurrent} = useMemo(() => getLoginUrlsState(instance), [instance])\n\n if (!getCurrent()) throw fetchLoginUrls(instance)\n\n return useSyncExternalStore(subscribe, getCurrent as () => AuthProvider[])\n}\n","import {logout} from '@sanity/sdk'\n\nimport {createCallbackHook} from '../helpers/createCallbackHook'\n\n/**\n * Hook to log out of the current session\n * @public\n * @returns A function to log out of the current session\n */\nexport const useLogOut = createCallbackHook(logout)\n"],"names":[],"mappings":";;;AAeO,MAAM,oBAAoB,MAAsB;AAC/C,QAAA,iBAAiB,WAAW,qBAAqB;AACvD,MAAI,CAAC;AACG,UAAA,IAAI,MAAM,iEAAiE;AAG5E,SAAA;AACT;ACjBO,SAAS,sBACd,oBACgC;AAChC,WAAS,WAAW,QAAiB;AACnC,UAAM,WAAW,kBAAkB,GAC7B,EAAC,WAAW,WAAc,IAAA;AAAA,MAC9B,MAAM,mBAAmB,UAAU,GAAG,MAAM;AAAA;AAAA,MAE5C,CAAC,UAAU,GAAG,MAAM;AAAA,IACtB;AAEO,WAAA,qBAAqB,WAAW,UAAU;AAAA,EAAA;AAG5C,SAAA;AACT;ACMa,MAAA,eAAe,sBAAsB,YAAY;ACrBvD,SAAS,mBACd,UACuC;AACvC,WAAS,UAAU;AACjB,UAAM,WAAW,kBAAkB;AAC5B,WAAA,YAAY,IAAI,WAAoB,SAAS,UAAU,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC;AAAA,EAAA;AAG/E,SAAA;AACT;AC6Ba,MAAA,oBAAoB,mBAAmB,cAAc;ACA3D,SAAS,eAA+B;AAC7C,QAAM,WAAW,qBACX,EAAC,WAAW,WAAU,IAAI,QAAQ,MAAM,kBAAkB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAErF,MAAI,CAAC,WAAA,EAAc,OAAM,eAAe,QAAQ;AAEzC,SAAA,qBAAqB,WAAW,UAAkC;AAC3E;ACzCa,MAAA,YAAY,mBAAmB,MAAM;"}
@@ -1,10 +1,6 @@
1
1
  import {FallbackProps} from 'react-error-boundary'
2
- import {ForwardRefExoticComponent} from 'react'
3
2
  import {JSX} from 'react'
4
- import type {PropsWithChildren} from 'react'
5
- import {ReactElement} from 'react'
6
- import {RefAttributes} from 'react'
7
- import {SanityInstance} from '@sanity/sdk'
3
+ import {SanityConfig} from '@sanity/sdk'
8
4
 
9
5
  /**
10
6
  * A component that handles authentication flow and error boundaries for a
@@ -35,7 +31,7 @@ export declare function AuthBoundary({
35
31
  /**
36
32
  * @alpha
37
33
  */
38
- export declare interface AuthBoundaryProps extends LoginLayoutProps {
34
+ declare interface AuthBoundaryProps extends LoginLayoutProps {
39
35
  /**
40
36
  * Custom component to render the login screen.
41
37
  * Receives all login layout props. Defaults to {@link Login}.
@@ -54,144 +50,15 @@ export declare interface AuthBoundaryProps extends LoginLayoutProps {
54
50
  LoginErrorComponent?: React.ComponentType<LoginErrorProps>
55
51
  }
56
52
 
57
- /**
58
- * Error class for authentication-related errors. Wraps errors thrown during the
59
- * authentication flow.
60
- *
61
- * @remarks
62
- * This class provides a consistent error type for authentication failures while
63
- * preserving the original error as the cause. If the original error has a
64
- * message property, it will be used as the error message.
65
- *
66
- * @alpha
67
- */
68
- export declare class AuthError extends Error {
69
- constructor(error: unknown)
70
- }
71
-
72
- /**
73
- * @public
74
- */
75
- export declare const DocumentGridLayout: {
76
- (props: PropsWithChildren): ReactElement
77
- displayName: string
78
- }
79
-
80
- /**
81
- * @public
82
- */
83
- export declare const DocumentListLayout: {
84
- (props: PropsWithChildren): ReactElement
85
- displayName: string
86
- }
87
-
88
- /**
89
- * This is a component that renders a document preview.
90
- *
91
- * @public
92
- *
93
- * @param props - The props for the DocumentPreviewLayout component.
94
- * @returns - The DocumentPreviewLayout component.
95
- */
96
- export declare const DocumentPreviewLayout: ForwardRefExoticComponent<
97
- DocumentPreviewLayoutProps & RefAttributes<HTMLElement>
98
- >
99
-
100
- /**
101
- * @public
102
- */
103
- export declare interface DocumentPreviewLayoutProps {
104
- docType?: string
105
- media?:
106
- | {
107
- type: string
108
- url: string
109
- }
110
- | null
111
- | undefined
112
- onClick?: () => void
113
- selected?: boolean
114
- status?: string
115
- subtitle?: string
116
- title: string
117
- }
118
-
119
- /**
120
- * Login component that displays available authentication providers.
121
- * Renders a list of login options with a loading fallback while providers load.
122
- *
123
- * @alpha
124
- */
125
- export declare function Login({header, footer}: LoginLayoutProps): JSX.Element
126
-
127
- /**
128
- /**
129
- * Component shown during auth callback processing that handles login completion.
130
- * Automatically processes the auth callback when mounted and updates the URL
131
- * to remove callback parameters without triggering a page reload.
132
- *
133
- * @alpha
134
- */
135
- export declare function LoginCallback({header, footer}: LoginLayoutProps): React.ReactNode
136
-
137
- /**
138
- * Displays authentication error details and provides retry functionality.
139
- * Only handles {@link AuthError} instances - rethrows other error types.
140
- *
141
- * @alpha
142
- */
143
- export declare function LoginError({
144
- error,
145
- resetErrorBoundary,
146
- header,
147
- footer,
148
- }: LoginErrorProps): React.ReactNode
149
-
150
53
  /**
151
54
  * @alpha
152
55
  */
153
- export declare type LoginErrorProps = FallbackProps & LoginLayoutProps
154
-
155
- /**
156
- * Layout component for login-related screens providing consistent styling and structure.
157
- * Renders content in a centered card with optional header and footer sections.
158
- *
159
- * Can be used to build custom login screens for the AuthBoundary component, including:
160
- * - Login provider selection (LoginComponent)
161
- * - OAuth callback handling (CallbackComponent)
162
- * - Error states (LoginErrorComponent)
163
- *
164
- * @example
165
- * ```tsx
166
- * // Custom login screen using the layout
167
- * function CustomLogin({header, footer}: LoginLayoutProps) {
168
- * return (
169
- * <LoginLayout
170
- * header={header}
171
- * footer={footer}
172
- * >
173
- * <CustomLoginContent />
174
- * </LoginLayout>
175
- * )
176
- * }
177
- *
178
- * // Use with AuthBoundary
179
- * <AuthBoundary
180
- * LoginComponent={CustomLogin}
181
- * header={<Logo />}
182
- * >
183
- * <ProtectedContent />
184
- * </AuthBoundary>
185
- * ```
186
- *
187
- * @alpha
188
- */
189
- export declare function LoginLayout({children, footer, header}: LoginLayoutProps): React.ReactNode
56
+ declare type LoginErrorProps = FallbackProps & LoginLayoutProps
190
57
 
191
58
  /**
192
59
  * @alpha
193
60
  */
194
- export declare interface LoginLayoutProps {
61
+ declare interface LoginLayoutProps {
195
62
  /** Optional header content rendered at top of card */
196
63
  header?: React.ReactNode
197
64
  /** Optional footer content rendered below card. Defaults to an internal login footer */
@@ -201,59 +68,16 @@ export declare interface LoginLayoutProps {
201
68
  }
202
69
 
203
70
  /**
204
- * Component that handles Sanity authentication flow and renders login provider options
205
- *
206
71
  * @public
207
72
  *
208
- * @returns Rendered component
209
- *
210
- * @remarks
211
- * The component handles three states:
212
- * 1. Loading state during token exchange
213
- * 2. Success state after successful authentication
214
- * 3. Provider selection UI when not authenticated
215
- *
216
- * @example
217
- * ```tsx
218
- * const config = { projectId: 'your-project-id', dataset: 'production' }
219
- * return <LoginLinks sanityInstance={config} />
220
- * ```
221
- */
222
- export declare const LoginLinks: () => ReactElement
223
-
224
- /**
225
- * Top-level context provider that provides a Sanity configuration instance.
226
- * This must wrap any Sanity SDK React component.
227
- * @public
228
- * @param props - Sanity project and dataset configuration
229
- * @returns Rendered component
230
- * @example
231
- * ```tsx
232
- * import {createSanityInstance} from '@sanity/sdk'
233
- * import {ExampleComponent, SanityProvider} from '@sanity/sdk-react'
234
- *
235
- * const sanityInstance = createSanityInstance({projectId: 'your-project-id', dataset: 'production'})
236
- *
237
- * export default function MyApp() {
238
- * return (
239
- * <SanityProvider sanityInstance={sanityInstance}>
240
- * <ExampleComponent />
241
- * </SanityProvider>
242
- * )
243
- * }
244
- * ```
73
+ * @returns Rendered child component wrapped in a SanityProvider and AuthBoundary
245
74
  */
246
- export declare const SanityProvider: ({
75
+ export declare function SanityApp({
76
+ sanityConfig,
247
77
  children,
248
- sanityInstance,
249
- }: SanityProviderProps) => ReactElement
250
-
251
- /**
252
- * @public
253
- */
254
- export declare interface SanityProviderProps {
78
+ }: {
255
79
  children: React.ReactNode
256
- sanityInstance: SanityInstance
257
- }
80
+ sanityConfig: SanityConfig
81
+ }): JSX.Element
258
82
 
259
83
  export {}
@@ -1,12 +1,10 @@
1
- import { jsxs, jsx, Fragment as Fragment$1 } from "react/jsx-runtime";
2
- import { AuthStateType } from "@sanity/sdk";
3
- import { Fragment, Suspense, useEffect, useCallback, useMemo, forwardRef } from "react";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { AuthStateType, createSanityInstance } from "@sanity/sdk";
3
+ import { Fragment, Suspense, useEffect, useCallback, useMemo } from "react";
4
4
  import { ErrorBoundary } from "react-error-boundary";
5
5
  import { useLoginUrls, useHandleCallback, useLogOut, useAuthState } from "./_chunks-es/useLogOut.js";
6
- import { SanityProvider } from "./_chunks-es/useLogOut.js";
7
- import { Flex, Text, Card, Heading, Spinner, Button, Container, Stack } from "@sanity/ui";
8
6
  import { SanityLogo } from "@sanity/logos";
9
- import { DocumentIcon } from "@sanity/icons";
7
+ import { SanityProvider } from "./_chunks-es/context.js";
10
8
  class AuthError extends Error {
11
9
  constructor(error) {
12
10
  typeof error == "object" && error && "message" in error && typeof error.message == "string" ? super(error.message) : super(), this.cause = error;
@@ -35,21 +33,9 @@ const LINKS = [
35
33
  }
36
34
  ];
37
35
  function LoginFooter() {
38
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, justify: "center", align: "center", paddingTop: 2, children: [
39
- /* @__PURE__ */ jsx(Text, { size: 3, children: /* @__PURE__ */ jsx(SanityLogo, {}) }),
40
- /* @__PURE__ */ jsx(Flex, { align: "center", gap: 2, children: LINKS.map((link, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
41
- /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsx(
42
- "a",
43
- {
44
- href: link.url,
45
- target: "_blank",
46
- rel: "noopener noreferrer",
47
- style: { color: "inherit" },
48
- children: link.title
49
- }
50
- ) }),
51
- index < LINKS.length - 1 && /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "\u2022" })
52
- ] }, link.title)) })
36
+ return /* @__PURE__ */ jsxs("div", { className: "sc-login-footer", children: [
37
+ /* @__PURE__ */ jsx(SanityLogo, { className: "sc-login-footer__logo" }),
38
+ /* @__PURE__ */ jsx("ul", { className: "sc-login-footer__links", children: LINKS.map((link) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("li", { className: "sc-login-footer__link", children: /* @__PURE__ */ jsx("a", { href: link.url, target: "_blank", rel: "noopener noreferrer", children: link.title }) }) }, link.title)) })
53
39
  ] });
54
40
  }
55
41
  function LoginLayout({
@@ -57,29 +43,23 @@ function LoginLayout({
57
43
  footer = /* @__PURE__ */ jsx(LoginFooter, {}),
58
44
  header
59
45
  }) {
60
- return /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "flex" }, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, style: { width: "320px", margin: "auto", display: "flex" }, children: [
61
- /* @__PURE__ */ jsx(Card, { border: !0, radius: 2, paddingY: 4, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
62
- header && /* @__PURE__ */ jsx(Card, { borderBottom: !0, paddingX: 4, paddingBottom: 3, children: header }),
63
- children && /* @__PURE__ */ jsx(Flex, { paddingX: 4, direction: "column", style: { minHeight: "154px" }, children })
64
- ] }) }),
46
+ return /* @__PURE__ */ jsx("div", { className: "sc-login-layout", children: /* @__PURE__ */ jsxs("div", { className: "sc-login-layout__container", children: [
47
+ /* @__PURE__ */ jsxs("div", { className: "sc-login-layout__card", children: [
48
+ header && /* @__PURE__ */ jsx("div", { className: "sc-login-layout__card-header", children: header }),
49
+ children && /* @__PURE__ */ jsx("div", { className: "sc-login-layout__card-body", children })
50
+ ] }),
65
51
  footer
66
52
  ] }) });
67
53
  }
68
54
  function Login({ header, footer }) {
69
- return /* @__PURE__ */ jsx(LoginLayout, { header, footer, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
70
- /* @__PURE__ */ jsx(Heading, { as: "h1", size: 1, align: "center", children: "Choose login provider" }),
71
- /* @__PURE__ */ jsx(
72
- Suspense,
73
- {
74
- fallback: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", style: { height: "123px" }, children: /* @__PURE__ */ jsx(Spinner, {}) }),
75
- children: /* @__PURE__ */ jsx(Providers, {})
76
- }
77
- )
55
+ return /* @__PURE__ */ jsx(LoginLayout, { header, footer, children: /* @__PURE__ */ jsxs("div", { className: "sc-login", children: [
56
+ /* @__PURE__ */ jsx("h1", { className: "sc-login__title", children: "Choose login provider" }),
57
+ /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { className: "sc-login__loading", children: "Loading\u2026" }), children: /* @__PURE__ */ jsx(Providers, {}) })
78
58
  ] }) });
79
59
  }
80
60
  function Providers() {
81
61
  const loginUrls = useLoginUrls();
82
- return /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 3, children: loginUrls.map(({ title, url }) => /* @__PURE__ */ jsx(Button, { text: title, as: "a", href: url, mode: "ghost" }, url)) });
62
+ return /* @__PURE__ */ jsx("div", { className: "sc-login-providers", children: loginUrls.map(({ title, url }) => /* @__PURE__ */ jsx("a", { href: url, children: title }, url)) });
83
63
  }
84
64
  function LoginCallback({ header, footer }) {
85
65
  const handleCallback = useHandleCallback();
@@ -88,9 +68,9 @@ function LoginCallback({ header, footer }) {
88
68
  handleCallback(url.toString()).then((replacementLocation) => {
89
69
  replacementLocation && history.replaceState(null, "", replacementLocation);
90
70
  });
91
- }, [handleCallback]), /* @__PURE__ */ jsx(LoginLayout, { header, footer, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", justify: "center", align: "center", gap: 4, style: { margin: "auto" }, children: [
92
- /* @__PURE__ */ jsx(Text, { size: 1, children: "Logging you in\u2026" }),
93
- /* @__PURE__ */ jsx(Spinner, { size: 4 })
71
+ }, [handleCallback]), /* @__PURE__ */ jsx(LoginLayout, { header, footer, children: /* @__PURE__ */ jsxs("div", { className: "sc-login-callback", children: [
72
+ /* @__PURE__ */ jsx("h1", { className: "sc-login-callback__title", children: "Logging you in\u2026" }),
73
+ /* @__PURE__ */ jsx("div", { className: "sc-login-callback__loading", children: "Loading\u2026" })
94
74
  ] }) });
95
75
  }
96
76
  function LoginError({
@@ -103,12 +83,12 @@ function LoginError({
103
83
  const logout = useLogOut(), handleRetry = useCallback(async () => {
104
84
  await logout(), resetErrorBoundary();
105
85
  }, [logout, resetErrorBoundary]);
106
- return /* @__PURE__ */ jsx(LoginLayout, { header, footer, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, style: { margin: "auto" }, children: [
107
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, children: [
108
- /* @__PURE__ */ jsx(Text, { as: "h2", align: "center", weight: "bold", size: 3, children: "Authentication Error" }),
109
- /* @__PURE__ */ jsx(Text, { size: 1, align: "center", children: "Please try again or contact support if the problem persists." })
86
+ return /* @__PURE__ */ jsx(LoginLayout, { header, footer, children: /* @__PURE__ */ jsxs("div", { className: "sc-login-error", children: [
87
+ /* @__PURE__ */ jsxs("div", { className: "sc-login-error__content", children: [
88
+ /* @__PURE__ */ jsx("h2", { className: "sc-login-error__title", children: "Authentication Error" }),
89
+ /* @__PURE__ */ jsx("p", { className: "sc-login-error__description", children: "Please try again or contact support if the problem persists." })
110
90
  ] }),
111
- /* @__PURE__ */ jsx(Button, { text: "Retry", tone: "primary", onClick: handleRetry })
91
+ /* @__PURE__ */ jsx("button", { className: "sc-login-error__button", onClick: handleRetry, children: "Retry" })
112
92
  ] }) });
113
93
  }
114
94
  function AuthBoundary({
@@ -138,164 +118,15 @@ function AuthSwitch({
138
118
  return /* @__PURE__ */ jsx(LoginComponent, { ...props });
139
119
  }
140
120
  }
141
- const DocumentGridLayout = (props) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
142
- /* @__PURE__ */ jsx("style", { children: `
143
- .DocumentGridLayout {
144
- grid-template-columns: repeat(auto-fit, minmax(38ch, 1fr));
145
- }
146
- ` }),
147
- /* @__PURE__ */ jsx("ol", { className: "DocumentGridLayout list-none grid", children: props.children })
148
- ] });
149
- DocumentGridLayout.displayName = "DocumentGridLayout";
150
- const DocumentListLayout = (props) => /* @__PURE__ */ jsx("ol", { className: "DocumentListLayout list-none", children: props.children });
151
- DocumentListLayout.displayName = "DocumentListLayout";
152
- const DocumentPreviewLayout = forwardRef(
153
- ({
154
- docType,
155
- media,
156
- onClick,
157
- selected = !1,
158
- status = "",
159
- subtitle = "",
160
- title
161
- }, ref) => {
162
- if (!title)
163
- return /* @__PURE__ */ jsx(Fragment$1, {});
164
- let PreviewMedia;
165
- if (media?.url) {
166
- const baseUrl = new URL(media.url);
167
- baseUrl.searchParams.set("h", "66"), baseUrl.searchParams.set("w", "66"), baseUrl.searchParams.set("fit", "crop");
168
- const mediaUrl = baseUrl.toString();
169
- PreviewMedia = /* @__PURE__ */ jsx("img", { src: mediaUrl, alt: "" });
170
- } else
171
- PreviewMedia = /* @__PURE__ */ jsx(DocumentIcon, {});
172
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
173
- /* @__PURE__ */ jsx("style", { children: `
174
- .DocumentPreviewLayout {
175
- --_hoverFocusBg: light-dark(var(--shade-11), var(--tint-1));
176
- --_selectedBg: light-dark(var(--blue-10), var(--blue-2));
177
- --_selectedFg: light-dark(var(--gray-1), var(--gray-10));
178
- --_titleFg: light-dark(var(--gray-1), var(--gray-10));
179
- --_subtitleFg: light-dark(var(--gray-4), var(--gray-7));
180
- --_docTypeFg: light-dark(var(--gray-1), var(--gray-10));
181
- --_docTypeBg: light-dark(var(--shade-10), var(--tint-1));
182
- --_publishedFg: light-dark(var(--gray-1), var(--gray-10));
183
- --_publishedBg: light-dark(var(--green-10), var(--green-2));
184
- --_draftFg: light-dark(var(--gray-1), var(--gray-10));
185
- --_draftBg: light-dark(var(--yellow-6), var(--yellow-2));
186
-
187
- appearance: none;
188
-
189
- &:has(:hover, focus) {
190
- background-color: var(--hoverFocusBg, var(--_hoverFocusBg));
191
- }
192
-
193
- &.selected {
194
- background-color: var(--selectedBg, var(--_selectedBg));
195
- color: var(--selectedFg, var(--_selectedFg));
196
- }
197
-
198
- .Title {
199
- color: var(--titleFg, var(--_titleFg));
200
- }
201
-
202
- &:not(.selected) .Subtitle {
203
- color: var(--subtitleFg, var(--_subtitleFg));
204
- }
205
-
206
- .Media {
207
- aspect-ratio: 1;
208
- inline-size: 33px;
209
- border-color: var(--gray-8);
210
- }
211
-
212
- .DocType {
213
- color: var(--docTypeFg, var(--_docTypeFg));
214
- background-color: var(--docTypeBg, var(--_docTypeBg));
215
- }
216
-
217
- .Published {
218
- color: var(--publishedFg, var(--_publishedFg));
219
- background-color: var(--publishedBg, var(--_publishedBg));
220
- }
221
-
222
- .Draft {
223
- color: var(--draftFg, var(--_draftFg));
224
- background-color: var(--draftBg, var(--_draftBg));
225
- }
226
-
227
- :is(.Published, .Draft) figcaption {
228
- @container (width < 52ch) {
229
- clip: rect(0 0 0 0);
230
- clip-path: inset(50%);
231
- height: 1px;
232
- overflow: hidden;
233
- position: absolute;
234
- white-space: nowrap;
235
- width: 1px;
236
- }
237
- }
238
-
239
- }
240
- ` }),
241
- /* @__PURE__ */ jsx(
242
- "button",
243
- {
244
- onClick,
245
- ref,
246
- className: `DocumentPreviewLayout block si-100 text-start p-1 radius1 ${selected ? "selected" : ""}`,
247
- children: /* @__PURE__ */ jsxs("div", { className: "container-inline flex align-items-center gap-2 font-sans", children: [
248
- /* @__PURE__ */ jsx("figure", { className: "Media border0 border-solid flex-none flex align-items-center justify-content-center object-cover", children: PreviewMedia }),
249
- /* @__PURE__ */ jsxs("div", { className: "leading2 flex-grow overflow-hidden", children: [
250
- /* @__PURE__ */ jsx("p", { className: "Title text-1 font-medium truncate", children: title }),
251
- subtitle && /* @__PURE__ */ jsx("p", { className: "Subtitle text-1 truncate", children: subtitle })
252
- ] }),
253
- docType && /* @__PURE__ */ jsx("figure", { className: "DocType inline-block pb-5 pi-3 radius-pill text-2", children: /* @__PURE__ */ jsx("figcaption", { className: "inline", children: docType }) }),
254
- status === "published" && /* @__PURE__ */ jsxs("figure", { className: "Published inline-block pb-5 pi-3 radius-pill text-2", children: [
255
- "\u2714\uFE0E ",
256
- /* @__PURE__ */ jsx("figcaption", { className: "inline", children: "published" })
257
- ] }),
258
- status === "draft" && /* @__PURE__ */ jsxs("figure", { className: "Draft inline-block pb-5 pi-3 radius-pill text-2", children: [
259
- "\u26D1\uFE0E ",
260
- /* @__PURE__ */ jsx("figcaption", { className: "inline", children: "draft" })
261
- ] })
262
- ] })
263
- }
264
- )
265
- ] });
266
- }
267
- );
268
- DocumentPreviewLayout.displayName = "DocumentPreviewLayout";
269
- const LoginLinks = () => {
270
- const loginUrls = useLoginUrls(), authState = useAuthState();
271
- return useHandleCallback(), authState.type === "logging-in" ? /* @__PURE__ */ jsx("div", { children: "Logging in..." }) : authState.type === "logged-in" ? /* @__PURE__ */ jsx("div", { children: "You are logged in" }) : /* @__PURE__ */ jsx(Card, { height: "fill", overflow: "auto", paddingX: 4, children: /* @__PURE__ */ jsx(Flex, { height: "fill", direction: "column", align: "center", justify: "center", paddingTop: 4, children: /* @__PURE__ */ jsx(Container, { width: 0, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
272
- /* @__PURE__ */ jsx(Heading, { align: "center", size: 1, children: "Choose login provider" }),
273
- /* @__PURE__ */ jsx(Stack, { space: 2, children: loginUrls.map((provider, index) => /* @__PURE__ */ jsx(
274
- Button,
275
- {
276
- as: "a",
277
- href: provider.url,
278
- mode: "ghost",
279
- tone: "default",
280
- space: 3,
281
- padding: 3,
282
- text: provider.title
283
- },
284
- `${provider.url}_${index}`
285
- )) })
286
- ] }) }) }) });
287
- };
121
+ function SanityApp({
122
+ sanityConfig,
123
+ children
124
+ }) {
125
+ const sanityInstance = createSanityInstance(sanityConfig);
126
+ return /* @__PURE__ */ jsx(SanityProvider, { sanityInstance, children: /* @__PURE__ */ jsx(AuthBoundary, { children }) });
127
+ }
288
128
  export {
289
129
  AuthBoundary,
290
- AuthError,
291
- DocumentGridLayout,
292
- DocumentListLayout,
293
- DocumentPreviewLayout,
294
- Login,
295
- LoginCallback,
296
- LoginError,
297
- LoginLayout,
298
- LoginLinks,
299
- SanityProvider
130
+ SanityApp
300
131
  };
301
132
  //# sourceMappingURL=components.js.map