@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.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refractor.mjs","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;"}
@@ -1,11 +1,10 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
- import { useState, useEffect, useDebugValue, useMemo, useSyncExternalStore, createContext, useContext, forwardRef, useId, Children, isValidElement, cloneElement, useRef, useImperativeHandle, memo, useCallback, useLayoutEffect } from "react";
3
+ import { useState, useEffect, useDebugValue, useMemo, useSyncExternalStore, createContext, useContext, forwardRef, useId, Children, isValidElement, cloneElement, useRef, useImperativeHandle, lazy, Suspense, memo, useCallback, useLayoutEffect } from "react";
4
4
  import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
5
5
  import { buildTheme, createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1, getTheme_v2, getScopedTheme } from "@sanity/ui/theme";
6
6
  import ReactIs, { isValidElementType } from "react-is";
7
7
  import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon } from "@sanity/icons";
8
- import Refractor from "react-refractor";
9
8
  import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
10
9
  import { motion, AnimatePresence } from "framer-motion";
11
10
  import { ResizeObserver } from "@juggle/resize-observer";
@@ -2462,32 +2461,29 @@ function codeBaseStyle() {
2462
2461
  }
2463
2462
  `;
2464
2463
  }
2465
- const StyledCode = /* @__PURE__ */ styled.pre.withConfig({
2464
+ const LazyRefractor = lazy(() => import("./refractor.esm.js")), StyledCode = /* @__PURE__ */ styled.pre.withConfig({
2466
2465
  displayName: "StyledCode",
2467
2466
  componentId: "sc-4dymyn-0"
2468
2467
  })(codeBaseStyle, responsiveCodeFontStyle), Code = forwardRef(function(props, ref) {
2469
- const $ = c(23);
2470
- let children, languageProp, restProps, t0, weight;
2468
+ const $ = c(20);
2469
+ let children, language, restProps, t0, weight;
2471
2470
  $[0] !== props ? ({
2472
2471
  children,
2473
- language: languageProp,
2472
+ language,
2474
2473
  size: t0,
2475
2474
  weight,
2476
2475
  ...restProps
2477
- } = props, $[0] = props, $[1] = children, $[2] = languageProp, $[3] = restProps, $[4] = t0, $[5] = weight) : (children = $[1], languageProp = $[2], restProps = $[3], t0 = $[4], weight = $[5]);
2478
- const size2 = t0 === void 0 ? 2 : t0, language = typeof languageProp == "string" ? languageProp : void 0;
2479
- let t1;
2480
- $[6] !== language ? (t1 = language ? Refractor.hasLanguage(language) : !1, $[6] = language, $[7] = t1) : t1 = $[7];
2481
- const registered = t1, t2 = useArrayProp(size2);
2482
- let t3;
2483
- $[8] !== children || $[9] !== language || $[10] !== registered ? (t3 = !(language && registered) && /* @__PURE__ */ jsx("code", { children }), $[8] = children, $[9] = language, $[10] = registered, $[11] = t3) : t3 = $[11];
2476
+ } = props, $[0] = props, $[1] = children, $[2] = language, $[3] = restProps, $[4] = t0, $[5] = weight) : (children = $[1], language = $[2], restProps = $[3], t0 = $[4], weight = $[5]);
2477
+ const t1 = useArrayProp(t0 === void 0 ? 2 : t0);
2478
+ let t2;
2479
+ $[6] !== children ? (t2 = /* @__PURE__ */ jsx("code", { children }), $[6] = children, $[7] = t2) : t2 = $[7];
2480
+ const t3 = String(children);
2484
2481
  let t4;
2485
- $[12] !== children || $[13] !== language || $[14] !== registered ? (t4 = language && registered && /* @__PURE__ */ jsx(Refractor, { inline: !0, language, value: String(children) }), $[12] = children, $[13] = language, $[14] = registered, $[15] = t4) : t4 = $[15];
2482
+ $[8] !== language || $[9] !== t3 ? (t4 = /* @__PURE__ */ jsx(LazyRefractor, { language, value: t3 }), $[8] = language, $[9] = t3, $[10] = t4) : t4 = $[10];
2486
2483
  let t5;
2487
- return $[16] !== ref || $[17] !== restProps || $[18] !== t2 || $[19] !== t3 || $[20] !== t4 || $[21] !== weight ? (t5 = /* @__PURE__ */ jsxs(StyledCode, { "data-ui": "Code", ...restProps, $size: t2, $weight: weight, ref, children: [
2488
- t3,
2489
- t4
2490
- ] }), $[16] = ref, $[17] = restProps, $[18] = t2, $[19] = t3, $[20] = t4, $[21] = weight, $[22] = t5) : t5 = $[22], t5;
2484
+ $[11] !== t2 || $[12] !== t4 ? (t5 = /* @__PURE__ */ jsx(Suspense, { fallback: t2, children: t4 }), $[11] = t2, $[12] = t4, $[13] = t5) : t5 = $[13];
2485
+ let t6;
2486
+ return $[14] !== ref || $[15] !== restProps || $[16] !== t1 || $[17] !== t5 || $[18] !== weight ? (t6 = /* @__PURE__ */ jsx(StyledCode, { "data-ui": "Code", ...restProps, $size: t1, $weight: weight, ref, children: t5 }), $[14] = ref, $[15] = restProps, $[16] = t1, $[17] = t5, $[18] = weight, $[19] = t6) : t6 = $[19], t6;
2491
2487
  });
2492
2488
  Code.displayName = "ForwardRef(Code)";
2493
2489
  const BASE_STYLE$1 = {