next-sanity 3.1.0 → 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"
@@ -58,6 +52,7 @@ function NextStudioLoading(props) {
58
52
  const capHeight = lineHeight - ascenderHeight - descenderHeight;
59
53
  return {
60
54
  wrapper: {
55
+ display: "block",
61
56
  animation: "".concat(id, " 500ms linear infinite"),
62
57
  color: theme.color[scheme].default.muted.default.enabled.muted.fg,
63
58
  width: rem(capHeight),
@@ -93,11 +88,26 @@ function NextStudioLoading(props) {
93
88
  flexDirection: "column",
94
89
  height: "100%",
95
90
  margin: 0,
96
- padding: 0
91
+ padding: 0,
92
+ gap: "10px"
97
93
  },
98
94
  children: [/* @__PURE__ */jsx("style", {
99
95
  children: "@keyframes ".concat(id, " {").concat(keyframes, "}")
100
96
  }, scheme), /* @__PURE__ */jsx("div", {
97
+ "data-ui": "Text",
98
+ style: {
99
+ position: "relative",
100
+ fontWeight: 400,
101
+ padding: "1px 0px",
102
+ fontSize: "1rem",
103
+ lineHeight: "calc(1.3125)",
104
+ transform: "translateY(-5px)",
105
+ color: theme.color[scheme].default.muted.default.enabled.muted.fg
106
+ },
107
+ children: /* @__PURE__ */jsx("span", {
108
+ children: "Loading\u2026"
109
+ })
110
+ }), /* @__PURE__ */jsx("div", {
101
111
  "data-ui": "Spinner",
102
112
  style: styles.wrapper,
103
113
  children: /* @__PURE__ */jsx(SpinnerIcon, {
@@ -109,4 +119,4 @@ function NextStudioLoading(props) {
109
119
  });
110
120
  }
111
121
  export { NextStudioLoading as N, NextStudioNoScript as a, useTheme as u };
112
- //# sourceMappingURL=NextStudioLoading-3a59a7d7.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,G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  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"
@@ -60,6 +54,7 @@ function NextStudioLoading(props) {
60
54
  const capHeight = lineHeight - ascenderHeight - descenderHeight;
61
55
  return {
62
56
  wrapper: {
57
+ display: "block",
63
58
  animation: "".concat(id, " 500ms linear infinite"),
64
59
  color: theme.color[scheme].default.muted.default.enabled.muted.fg,
65
60
  width: ui.rem(capHeight),
@@ -95,11 +90,26 @@ function NextStudioLoading(props) {
95
90
  flexDirection: "column",
96
91
  height: "100%",
97
92
  margin: 0,
98
- padding: 0
93
+ padding: 0,
94
+ gap: "10px"
99
95
  },
100
96
  children: [/* @__PURE__ */jsxRuntime.jsx("style", {
101
97
  children: "@keyframes ".concat(id, " {").concat(keyframes, "}")
102
98
  }, scheme), /* @__PURE__ */jsxRuntime.jsx("div", {
99
+ "data-ui": "Text",
100
+ style: {
101
+ position: "relative",
102
+ fontWeight: 400,
103
+ padding: "1px 0px",
104
+ fontSize: "1rem",
105
+ lineHeight: "calc(1.3125)",
106
+ transform: "translateY(-5px)",
107
+ color: theme.color[scheme].default.muted.default.enabled.muted.fg
108
+ },
109
+ children: /* @__PURE__ */jsxRuntime.jsx("span", {
110
+ children: "Loading\u2026"
111
+ })
112
+ }), /* @__PURE__ */jsxRuntime.jsx("div", {
103
113
  "data-ui": "Spinner",
104
114
  style: styles.wrapper,
105
115
  children: /* @__PURE__ */jsxRuntime.jsx(icons.SpinnerIcon, {
@@ -113,4 +123,4 @@ function NextStudioLoading(props) {
113
123
  exports.NextStudioLoading = NextStudioLoading;
114
124
  exports.NextStudioNoScript = NextStudioNoScript;
115
125
  exports.useTheme = useTheme;
116
- //# sourceMappingURL=NextStudioLoading-d668a359.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,CA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,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-d668a359.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-3a59a7d7.js';
14
- export { a as NextStudioNoScript, u as useTheme } from '../_chunks/NextStudioLoading-3a59a7d7.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-d668a359.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-3a59a7d7.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.0",
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",
@@ -157,7 +157,7 @@
157
157
  "@typescript-eslint/eslint-plugin": "^5.44.0",
158
158
  "autoprefixer": "^10.4.13",
159
159
  "eslint": "^8.28.0",
160
- "eslint-config-next": "13.0.6-canary.0",
160
+ "eslint-config-next": "13.0.6-canary.1",
161
161
  "eslint-config-prettier": "^8.5.0",
162
162
  "eslint-config-sanity": "^6.0.0",
163
163
  "eslint-gitignore": "^0.1.0",
@@ -166,16 +166,16 @@
166
166
  "groqd": "^0.0.4",
167
167
  "jest": "^29.3.1",
168
168
  "jest-environment-jsdom": "^29.3.1",
169
- "next": "13.0.6-canary.0",
169
+ "next": "13.0.6-canary.1",
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",
@@ -1,15 +1,20 @@
1
+ /* eslint-disable no-warning-comments */
1
2
  // Intentionally not using `styled-components` to ensure it works in any `next` setup.
2
3
  // Wether 'styled-components' SSR is setup or not.
3
4
 
4
5
  import {SpinnerIcon} from '@sanity/icons'
5
6
  import {_responsive, rem} from '@sanity/ui'
6
- import type {StudioProps} from 'sanity'
7
+ import type {Config, SingleWorkspace, StudioProps} from 'sanity'
7
8
 
8
9
  import {NextStudioNoScript} from './NextStudioNoScript'
9
10
  import {useTheme} from './useTheme'
10
11
 
11
12
  /** @alpha */
12
- 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'>>
13
18
  /**
14
19
  * Render the <noscript> tag
15
20
  * @defaultValue true
@@ -40,6 +45,7 @@ export function NextStudioLoading(props: NextStudioLoadingProps) {
40
45
 
41
46
  return {
42
47
  wrapper: {
48
+ display: 'block',
43
49
  animation: `${id} 500ms linear infinite`,
44
50
  color: theme.color[scheme].default.muted.default.enabled.muted.fg,
45
51
  width: rem(capHeight),
@@ -80,9 +86,30 @@ export function NextStudioLoading(props: NextStudioLoadingProps) {
80
86
  height: '100%',
81
87
  margin: 0,
82
88
  padding: 0,
89
+ // @TODO use rem calc
90
+ gap: '10px',
83
91
  }}
84
92
  >
85
93
  <style key={scheme}>{`@keyframes ${id} {${keyframes}}`}</style>
94
+ <div
95
+ data-ui="Text"
96
+ style={{
97
+ position: 'relative',
98
+ // @TODO read from theme
99
+ fontWeight: 400,
100
+ // @TODO read from theme
101
+ padding: '1px 0px',
102
+ // @TODO use rem calc
103
+ fontSize: '1rem',
104
+ // @TODO use rem calc
105
+ lineHeight: 'calc(1.3125)',
106
+ // @TODO use rem calc
107
+ transform: 'translateY(-5px)',
108
+ color: theme.color[scheme].default.muted.default.enabled.muted.fg,
109
+ }}
110
+ >
111
+ <span>Loading…</span>
112
+ </div>
86
113
  <div data-ui="Spinner" style={styles.wrapper}>
87
114
  <SpinnerIcon style={styles.svg} />
88
115
  </div>
@@ -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-3a59a7d7.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","// 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 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 }}\n >\n <style key={scheme}>{`@keyframes ${id} {${keyframes}}`}</style>\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","animation","color","default","muted","enabled","fg","width","rem","height","svg","display","margin","Fragment","fontFamily","family","backgroundColor","base","bg","maxHeight","overscrollBehavior","WebkitFontSmoothing","overflow","minWidth","minHeight","alignItems","justifyContent","flexDirection","padding","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,C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J;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"NextStudioLoading-d668a359.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","// 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 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 }}\n >\n <style key={scheme}>{`@keyframes ${id} {${keyframes}}`}</style>\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","animation","color","default","muted","enabled","fg","width","rem","height","svg","display","margin","Fragment","fontFamily","family","backgroundColor","base","bg","maxHeight","overscrollBehavior","WebkitFontSmoothing","overflow","minWidth","minHeight","alignItems","justifyContent","flexDirection","padding","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,KAAA,CAAAA,OAAA,CAChB,MAAOT,YAAA,CAAaC,MAAM,CAAA,GAAIA,OAAO,CAAK,CAAA,GAAAA,MAAA,EAC1C,CAACA,MAAM,CAAA,CACT;EACO,OAAAQ,KAAA,CAAAA,OAAA,CACL,MAAOL,oBAAA,CAAqBC,SAAS,CAAA,GAAIA,UAAUE,KAAQ,GAAAG,MAAA,CAAAA,YAAA,EAC3D,CAACL,SAAS,CAAA,CACZ;AACF;ACjCA,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,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