next-sanity 3.1.1 → 3.1.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.
@@ -3,15 +3,9 @@ import { SpinnerIcon } from '@sanity/icons';
3
3
  import { _responsive, rem } from '@sanity/ui';
4
4
  import { useMemo } from 'react';
5
5
  import { defaultTheme } from 'sanity';
6
- function isWorkspaces(config) {
7
- return Array.isArray(config);
8
- }
9
- function isWorkspaceWithTheme(workspace) {
10
- return Boolean(workspace.theme);
11
- }
12
6
  function useTheme(config) {
13
- const workspace = useMemo(() => isWorkspaces(config) ? config[0] : config, [config]);
14
- return useMemo(() => isWorkspaceWithTheme(workspace) ? workspace.theme : defaultTheme, [workspace]);
7
+ const workspace = useMemo(() => Array.isArray(config) ? config[0] : config, [config]);
8
+ return useMemo(() => (workspace == null ? void 0 : workspace.theme) || defaultTheme, [workspace]);
15
9
  }
16
10
  const style = {
17
11
  __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"
@@ -125,4 +119,4 @@ function NextStudioLoading(props) {
125
119
  });
126
120
  }
127
121
  export { NextStudioLoading as N, NextStudioNoScript as a, useTheme as u };
128
- //# sourceMappingURL=NextStudioLoading-37471b1b.js.map
122
+ //# sourceMappingURL=NextStudioLoading-18687251.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NextStudioLoading-18687251.js","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {useMemo} from 'react'\nimport {type Config, type SingleWorkspace, type StudioTheme, defaultTheme} 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 || defaultTheme, [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// Wether '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","defaultTheme","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","position","fontWeight","fontSize","transform","SpinnerIcon"],"mappings":";;;;;AAIO,SAASA,SACdC,MACa,EAAA;EACb,MAAMC,SAAY,GAAAC,OAAA,CAEhB,MAAOC,KAAA,CAAMC,OAAQ,CAAAJ,MAAM,CAAI,GAAAA,MAAA,CAAO,CAAK,CAAA,GAAAA,MAAA,EAAS,CAACA,MAAM,CAAC,CAAA;EAC9D,OAAOE,QAAqB,MAAM,CAAAD,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,SAAA,CAAWI,UAASC,YAAc,EAAA,CAACL,SAAS,CAAC,CAAA;AACjF;ACTA,MAAMM,KAAQ,GAAA;EACZC,MAAQ;AAoBV,CAAA;AAGa,MAAAC,kBAAA,GAAqB,MAAA,eAC/BC,GAAA,CAAA,UAAA,EAAA;EACCC,QAAC,EAAA,eAAAD,GAAA,CAAA,KAAA,EAAA;IAAIE,SAAU,EAAA,wBAAA;IACbD,QAAC,EAAA,eAAAE,IAAA,CAAA,KAAA,EAAA;MAAID,SAAU,EAAA,2BAAA;MACbD,QAAA,EAAA,CAAC,eAAAD,GAAA,CAAA,OAAA,EAAA;QAAMI,IAAK,EAAA,UAAA;QAAWC,uBAAyB,EAAAR;MAAA,CAAO,CAAA,EACtD,eAAAG,GAAA,CAAA,IAAA,EAAA;QAAGC,QAAA,EAAA;MAAA,CAAmB,CAAA,EACtB,eAAAE,IAAA,CAAA,GAAA,EAAA;QAAEF,QAAA,EAAA,CAAA,SAAA,EACO,eAAAD,GAAA,CAAA,GAAA,EAAA;UAAEM,IAAK,EAAA,oCAAA;UAAqCL,QAAA,EA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UAEA/B,QAAC,EAAA,eAAAD,GAAA,CAAA,MAAA,EAAA;YAAKC,QAAA,EAAA;UAAA,CAAQ;QAAA,CAChB,CAAA,EACC,eAAAD,GAAA,CAAA,KAAA,EAAA;UAAI,SAAQ,EAAA,SAAA;UAAUH,OAAOkB,MAAO,CAAAU,OAAA;UACnCxB,QAAC,EAAA,eAAAD,GAAA,CAAA2D,WAAA,EAAA;YAAY9D,OAAOkB,MAAO,CAAAqB;UAAA,CAAK;QAAA,CAClC,CAAA;MAAA,CACF;IAAA,CACF,CAAA;EAAA,CACF,CAAA;AAEJ;"}
@@ -5,15 +5,9 @@ var icons = require('@sanity/icons');
5
5
  var ui = require('@sanity/ui');
