next-sanity 4.2.1-dev.0 → 4.2.1
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.
- package/README.md +31 -41
- package/dist/_chunks/{NextStudioLoading-8cf56cdf.js → NextStudioLoading-2003f32a.js} +4 -4
- package/dist/_chunks/NextStudioLoading-2003f32a.js.map +1 -0
- package/dist/_chunks/{NextStudioLoading-bf57e61a.cjs → NextStudioLoading-225bb240.cjs} +4 -4
- package/dist/_chunks/NextStudioLoading-225bb240.cjs.map +1 -0
- package/dist/index.cjs +6 -16
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -24
- package/dist/index.js +1 -17
- package/dist/index.js.map +1 -1
- package/dist/studio/head.cjs.map +1 -1
- package/dist/studio/head.d.ts +1 -2
- package/dist/studio/head.js.map +1 -1
- package/dist/studio/index.cjs +33 -16
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/index.d.ts +19 -3
- package/dist/studio/index.js +35 -19
- package/dist/studio/index.js.map +1 -1
- package/dist/studio/loading.cjs +1 -1
- package/dist/studio/loading.d.ts +4 -3
- package/dist/studio/loading.js +1 -1
- package/dist/studio/metadata.cjs +13 -0
- package/dist/studio/metadata.cjs.js +5 -0
- package/dist/studio/metadata.cjs.map +1 -0
- package/dist/studio/metadata.d.ts +43 -0
- package/dist/studio/metadata.js +8 -0
- package/dist/studio/metadata.js.map +1 -0
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +29 -14
- package/src/client.ts +1 -36
- package/src/studio/NextStudio.tsx +47 -19
- package/src/studio/NextStudioLayout.tsx +1 -1
- package/src/studio/NextStudioLoading.tsx +11 -4
- package/src/studio/head/NextStudioHead.tsx +1 -0
- package/src/studio/metadata.ts +44 -0
- package/dist/_chunks/NextStudioLoading-8cf56cdf.js.map +0 -1
- package/dist/_chunks/NextStudioLoading-bf57e61a.cjs.map +0 -1
|
@@ -3,9 +3,10 @@ import {Studio, type StudioProps} from 'sanity'
|
|
|
3
3
|
|
|
4
4
|
import {NextStudioClientOnly} from './NextStudioClientOnly'
|
|
5
5
|
import {NextStudioLayout} from './NextStudioLayout'
|
|
6
|
-
import {NextStudioLoading
|
|
6
|
+
import {NextStudioLoading} from './NextStudioLoading'
|
|
7
|
+
import {NextStudioNoScript} from './NextStudioNoScript'
|
|
7
8
|
|
|
8
|
-
export type {NextStudioLoadingProps}
|
|
9
|
+
export type {NextStudioLoadingProps} from './NextStudioLoading'
|
|
9
10
|
|
|
10
11
|
/** @beta */
|
|
11
12
|
export interface NextStudioProps extends StudioProps {
|
|
@@ -15,7 +16,13 @@ export interface NextStudioProps extends StudioProps {
|
|
|
15
16
|
* @defaultValue true
|
|
16
17
|
* @alpha
|
|
17
18
|
*/
|
|
18
|
-
unstable__noScript?:
|
|
19
|
+
unstable__noScript?: boolean
|
|
20
|
+
/**
|
|
21
|
+
* Render in a faster mode that requires `styled-components` SSR to be setup.
|
|
22
|
+
* @defaultValue false
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
25
|
+
unstable__fastRender?: boolean
|
|
19
26
|
}
|
|
20
27
|
/**
|
|
21
28
|
* Intended to render at the root of a page, letting the Studio own that page and render much like it would if you used `npx sanity start` to render
|
|
@@ -24,24 +31,45 @@ export interface NextStudioProps extends StudioProps {
|
|
|
24
31
|
const NextStudioComponent = ({
|
|
25
32
|
children,
|
|
26
33
|
config,
|
|
27
|
-
unstable__noScript,
|
|
34
|
+
unstable__noScript = true,
|
|
35
|
+
unstable__fastRender,
|
|
28
36
|
scheme,
|
|
29
37
|
...props
|
|
30
|
-
}: NextStudioProps) =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
config={config}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
}: NextStudioProps) => {
|
|
39
|
+
if (unstable__fastRender) {
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{unstable__noScript && <NextStudioNoScript />}
|
|
43
|
+
<NextStudioLayout config={config} scheme={scheme}>
|
|
44
|
+
{children || (
|
|
45
|
+
<Studio config={config} scheme={scheme} unstable_globalStyles {...props} />
|
|
46
|
+
)}
|
|
47
|
+
</NextStudioLayout>
|
|
48
|
+
</>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{unstable__noScript && <NextStudioNoScript />}
|
|
55
|
+
<NextStudioClientOnly
|
|
56
|
+
fallback={
|
|
57
|
+
<NextStudioLoading
|
|
58
|
+
unstable__noScript={unstable__noScript}
|
|
59
|
+
config={config}
|
|
60
|
+
scheme={scheme}
|
|
61
|
+
/>
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
<NextStudioLayout config={config} scheme={scheme}>
|
|
65
|
+
{children || (
|
|
66
|
+
<Studio config={config} scheme={scheme} unstable_globalStyles {...props} />
|
|
67
|
+
)}
|
|
68
|
+
</NextStudioLayout>
|
|
69
|
+
</NextStudioClientOnly>
|
|
70
|
+
</>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
45
73
|
|
|
46
74
|
/**
|
|
47
75
|
* Override how the Studio renders by passing children.
|
|
@@ -35,7 +35,7 @@ const NextStudioLayoutComponent = ({
|
|
|
35
35
|
<Layout
|
|
36
36
|
data-ui="NextStudioLayout"
|
|
37
37
|
$fontFamily={theme.fonts.text.family}
|
|
38
|
-
$bg={theme.color[scheme].default.base.bg}
|
|
38
|
+
$bg={theme.color[scheme === 'dark' ? 'dark' : 'light'].default.base.bg}
|
|
39
39
|
>
|
|
40
40
|
{children}
|
|
41
41
|
</Layout>
|
|
@@ -9,7 +9,10 @@ import type {Config, SingleWorkspace, StudioProps} from 'sanity'
|
|
|
9
9
|
import {NextStudioNoScript} from './NextStudioNoScript'
|
|
10
10
|
import {useTheme} from './useTheme'
|
|
11
11
|
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* @alpha
|
|
14
|
+
* @deprecated Will be removed in the next major release
|
|
15
|
+
*/
|
|
13
16
|
export interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {
|
|
14
17
|
/**
|
|
15
18
|
* If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.
|
|
@@ -47,7 +50,9 @@ export function NextStudioLoading(props: NextStudioLoadingProps) {
|
|
|
47
50
|
wrapper: {
|
|
48
51
|
display: 'block',
|
|
49
52
|
animation: `${id} 500ms linear infinite`,
|
|
50
|
-
color:
|
|
53
|
+
color:
|
|
54
|
+
theme.color[scheme === 'dark' ? 'dark' : 'light'].default.muted.default.enabled.muted
|
|
55
|
+
.fg,
|
|
51
56
|
width: rem(capHeight),
|
|
52
57
|
height: rem(capHeight),
|
|
53
58
|
},
|
|
@@ -66,7 +71,7 @@ export function NextStudioLoading(props: NextStudioLoadingProps) {
|
|
|
66
71
|
<div
|
|
67
72
|
style={{
|
|
68
73
|
fontFamily: fonts.text.family,
|
|
69
|
-
backgroundColor: theme.color[scheme].default.base.bg,
|
|
74
|
+
backgroundColor: theme.color[scheme === 'dark' ? 'dark' : 'light'].default.base.bg,
|
|
70
75
|
height: '100vh',
|
|
71
76
|
maxHeight: '100dvh',
|
|
72
77
|
overscrollBehavior: 'none',
|
|
@@ -105,7 +110,9 @@ export function NextStudioLoading(props: NextStudioLoadingProps) {
|
|
|
105
110
|
lineHeight: 'calc(1.3125)',
|
|
106
111
|
// @TODO use rem calc
|
|
107
112
|
transform: 'translateY(-5px)',
|
|
108
|
-
color:
|
|
113
|
+
color:
|
|
114
|
+
theme.color[scheme === 'dark' ? 'dark' : 'light'].default.muted.default.enabled
|
|
115
|
+
.muted.fg,
|
|
109
116
|
}}
|
|
110
117
|
>
|
|
111
118
|
<span>Loading…</span>
|
|
@@ -79,6 +79,7 @@ export interface NextStudioHeadProps {
|
|
|
79
79
|
* }
|
|
80
80
|
* ```
|
|
81
81
|
* @public
|
|
82
|
+
* @deprecated Use `import {metadata} from 'next-sanity/studio'` instead, this component will be removed in the next major release.
|
|
82
83
|
*/
|
|
83
84
|
export function NextStudioHead(props: NextStudioHeadProps) {
|
|
84
85
|
const {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type {Metadata} from 'next'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* In Next 13 appDir mode (`/app/studio/[[...index]]/page.tsx`):
|
|
5
|
+
* ```tsx
|
|
6
|
+
* // If you don't want to change any defaults you can just re-export the metadata directly:
|
|
7
|
+
* export {metadata} from 'next-sanity/studio'
|
|
8
|
+
*
|
|
9
|
+
* // To customize the metadata, spread it on the export:
|
|
10
|
+
* import {metadata as studioMetadata} from 'next-sanity/studio'
|
|
11
|
+
* import type { Metadata } from 'next'
|
|
12
|
+
*
|
|
13
|
+
* export const metadata: Metadata = {
|
|
14
|
+
* ...studioMetadata,
|
|
15
|
+
* // Overrides the viewport to resize behavior
|
|
16
|
+
* viewport: `${studioMetadata.viewport}, interactive-widget=resizes-content`,
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
* If you're using Next 12 or the `pages` folder (`/pages/studio/[[...index]].tsx`):
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import Head from 'next/head'
|
|
22
|
+
* import {NextStudio, metadata} from 'next-sanity/studio'
|
|
23
|
+
*
|
|
24
|
+
* export default function StudioPage() {
|
|
25
|
+
* return (
|
|
26
|
+
* <>
|
|
27
|
+
* <Head>
|
|
28
|
+
* {Object.entries(metadata).map(([key, value]) => (
|
|
29
|
+
* <meta key={key} name={key} content={value} />
|
|
30
|
+
* ))}
|
|
31
|
+
* </Head>
|
|
32
|
+
* <NextStudio config={config} />
|
|
33
|
+
* </>
|
|
34
|
+
* )
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export const metadata = {
|
|
40
|
+
// Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly
|
|
41
|
+
viewport: 'width=device-width,initial-scale=1,viewport-fit=cover' as const,
|
|
42
|
+
referrer: 'same-origin' as const,
|
|
43
|
+
robots: 'noindex' as const,
|
|
44
|
+
} satisfies Metadata
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextStudioLoading-8cf56cdf.js","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {studioTheme} from '@sanity/ui'\nimport {useMemo} from 'react'\nimport type {Config, SingleWorkspace, StudioTheme} from 'sanity'\n\n/** @alpha */\nexport function useTheme(\n config?: Config | Required<Pick<SingleWorkspace, 'theme'>>\n): StudioTheme {\n const workspace = useMemo<\n SingleWorkspace | Required<Pick<SingleWorkspace, 'theme'>> | undefined\n >(() => (Array.isArray(config) ? config[0] : config), [config])\n return useMemo<StudioTheme>(() => workspace?.theme || studioTheme, [workspace])\n}\n","/* eslint-disable react/no-danger */\n\nconst style = {\n __html: `\n.sanity-app-no-js__root {\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n background: #fff;\n z-index: 1;\n}\n\n.sanity-app-no-js__content {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n text-align: center;\n font-family: helvetica, arial, sans-serif;\n}\n`,\n} as const\n\n/** @alpha */\nexport const NextStudioNoScript = () => (\n <noscript>\n <div className=\"sanity-app-no-js__root\">\n <div className=\"sanity-app-no-js__content\">\n <style type=\"text/css\" dangerouslySetInnerHTML={style} />\n <h1>JavaScript disabled</h1>\n <p>\n Please <a href=\"https://www.enable-javascript.com/\">enable JavaScript</a> in your\n browser and reload the page to proceed.\n </p>\n </div>\n </div>\n </noscript>\n)\n","/* eslint-disable no-warning-comments */\n// Intentionally not using `styled-components` to ensure it works in any `next` setup.\n// Whether 'styled-components' SSR is setup or not.\n\nimport {SpinnerIcon} from '@sanity/icons'\nimport {_responsive, rem} from '@sanity/ui'\nimport type {Config, SingleWorkspace, StudioProps} from 'sanity'\n\nimport {NextStudioNoScript} from './NextStudioNoScript'\nimport {useTheme} from './useTheme'\n\n/** @alpha */\nexport interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {\n /**\n * If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.\n */\n config?: Config | Required<Pick<SingleWorkspace, 'theme'>>\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n}\n\nconst keyframes = `\nfrom {\n transform: rotate(0deg);\n}\n\nto {\n transform: rotate(360deg);\n}\n`\n\nexport function NextStudioLoading(props: NextStudioLoadingProps) {\n const {config, scheme = 'light', unstable__noScript = true} = props\n const id = 'next-sanity-spinner'\n const theme = useTheme(config)\n const {fonts, media} = theme\n\n const styles: any = _responsive(media, [2], (size: number) => {\n const {ascenderHeight, descenderHeight, lineHeight, iconSize} = fonts.text.sizes[size]\n const capHeight = lineHeight - ascenderHeight - descenderHeight\n\n return {\n wrapper: {\n display: 'block',\n animation: `${id} 500ms linear infinite`,\n color: theme.color[scheme].default.muted.default.enabled.muted.fg,\n width: rem(capHeight),\n height: rem(capHeight),\n },\n svg: {\n display: 'block',\n width: rem(iconSize),\n height: rem(iconSize),\n margin: (capHeight - iconSize) / 2,\n },\n }\n })[0]\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <div\n style={{\n fontFamily: fonts.text.family,\n backgroundColor: theme.color[scheme].default.base.bg,\n height: '100vh',\n maxHeight: '100dvh',\n overscrollBehavior: 'none',\n WebkitFontSmoothing: 'antialiased',\n overflow: 'auto',\n }}\n >\n <div\n data-ui=\"Flex\"\n style={{\n display: 'flex',\n minWidth: 0,\n minHeight: 0,\n alignItems: 'center',\n justifyContent: 'center',\n flexDirection: 'column',\n height: '100%',\n margin: 0,\n padding: 0,\n // @TODO use rem calc\n gap: '10px',\n }}\n >\n <style key={scheme}>{`@keyframes ${id} {${keyframes}}`}</style>\n <div\n data-ui=\"Text\"\n style={{\n position: 'relative',\n // @TODO read from theme\n fontWeight: 400,\n // @TODO read from theme\n padding: '1px 0px',\n // @TODO use rem calc\n fontSize: '1rem',\n // @TODO use rem calc\n lineHeight: 'calc(1.3125)',\n // @TODO use rem calc\n transform: 'translateY(-5px)',\n color: theme.color[scheme].default.muted.default.enabled.muted.fg,\n }}\n >\n <span>Loading…</span>\n </div>\n <div data-ui=\"Spinner\" style={styles.wrapper}>\n <SpinnerIcon style={styles.svg} />\n </div>\n </div>\n </div>\n </>\n )\n}\n"],"names":["useTheme","config","workspace","useMemo","Array","isArray","theme","studioTheme","style","__html","NextStudioNoScript","jsx","children","className","jsxs","type","dangerouslySetInnerHTML","href","keyframes","NextStudioLoading","props","scheme","unstable__noScript","id","fonts","media","styles","_responsive","size","ascenderHeight","descenderHeight","lineHeight","iconSize","text","sizes","capHeight","wrapper","display","animation","color","default","muted","enabled","fg","width","rem","height","svg","margin","Fragment","fontFamily","family","backgroundColor","base","bg","maxHeight","overscrollBehavior","WebkitFontSmoothing","overflow","minWidth","minHeight","alignItems","justifyContent","flexDirection","padding","gap","concat","position","fontWeight","fontSize","transform","SpinnerIcon"],"mappings":";;;;AAKO,SAASA,SACdC,MACa,EAAA;EACb,MAAMC,SAAY,GAAAC,OAAA,CAEhB,MAAOC,KAAA,CAAMC,OAAQ,CAAAJ,MAAM,CAAI,GAAAA,MAAA,CAAO,CAAC,CAAA,GAAIA,MAAS,EAAA,CAACA,MAAM,CAAC,CAAA;EAC9D,OAAOE,QAAqB,MAAM,CAAAD,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,SAAA,CAAWI,UAASC,WAAa,EAAA,CAACL,SAAS,CAAC,CAAA;AAChF;ACVA,MAAMM,KAAQ,GAAA;EACZC,MAAQ;AAoBV,CAAA;AAGa,MAAAC,kBAAA,GAAqBA,CAAA,KAChC,eAAAC,G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,EAAA,CAAA,eAAAD,GAAA,CAAC,OAAoB,EAAA;UAAAC,QAAA,gBAAAsD,MAAA,CAAc3C,EAAO,QAAA2C,MAAA,CAAAhD,SAAA;QAAA,CAAA,EAA9BG,MAA2C,CAAA,EAAA,eACvDV,GAAA,CAAC,KAAA,EAAA;UACC,SAAQ,EAAA,MAAA;UACRH,KAAO,EAAA;YACL2D,QAAU,EAAA,UAAA;YAAA;YAEVC,UAAY,EAAA,GAAA;YAAA;YAEZJ,OAAS,EAAA,SAAA;YAAA;YAETK,QAAU,EAAA,MAAA;YAAA;YAEVtC,UAAY,EAAA,cAAA;YAAA;YAEZuC,SAAW,EAAA,kBAAA;YACX/B,KAAA,EAAOjC,MAAMiC,KAAM,CAAAlB,MAAM,EAAEmB,OAAQ,CAAAC,KAAA,CAAMD,OAAQ,CAAAE,OAAA,CAAQD,KAAM,CAAAE;UACjE,CAAA;UAEA/B,QAAA,EAAA,eAAAD,GAAA,CAAC;YAAKC,QAAQ,EAAA;UAAA,CAAA;QAAA,CAAA,CAChB,EAAA,eACCD,GAAA,CAAA,KAAA,EAAA;UAAI,SAAQ,EAAA,SAAA;UAAUH,KAAO,EAAAkB,MAAA,CAAOU,OACnC;UAAAxB,QAAA,EAAA,eAAAD,GAAA,CAAC4D,WAAY,EAAA;YAAA/D,KAAA,EAAOkB,MAAO,CAAAqB;UAAK,CAAA;SAClC,CAAA;MAAA,CAAA;IACF,CAAA,CACF;EACF,CAAA,CAAA;AAEJ;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextStudioLoading-bf57e61a.cjs","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {studioTheme} from '@sanity/ui'\nimport {useMemo} from 'react'\nimport type {Config, SingleWorkspace, StudioTheme} from 'sanity'\n\n/** @alpha */\nexport function useTheme(\n config?: Config | Required<Pick<SingleWorkspace, 'theme'>>\n): StudioTheme {\n const workspace = useMemo<\n SingleWorkspace | Required<Pick<SingleWorkspace, 'theme'>> | undefined\n >(() => (Array.isArray(config) ? config[0] : config), [config])\n return useMemo<StudioTheme>(() => workspace?.theme || studioTheme, [workspace])\n}\n","/* eslint-disable react/no-danger */\n\nconst style = {\n __html: `\n.sanity-app-no-js__root {\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n background: #fff;\n z-index: 1;\n}\n\n.sanity-app-no-js__content {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n text-align: center;\n font-family: helvetica, arial, sans-serif;\n}\n`,\n} as const\n\n/** @alpha */\nexport const NextStudioNoScript = () => (\n <noscript>\n <div className=\"sanity-app-no-js__root\">\n <div className=\"sanity-app-no-js__content\">\n <style type=\"text/css\" dangerouslySetInnerHTML={style} />\n <h1>JavaScript disabled</h1>\n <p>\n Please <a href=\"https://www.enable-javascript.com/\">enable JavaScript</a> in your\n browser and reload the page to proceed.\n </p>\n </div>\n </div>\n </noscript>\n)\n","/* eslint-disable no-warning-comments */\n// Intentionally not using `styled-components` to ensure it works in any `next` setup.\n// Whether 'styled-components' SSR is setup or not.\n\nimport {SpinnerIcon} from '@sanity/icons'\nimport {_responsive, rem} from '@sanity/ui'\nimport type {Config, SingleWorkspace, StudioProps} from 'sanity'\n\nimport {NextStudioNoScript} from './NextStudioNoScript'\nimport {useTheme} from './useTheme'\n\n/** @alpha */\nexport interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {\n /**\n * If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.\n */\n config?: Config | Required<Pick<SingleWorkspace, 'theme'>>\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n}\n\nconst keyframes = `\nfrom {\n transform: rotate(0deg);\n}\n\nto {\n transform: rotate(360deg);\n}\n`\n\nexport function NextStudioLoading(props: NextStudioLoadingProps) {\n const {config, scheme = 'light', unstable__noScript = true} = props\n const id = 'next-sanity-spinner'\n const theme = useTheme(config)\n const {fonts, media} = theme\n\n const styles: any = _responsive(media, [2], (size: number) => {\n const {ascenderHeight, descenderHeight, lineHeight, iconSize} = fonts.text.sizes[size]\n const capHeight = lineHeight - ascenderHeight - descenderHeight\n\n return {\n wrapper: {\n display: 'block',\n animation: `${id} 500ms linear infinite`,\n color: theme.color[scheme].default.muted.default.enabled.muted.fg,\n width: rem(capHeight),\n height: rem(capHeight),\n },\n svg: {\n display: 'block',\n width: rem(iconSize),\n height: rem(iconSize),\n margin: (capHeight - iconSize) / 2,\n },\n }\n })[0]\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <div\n style={{\n fontFamily: fonts.text.family,\n backgroundColor: theme.color[scheme].default.base.bg,\n height: '100vh',\n maxHeight: '100dvh',\n overscrollBehavior: 'none',\n WebkitFontSmoothing: 'antialiased',\n overflow: 'auto',\n }}\n >\n <div\n data-ui=\"Flex\"\n style={{\n display: 'flex',\n minWidth: 0,\n minHeight: 0,\n alignItems: 'center',\n justifyContent: 'center',\n flexDirection: 'column',\n height: '100%',\n margin: 0,\n padding: 0,\n // @TODO use rem calc\n gap: '10px',\n }}\n >\n <style key={scheme}>{`@keyframes ${id} {${keyframes}}`}</style>\n <div\n data-ui=\"Text\"\n style={{\n position: 'relative',\n // @TODO read from theme\n fontWeight: 400,\n // @TODO read from theme\n padding: '1px 0px',\n // @TODO use rem calc\n fontSize: '1rem',\n // @TODO use rem calc\n lineHeight: 'calc(1.3125)',\n // @TODO use rem calc\n transform: 'translateY(-5px)',\n color: theme.color[scheme].default.muted.default.enabled.muted.fg,\n }}\n >\n <span>Loading…</span>\n </div>\n <div data-ui=\"Spinner\" style={styles.wrapper}>\n <SpinnerIcon style={styles.svg} />\n </div>\n </div>\n </div>\n </>\n )\n}\n"],"names":["useTheme","config","workspace","useMemo","Array","isArray","theme","studioTheme","style","__html","NextStudioNoScript","jsx","children","className","jsxs","type","dangerouslySetInnerHTML","href","keyframes","NextStudioLoading","props","scheme","unstable__noScript","id","fonts","media","styles","_responsive","size","ascenderHeight","descenderHeight","lineHeight","iconSize","text","sizes","capHeight","wrapper","display","animation","color","default","muted","enabled","fg","width","rem","height","svg","margin","Fragment","fontFamily","family","backgroundColor","base","bg","maxHeight","overscrollBehavior","WebkitFontSmoothing","overflow","minWidth","minHeight","alignItems","justifyContent","flexDirection","padding","gap","concat","position","fontWeight","fontSize","transform","SpinnerIcon"],"mappings":";;;;;;AAKO,SAASA,SACdC,MACa,EAAA;EACb,MAAMC,SAAY,GAAAC,KAAA,CAAAA,OAAA,CAEhB,MAAOC,KAAA,CAAMC,OAAQ,CAAAJ,MAAM,CAAI,GAAAA,MAAA,CAAO,CAAC,CAAA,GAAIA,MAAS,EAAA,CAACA,MAAM,CAAC,CAAA;EAC9D,OAAOE,cAAqB,MAAM,CAAAD,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,SAAA,CAAWI,UAASC,EAAAA,CAAAA,WAAa,EAAA,CAACL,SAAS,CAAC,CAAA;AAChF;ACVA,MAAMM,KAAQ,GAAA;EACZC,MAAQ;AAoBV,CAAA;AAGa,MAAAC,kBAAA,GAAqBA,CAAA,KAChCC,eAAAA,UAAAA,CAAAA,GAAA,CAAC,UACC,EAAA;EAAAC,QAAA,EAAA,eAAAD,UAAA,CAAAA,GAAA,CAAC,KAAI,EAAA;IAAAE,SAAA,EAAU,wBACb;IAAAD,QAAA,EAAA,eAAAE,eAAA,CAAC,KAAI,EAAA;MAAAD,SAAA,EAAU,2BACb;MAAAD,QAAA,EAAA,CAAA,eAAAD,UAAA,CAAAA,GAAA,CAAC,OAAM,EAAA;QAAAI,IAAA,EAAK,UAAW;QAAAC,uBAAA,EAAyBR;OAAO,CAAA,EACvDG,eAAAA,UAAAA,CAAAA,GAAA,CAAC;QAAGC,QAAmB,EAAA;MAAA,CAAA,CAAA,EAAA,+BACtB,GAAE,EAAA;QAAAA,QAAA,EAAA,CAAA,SAAA,EAAA,eACOD,UAAA,CAAAA,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