@sanity/ui 2.12.0-canary.1 → 2.12.0

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.
@@ -0,0 +1,26 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { c } from "react-compiler-runtime";
3
+ import Refractor from "react-refractor";
4
+ function LazyRefractor(props) {
5
+ const $ = c(13), {
6
+ language: languageProp,
7
+ value
8
+ } = props, language = typeof languageProp == "string" ? languageProp : void 0;
9
+ let t0;
10
+ $[0] !== language ? (t0 = language ? Refractor.hasLanguage(language) : !1, $[0] = language, $[1] = t0) : t0 = $[1];
11
+ const registered = t0;
12
+ let t1;
13
+ $[2] !== language || $[3] !== registered || $[4] !== value ? (t1 = !(language && registered) && /* @__PURE__ */ jsx("code", { children: value }), $[2] = language, $[3] = registered, $[4] = value, $[5] = t1) : t1 = $[5];
14
+ let t2;
15
+ $[6] !== language || $[7] !== registered || $[8] !== value ? (t2 = language && registered && /* @__PURE__ */ jsx(Refractor, { inline: !0, language, value }), $[6] = language, $[7] = registered, $[8] = value, $[9] = t2) : t2 = $[9];
16
+ let t3;
17
+ return $[10] !== t1 || $[11] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Fragment, { children: [
18
+ t1,
19
+ t2
20
+ ] }), $[10] = t1, $[11] = t2, $[12] = t3) : t3 = $[12], t3;
21
+ }
22
+ LazyRefractor.displayName = "LazyRefractor";
23
+ export {
24
+ LazyRefractor as default
25
+ };
26
+ //# sourceMappingURL=refractor.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refractor.esm.js","sources":["../../src/core/primitives/code/refractor.tsx"],"sourcesContent":["import Refractor from 'react-refractor'\n\nexport default function LazyRefractor(\n props: Partial<Pick<React.ComponentProps<typeof Refractor>, 'language'>> &\n Pick<React.ComponentProps<typeof Refractor>, 'value'>,\n) {\n const {language: languageProp, value} = props\n const language = typeof languageProp === 'string' ? languageProp : undefined\n const registered = language ? Refractor.hasLanguage(language as any) : false\n\n return (\n <>\n {!(language && registered) && <code>{value}</code>}\n {language && registered && <Refractor inline language={language} value={value} />}\n </>\n )\n}\n\nLazyRefractor.displayName = 'LazyRefractor'\n"],"names":["LazyRefractor","props","$","_c","language","languageProp","value","undefined","t0","Refractor","hasLanguage","registered","t1","t2","t3","displayName"],"mappings":";;;AAEA,SAAeA,cAAAC,OAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA,GAIb;AAAA,IAAAC,UAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAwCL,OACxCG,WAAiB,OAAOC,gBAAiB,WAAWA,eAAYE;AAAYC,MAAAA;AAAAN,WAAAE,YACzDI,KAAAJ,WAAWK,UAAAC,YAAsBN,QAAe,IAAS,IAAAF,OAAAE,UAAAF,OAAAM,MAAAA,KAAAN,EAAA,CAAA;AAA5E,QAAAS,aAAmBH;AAAyDI,MAAAA;AAAAV,IAAAE,CAAAA,MAAAA,YAAAF,SAAAS,cAAAT,EAAA,CAAA,MAAAI,SAIvEM,KAAA,EAAER,YAAYO,2CAAsBL,EAAAA,UAAAA,MAAAA,CAAM,GAAOJ,OAAAE,UAAAF,OAAAS,YAAAT,OAAAI,OAAAJ,OAAAU,MAAAA,KAAAV,EAAA,CAAA;AAAAW,MAAAA;AAAAX,IAAAE,CAAAA,MAAAA,YAAAF,SAAAS,cAAAT,EAAA,CAAA,MAAAI,SACjDO,KAAAT,YAAYO,cAAe,oBAAA,WAAA,EAAU,QAAA,IAAiBP,UAAiBE,OAAS,GAAAJ,OAAAE,UAAAF,OAAAS,YAAAT,OAAAI,OAAAJ,OAAAW,MAAAA,KAAAX,EAAA,CAAA;AAAAY,MAAAA;AAAAZ,SAAAA,EAAAU,EAAAA,MAAAA,MAAAV,UAAAW,MAFnFC,KACGF,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,IAAAA;AAAAA,IACAC;AAAAA,EAAAA,EAAgF,CAAA,GAChFX,QAAAU,IAAAV,QAAAW,IAAAX,QAAAY,MAAAA,KAAAZ,EAAA,EAAA,GAHHY;AAGG;AAIPd,cAAce,cAAc;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.12.0-canary.1",
3
+ "version": "2.12.0",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -61,6 +61,32 @@
61
61
  "_visual-editing.js",
62
62
  "theme.js"
63
63
  ],