6
6
  var react = require('react');
7
7
  var sanity = require('sanity');
8
- function isWorkspaces(config) {
9
- return Array.isArray(config);
10
- }
11
- function isWorkspaceWithTheme(workspace) {
12
- return Boolean(workspace.theme);
13
- }
14
8
  function useTheme(config) {
15
- const workspace = react.useMemo(() => isWorkspaces(config) ? config[0] : config, [config]);
16
- return react.useMemo(() => isWorkspaceWithTheme(workspace) ? workspace.theme : sanity.defaultTheme, [workspace]);
9
+ const workspace = react.useMemo(() => Array.isArray(config) ? config[0] : config, [config]);
10
+ return react.useMemo(() => (workspace == null ? void 0 : workspace.theme) || sanity.defaultTheme, [workspace]);
17
11
  }
18
12
  const style = {
19
13
  __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"
@@ -129,4 +123,4 @@ function NextStudioLoading(props) {
129
123
  exports.NextStudioLoading = NextStudioLoading;
130
124
  exports.NextStudioNoScript = NextStudioNoScript;
131
125
  exports.useTheme = useTheme;
132
- //# sourceMappingURL=NextStudioLoading-97555646.cjs.map
126
+ //# sourceMappingURL=NextStudioLoading-e92a7c84.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NextStudioLoading-e92a7c84.cjs","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {useMemo} from 'react'\nimport {type Config, type SingleWorkspace, type StudioTheme, defaultTheme} 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 || defaultTheme, [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// Wether '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","defaultTheme","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","position","fontWeight","fontSize","transform","SpinnerIcon"],"mappings":";;;;;;;AAIO,SAASA,SACdC,MACa,EAAA;EACb,MAAMC,SAAY,GAAAC,KAAA,CAAAA,OAAA,CAEhB,MAAOC,KAAA,CAAMC,OAAQ,CAAAJ,MAAM,CAAI,GAAAA,MAAA,CAAO,CAAK,CAAA,GAAAA,MAAA,EAAS,CAACA,MAAM,CAAC,CAAA;EAC9D,OAAOE,cAAqB,MAAM,CAAAD,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,SAAA,CAAWI,UAASC,MAAAA,CAAAA,YAAc,EAAA,CAACL,SAAS,CAAC,CAAA;AACjF;ACTA,MAAMM,KAAQ,GAAA;EACZC,MAAQ;AAoBV,CAAA;AAGa,MAAAC,kBAAA,GAAqB,MAAA,eAC/BC,UAAA,CAAAA,GAAA,CAAA,UAAA,EAAA;EACCC,QAAC,EAAA,eAAAD,UAAA,CAAAA,GAAA,CAAA,KAAA,EAAA;IAAIE,SAAU,EAAA,wBAAA;IACbD,QAAC,EAAA,eAAAE,UAAA,CAAAA,IAAA,CAAA,KAAA,EAAA;MAAID,S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,CAAA;QAEArD,QAAA,EAAA,CAACD,eAAAA,UAAAA,CAAAA,GAAA,CAAA,OAAA,EAAA;UAAoBC,+BAAcW,EAAO,eAAAL,SAAA;QAAA,CAAA,EAA9BG,MAA2C,CAAA,EACtDV,eAAAA,UAAAA,CAAAA,GAAA,CAAA,KAAA,EAAA;UACC,SAAQ,EAAA,MAAA;UACRH,KAAO,EAAA;YACL0D,QAAU,EAAA,UAAA;YAEVC,UAAY,EAAA,GAAA;YAEZH,OAAS,EAAA,SAAA;YAETI,QAAU,EAAA,MAAA;YAEVrC,UAAY,EAAA,cAAA;YAEZsC,SAAW,EAAA,kBAAA;YACX9B,KAAA,EAAOjC,MAAMiC,KAAM,CAAAlB,MAAA,CAAA,CAAQmB,QAAQC,KAAM,CAAAD,OAAA,CAAQE,QAAQD,KAAM,CAAAE;UACjE,CAAA;UAEA/B,QAAC,EAAA,eAAAD,UAAA,CAAAA,GAAA,CAAA,MAAA,EAAA;YAAKC,QAAA,EAAA;UAAA,CAAQ;QAAA,CAChB,CAAA,EACCD,eAAAA,UAAAA,CAAAA,GAAA,CAAA,KAAA,EAAA;UAAI,SAAQ,EAAA,SAAA;UAAUH,OAAOkB,MAAO,CAAAU,OAAA;UACnCxB,QAAC,EAAA,eAAAD,UAAA,CAAAA,GAAA,CAAA2D,iBAAA,EAAA;YAAY9D,OAAOkB,MAAO,CAAAqB;UAAA,CAAK;QAAA,CAClC,CAAA;MAAA,CACF;IAAA,CACF,CAAA;EAAA,CACF,CAAA;AAEJ;;;"}
@@ -15,7 +15,7 @@ var jsxRuntime = require('react/jsx-runtime');
15
15
  var react = require('react');
16
16
  var sanity = require('sanity');
17
17
  var styled = require('styled-components');
18
- var NextStudioLoading = require('../_chunks/NextStudioLoading-97555646.cjs');
18
+ var NextStudioLoading = require('../_chunks/NextStudioLoading-e92a7c84.cjs');
19
19
  require('@sanity/icons');
20
20
  require('@sanity/ui');
21
21
  function _interopDefaultLegacy(e) {
@@ -3,6 +3,7 @@
3
3
  import {Config} from 'sanity'
4
4
  import {MemoExoticComponent} from 'react'
5
5
  import {ReactNode} from 'react'
6
+ import {SingleWorkspace} from 'sanity'
6
7
  import {StudioProps} from 'sanity'
7
8
  import {StudioTheme} from 'sanity'
8
9
  import type {ThemeColorSchemeKey} from '@sanity/ui'
@@ -61,7 +62,11 @@ export declare interface NextStudioLayoutProps extends Pick<StudioProps, 'config
61
62
  }
62
63
 
63
64
  /** @alpha */
64
- export declare interface NextStudioLoadingProps extends Pick<StudioProps, 'config' | 'scheme'> {
65
+ export declare interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {
66
+ /**
67
+ * If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.
68
+ */
69
+ config?: Config | Required<Pick<SingleWorkspace, 'theme'>>
65
70
  /**
66
71
  * Render the <noscript> tag
67
72
  * @defaultValue true
@@ -94,6 +99,8 @@ export declare interface NextStudioProps extends StudioProps {
94
99
  export declare function usePrefersColorScheme(): ThemeColorSchemeKey
95
100
 
96
101
  /** @alpha */
97
- export declare function useTheme(config: Config): StudioTheme
102
+ export declare function useTheme(
103
+ config?: Config | Required<Pick<SingleWorkspace, 'theme'>>
104
+ ): StudioTheme
98
105
 
99
106
  export {}
@@ -10,8 +10,8 @@ import { jsx, Fragment } from 'react/jsx-runtime';
10
10
  import { useState, useEffect, startTransition, memo, useSyncExternalStore } from 'react';
11
11
  import { Studio } from 'sanity';
12
12
  import styled, { css } from 'styled-components';
13
- import { u as useTheme, N as NextStudioLoading } from '../_chunks/NextStudioLoading-37471b1b.js';
14
- export { a as NextStudioNoScript, u as useTheme } from '../_chunks/NextStudioLoading-37471b1b.js';
13
+ import { u as useTheme, N as NextStudioLoading } from '../_chunks/NextStudioLoading-18687251.js';
14
+ export { a as NextStudioNoScript, u as useTheme } from '../_chunks/NextStudioLoading-18687251.js';
15
15
  import '@sanity/icons';
16
16
  import '@sanity/ui';
17
17
  function NextStudioClientOnly(_ref) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var NextStudioLoading = require('../_chunks/NextStudioLoading-97555646.cjs');
3
+ var NextStudioLoading = require('../_chunks/NextStudioLoading-e92a7c84.cjs');
4
4
  require('react/jsx-runtime');
5
5
  require('@sanity/icons');
6
6
  require('@sanity/ui');
@@ -1,10 +1,16 @@
1
+ import type {Config} from 'sanity'
2
+ import type {SingleWorkspace} from 'sanity'
1
3
  import type {StudioProps} from 'sanity'
2
4
 
3
5
  declare function NextStudioLoading(props: NextStudioLoadingProps): JSX.Element
4
6
  export default NextStudioLoading
5
7
 
6
8
  /** @alpha */
7
- export declare interface NextStudioLoadingProps extends Pick<StudioProps, 'config' | 'scheme'> {
9
+ export declare interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {
10
+ /**
11
+ * If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.
12
+ */
13
+ config?: Config | Required<Pick<SingleWorkspace, 'theme'>>
8
14
  /**
9
15
  * Render the <noscript> tag
10
16
  * @defaultValue true
@@ -1,4 +1,4 @@
1
- export { N as default } from '../_chunks/NextStudioLoading-37471b1b.js';
1
+ export { N as default } from '../_chunks/NextStudioLoading-18687251.js';
2
2
  import 'react/jsx-runtime';
3
3
  import '@sanity/icons';
4
4
  import '@sanity/ui';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-sanity",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "sanity",
@@ -147,7 +147,7 @@
147
147
  "@sanity/image-url": "^1.0.1",
148
148
  "@sanity/pkg-utils": "^1.18.0",
149
149
  "@sanity/semantic-release-preset": "^2.0.2",
150
- "@sanity/vision": "3.0.0-rc.2",
150
+ "@sanity/vision": "3.0.0",
151
151
  "@testing-library/react-hooks": "^8.0.1",
152
152
  "@types/eventsource": "^1.1.10",
153
153
  "@types/jest": "^29.2.3",
@@ -170,12 +170,12 @@
170
170
  "postcss": "^8.4.19",
171
171
  "prettier": "^2.8.0",
172
172
  "prettier-plugin-packagejson": "^2.3.0",
173
- "prettier-plugin-tailwindcss": "^0.1.13",
173
+ "prettier-plugin-tailwindcss": "^0.2.0",
174
174
  "react": "^18.2.0",
175
175
  "react-dom": "^18.2.0",
176
176
  "react-is": "^18.2.0",
177
177
  "rollup": "^2.79.1",
178
- "sanity": "3.0.0-rc.2",
178
+ "sanity": "3.0.0-rc.3",
179
179
  "styled-components": "^5.3.6",
180
180
  "tailwindcss": "^3.2.4",
181
181
  "typescript": "^4.9.3",
@@ -4,13 +4,17 @@
4
4
 
5
5
  import {SpinnerIcon} from '@sanity/icons'
6
6
  import {_responsive, rem} from '@sanity/ui'
7
- import type {StudioProps} from 'sanity'
7
+ import type {Config, SingleWorkspace, StudioProps} from 'sanity'
8
8
 
9
9
  import {NextStudioNoScript} from './NextStudioNoScript'
10
10
  import {useTheme} from './useTheme'
11
11
 
12
12
  /** @alpha */
13
- export interface NextStudioLoadingProps extends Pick<StudioProps, 'config' | 'scheme'> {
13
+ export interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {
14
+ /**
15
+ * If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.
16
+ */
17
+ config?: Config | Required<Pick<SingleWorkspace, 'theme'>>
14
18
  /**
15
19
  * Render the <noscript> tag
16
20
  * @defaultValue true
@@ -1,36 +1,12 @@
1
1
  import {useMemo} from 'react'
2
- import {
3
- type Config,
4
- type SingleWorkspace,
5
- type StudioTheme,
6
- type WorkspaceOptions,
7
- defaultTheme,
8
- } from 'sanity'
9
-
10
- type WithTheme = {
11
- theme: StudioTheme
12
- }
13
- type SingleWorkspaceWithTheme = Omit<SingleWorkspace, 'theme'> & WithTheme
14
- type WorkspaceOptionsWithTheme = Omit<WorkspaceOptions, 'theme'> & WithTheme
15
-
16
- function isWorkspaces(config: Config): config is WorkspaceOptions[] {
17
- return Array.isArray(config)
18
- }
19
-
20
- function isWorkspaceWithTheme(
21
- workspace: SingleWorkspace | WorkspaceOptions
22
- ): workspace is SingleWorkspaceWithTheme | WorkspaceOptionsWithTheme {
23
- return Boolean(workspace.theme)
24
- }
2
+ import {type Config, type SingleWorkspace, type StudioTheme, defaultTheme} from 'sanity'
25
3
 
26
4
  /** @alpha */
27
- export function useTheme(config: Config): StudioTheme {
28
- const workspace = useMemo<SingleWorkspace | WorkspaceOptions>(
29
- () => (isWorkspaces(config) ? config[0] : config),
30
- [config]
31
- )
32
- return useMemo<StudioTheme>(
33
- () => (isWorkspaceWithTheme(workspace) ? workspace.theme : defaultTheme),
34
- [workspace]
35
- )
5
+ export function useTheme(
6
+ config?: Config | Required<Pick<SingleWorkspace, 'theme'>>
7
+ ): StudioTheme {
8
+ const workspace = useMemo<
9
+ SingleWorkspace | Required<Pick<SingleWorkspace, 'theme'>> | undefined
10
+ >(() => (Array.isArray(config) ? config[0] : config), [config])
11
+ return useMemo<StudioTheme>(() => workspace?.theme || defaultTheme, [workspace])
36
12
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"NextStudioLoading-37471b1b.js","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {useMemo} from 'react'\nimport {\n type Config,\n type SingleWorkspace,\n type StudioTheme,\n type WorkspaceOptions,\n defaultTheme,\n} from 'sanity'\n\ntype WithTheme = {\n theme: StudioTheme\n}\ntype SingleWorkspaceWithTheme = Omit<SingleWorkspace, 'theme'> & WithTheme\ntype WorkspaceOptionsWithTheme = Omit<WorkspaceOptions, 'theme'> & WithTheme\n\nfunction isWorkspaces(config: Config): config is WorkspaceOptions[] {\n return Array.isArray(config)\n}\n\nfunction isWorkspaceWithTheme(\n workspace: SingleWorkspace | WorkspaceOptions\n): workspace is SingleWorkspaceWithTheme | WorkspaceOptionsWithTheme {\n return Boolean(workspace.theme)\n}\n\n/** @alpha */\nexport function useTheme(config: Config): StudioTheme {\n const workspace = useMemo<SingleWorkspace | WorkspaceOptions>(\n () => (isWorkspaces(config) ? config[0] : config),\n [config]\n )\n return useMemo<StudioTheme>(\n () => (isWorkspaceWithTheme(workspace) ? workspace.theme : defaultTheme),\n [workspace]\n )\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// Wether 'styled-components' SSR is setup or not.\n\nimport {SpinnerIcon} from '@sanity/icons'\nimport {_responsive, rem} from '@sanity/ui'\nimport type {StudioProps} from 'sanity'\n\nimport {NextStudioNoScript} from './NextStudioNoScript'\nimport {useTheme} from './useTheme'\n\n/** @alpha */\nexport interface NextStudioLoadingProps extends Pick<StudioProps, 'config' | 'scheme'> {\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":["isWorkspaces","config","Array","isArray","isWorkspaceWithTheme","workspace","Boolean","theme","useTheme","useMemo","defaultTheme","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","position","fontWeight","fontSize","transform","SpinnerIcon"],"mappings":";;;;;AAeA,SAASA,aAAaC,MAA8C,EAAA;EAC3D,OAAAC,KAAA,CAAMC,QAAQF,MAAM,CAAA;AAC7B;AAEA,SAASG,qBACPC,SACmE,EAAA;EAC5D,OAAAC,OAAA,CAAQD,UAAUE,KAAK,CAAA;AAChC;AAGO,SAASC,SAASP,MAA6B,EAAA;EACpD,MAAMI,SAAY,GAAAI,OAAA,CAChB,MAAOT,YAAA,CAAaC,MAAM,CAAA,GAAIA,OAAO,CAAK,CAAA,GAAAA,MAAA,EAC1C,CAACA,MAAM,CAAA,CACT;EACO,OAAAQ,OAAA,CACL,MAAOL,oBAAA,CAAqBC,SAAS,CAAA,GAAIA,UAAUE,KAAQ,GAAAG,YAAA,EAC3D,CAACL,SAAS,CAAA,CACZ;AACF;ACjCA,MAAMM,KAAQ,GAAA;EACZC,MAAQ;AAoBV,CAAA;AAGa,MAAAC,kBAAA,GAAqB,MAAA,eAC/BC,GAAA,CAAA,UAAA,EAAA;EACCC,QAAC,EAAA,eAAAD,GAAA,CAAA,KAAA,EAAA;IAAIE,SAAU,EAAA,wBAAA;IACbD,QAAC,EAAA,eAAAE,IAAA,CAAA,KAAA,EAAA;MAAID,SAAU,EAAA,2BAAA;MACbD,QAAA,EAAA,CAAC,eAAAD,GAAA,CAAA,OAAA,EAAA;QAAMI,IAAK,EAAA,UAAA;QAAWC,uBAAyB,EAAAR;MAAA,CAAO,CAAA,EACtD,eAAAG,GAAA,CAAA,IAAA,EAAA;QAAGC,QAAA,EAAA;MAAA,CAAmB,CAAA,EACtB,eAAAE,IAAA,CAAA,GAAA,EAAA;QAAEF,QAAA,EAAA,CAAA,SAAA,EACO,eAAAD,GAAA,CAAA,GAAA,EAAA;U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AA,CAAQE,QAAQD,KAAM,CAAAE;UACjE,CAAA;UAEA/B,QAAC,EAAA,eAAAD,GAAA,CAAA,MAAA,EAAA;YAAKC,QAAA,EAAA;UAAA,CAAQ;QAAA,CAChB,CAAA,EACC,eAAAD,GAAA,CAAA,KAAA,EAAA;UAAI,SAAQ,EAAA,SAAA;UAAUH,OAAOkB,MAAO,CAAAU,OAAA;UACnCxB,QAAC,EAAA,eAAAD,GAAA,CAAA2D,WAAA,EAAA;YAAY9D,OAAOkB,MAAO,CAAAqB;UAAA,CAAK;QAAA,CAClC,CAAA;MAAA,CACF;IAAA,CACF,CAAA;EAAA,CACF,CAAA;AAEJ;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"NextStudioLoading-97555646.cjs","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {useMemo} from 'react'\nimport {\n type Config,\n type SingleWorkspace,\n type StudioTheme,\n type WorkspaceOptions,\n defaultTheme,\n} from 'sanity'\n\ntype WithTheme = {\n theme: StudioTheme\n}\ntype SingleWorkspaceWithTheme = Omit<SingleWorkspace, 'theme'> & WithTheme\ntype WorkspaceOptionsWithTheme = Omit<WorkspaceOptions, 'theme'> & WithTheme\n\nfunction isWorkspaces(config: Config): config is WorkspaceOptions[] {\n return Array.isArray(config)\n}\n\nfunction isWorkspaceWithTheme(\n workspace: SingleWorkspace | WorkspaceOptions\n): workspace is SingleWorkspaceWithTheme | WorkspaceOptionsWithTheme {\n return Boolean(workspace.theme)\n}\n\n/** @alpha */\nexport function useTheme(config: Config): StudioTheme {\n const workspace = useMemo<SingleWorkspace | WorkspaceOptions>(\n () => (isWorkspaces(config) ? config[0] : config),\n [config]\n )\n return useMemo<StudioTheme>(\n () => (isWorkspaceWithTheme(workspace) ? workspace.theme : defaultTheme),\n [workspace]\n )\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// Wether 'styled-components' SSR is setup or not.\n\nimport {SpinnerIcon} from '@sanity/icons'\nimport {_responsive, rem} from '@sanity/ui'\nimport type {StudioProps} from 'sanity'\n\nimport {NextStudioNoScript} from './NextStudioNoScript'\nimport {useTheme} from './useTheme'\n\n/** @alpha */\nexport interface NextStudioLoadingProps extends Pick<StudioProps, 'config' | 'scheme'> {\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":["isWorkspaces","config","Array","isArray","isWorkspaceWithTheme","workspace","Boolean","theme","useTheme","useMemo","defaultTheme","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","position","fontWeight","fontSize","transform","SpinnerIcon"],"mappings":";;;;;;;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