64
+ "scripts": {
65
+ "build": "run-s clean pkg:build pkg:check figma:pkg:build",
66
+ "clean": "rimraf .workshop dist",
67
+ "commit": "cz",
68
+ "cypress:dev": "run-p dev cypress:open",
69
+ "cypress:open": "cypress open",
70
+ "cypress:run": "cypress run",
71
+ "dev": "run-p storybook:dev workshop:dev",
72
+ "figma:pkg:build": "cd figma && pnpm build",
73
+ "format": "prettier --write --cache --ignore-unknown .",
74
+ "lint": "eslint . --ext .cjs,.js,.jsx,.mjs,.ts,.tsx",
75
+ "pkg:build": "pkg build --strict",
76
+ "pkg:check": "pkg --strict",
77
+ "prepare": "husky install",
78
+ "prepack": "pnpm build",
79
+ "release": "semantic-release",
80
+ "storybook:build": "storybook build",
81
+ "storybook:dev": "storybook dev -p 6006",
82
+ "test": "jest",
83
+ "test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
84
+ "ts:check": "tsc",
85
+ "watch": "pkg watch --strict",
86
+ "workshop:build": "workshop build",
87
+ "workshop:dev": "workshop dev",
88
+ "workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
89
+ },
64
90
  "commitlint": {
65
91
  "extends": [
66
92
  "@commitlint/config-conventional"
@@ -182,37 +208,25 @@
182
208
  "react-is": "^18 || >=19.0.0-0",
183
209
  "styled-components": "^5.2 || ^6"
184
210
  },
211
+ "packageManager": "pnpm@9.15.5",
185
212
  "engines": {
186
213
  "node": ">=14.0.0"
187
214
  },
188
215
  "publishConfig": {
189
216
  "access": "public"
190
217
  },
218
+ "pnpm": {
219
+ "overrides": {
220
+ "@types/react": "$@types/react",
221
+ "@types/react-dom": "$@types/react-dom",
222
+ "@types/react-is": "$@types/react-is",
223
+ "conventional-changelog-conventionalcommits": ">= 8.0.0",
224
+ "react": "$react",
225
+ "react-dom": "$react-dom",
226
+ "react-is": "$react-is"
227
+ }
228
+ },
191
229
  "esm.sh": {
192
230
  "bundle": false
193
- },
194
- "scripts": {
195
- "build": "run-s clean pkg:build pkg:check figma:pkg:build",
196
- "clean": "rimraf .workshop dist",
197
- "commit": "cz",
198
- "cypress:dev": "run-p dev cypress:open",
199
- "cypress:open": "cypress open",
200
- "cypress:run": "cypress run",
201
- "dev": "run-p storybook:dev workshop:dev",
202
- "figma:pkg:build": "cd figma && pnpm build",
203
- "format": "prettier --write --cache --ignore-unknown .",
204
- "lint": "eslint . --ext .cjs,.js,.jsx,.mjs,.ts,.tsx",
205
- "pkg:build": "pkg build --strict",
206
- "pkg:check": "pkg --strict",
207
- "release": "semantic-release",
208
- "storybook:build": "storybook build",
209
- "storybook:dev": "storybook dev -p 6006",
210
- "test": "jest",
211
- "test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
212
- "ts:check": "tsc",
213
- "watch": "pkg watch --strict",
214
- "workshop:build": "workshop build",
215
- "workshop:dev": "workshop dev",
216
- "workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
217
231
  }
218
- }
232
+ }
@@ -1,10 +1,11 @@
1
- import {forwardRef} from 'react'
2
- import Refractor from 'react-refractor'
1
+ import {forwardRef, Suspense, lazy} from 'react'
3
2
  import {styled} from 'styled-components'
4
3
  import {useArrayProp} from '../../hooks'
5
4
  import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
6
5
  import {codeBaseStyle} from './styles'
7
6
 
7
+ const LazyRefractor = lazy(() => import('./refractor'))
8
+
8
9
  /**
9
10
  * @public
10
11
  */
@@ -25,14 +26,13 @@ export const Code = forwardRef(function Code(
25
26
  props: CodeProps & Omit<React.HTMLProps<HTMLElement>, 'as' | 'size'>,
26
27
  ref: React.ForwardedRef<HTMLElement>,
27
28
  ) {
28
- const {children, language: languageProp, size = 2, weight, ...restProps} = props
29
- const language = typeof languageProp === 'string' ? languageProp : undefined
30
- const registered = language ? Refractor.hasLanguage(language as any) : false
29
+ const {children, language, size = 2, weight, ...restProps} = props
31
30
 
32
31
  return (
33
32
  <StyledCode data-ui="Code" {...restProps} $size={useArrayProp(size)} $weight={weight} ref={ref}>
34
- {!(language && registered) && <code>{children}</code>}
35
- {language && registered && <Refractor inline language={language} value={String(children)} />}
33
+ <Suspense fallback={<code>{children}</code>}>
34
+ <LazyRefractor language={language} value={String(children)} />
35
+ </Suspense>
36
36
  </StyledCode>
37
37
  )
38
38
  })
@@ -0,0 +1,19 @@
1
+ import Refractor from 'react-refractor'
2
+
3
+ export default function LazyRefractor(
4
+ props: Partial<Pick<React.ComponentProps<typeof Refractor>, 'language'>> &
5
+ Pick<React.ComponentProps<typeof Refractor>, 'value'>,
6
+ ) {
7
+ const {language: languageProp, value} = props
8
+ const language = typeof languageProp === 'string' ? languageProp : undefined
9
+ const registered = language ? Refractor.hasLanguage(language as any) : false
10
+
11
+ return (
12
+ <>
13
+ {!(language && registered) && <code>{value}</code>}
14
+ {language && registered && <Refractor inline language={language} value={value} />}
15
+ </>
16
+ )
17
+ }
18
+
19
+ LazyRefractor.displayName = 'LazyRefractor'