@sanity/ui 3.0.0-static.30 → 3.0.0-static.31

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.
Files changed (42) hide show
  1. package/dist/_chunks-cjs/_visual-editing.cjs +13 -14
  2. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  3. package/dist/_chunks-cjs/refractor.cjs.map +1 -1
  4. package/dist/_chunks-es/_visual-editing.js +13 -14
  5. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  6. package/dist/_chunks-es/refractor.js.map +1 -1
  7. package/dist/css/index.css +1 -1
  8. package/dist/css/index.d.cts +7227 -7227
  9. package/dist/css/index.d.ts +7227 -7227
  10. package/dist/index.cjs +11 -9
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +11 -11
  13. package/dist/index.d.ts +11 -11
  14. package/dist/index.js +11 -9
  15. package/dist/index.js.map +1 -1
  16. package/dist/theme.cjs.map +1 -1
  17. package/dist/theme.js.map +1 -1
  18. package/package.json +25 -25
  19. package/src/core/__DEV__.ts +0 -1
  20. package/src/core/_compat/theme/theme.test.tsx +4 -3
  21. package/src/core/components/dialog/dialogCard.tsx +9 -2
  22. package/src/core/components/menu/menu.test.tsx +8 -7
  23. package/src/core/components/toast/toast.test.tsx +8 -7
  24. package/src/core/hooks/usePrefersDark.hydration.test.tsx +1 -1
  25. package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +1 -1
  26. package/src/core/lib/createGlobalScopedContext.ts +5 -2
  27. package/src/core/lib/globalScope.ts +1 -1
  28. package/src/core/primitives/code/refractor.tsx +1 -1
  29. package/src/core/primitives/layer/layer.test.tsx +8 -7
  30. package/src/core/primitives/popover/popover.tsx +4 -29
  31. package/src/core/primitives/textArea/textArea.tsx +0 -2
  32. package/src/core/primitives/types.ts +11 -11
  33. package/src/core/types/props.ts +1 -0
  34. package/src/core/utils/boundaryElement/boundaryElement.test.tsx +8 -7
  35. package/src/core/utils/getElementRef.ts +2 -0
  36. package/src/core/utils/portal/portal.test.tsx +8 -7
  37. package/src/core/utils/portal/portalContext.ts +10 -7
  38. package/src/css/components/dialog/dialog.css.ts +2 -2
  39. package/src/css/primitives/button/button.css.ts +0 -2
  40. package/src/theme/v0/css.ts +2 -0
  41. package/src/theme/v2/build/merge.ts +2 -0
  42. package/src/theme/v3/merge.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"refractor.cjs","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 value: React.ReactNode\n },\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={String(value)} />}\n </>\n )\n}\n"],"names":["LazyRefractor","props","$","_c","language","languageProp","value","undefined","t0","Refractor","hasLanguage","registered","t1","t2","String","t3"],"mappings":";;;;;;AAEA,SAAeA,cAAAC,OAAA;AAAAC,QAAAA,IAAAC,kBAAA,EAAA,GAKb;AAAA,IAAAC,UAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAwCL,OACxCG,WAAiB,OAAOC,gBAAiB,WAAWA,eAAYE;AAAYC,MAAAA;AAAAN,WAAAE,YACzDI,KAAAJ,WAAWK,mBAAAA,QAAAC,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,sDAAsBL,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,6CAAeF,mBAAU,SAAA,EAAA,QAAK,IAAYL,UAAiB,OAAAU,OAAOR,KAAK,EAAA,CAAK,GAAAJ,OAAAE,UAAAF,OAAAS,YAAAT,OAAAI,OAAAJ,OAAAW,MAAAA,KAAAX,EAAA,CAAA;AAAAa,MAAAA;AAAAb,SAAAA,EAAAU,EAAAA,MAAAA,MAAAV,UAAAW,MAF3FE,KACGH,2BAAAA,KAAAA,WAAAA,UAAAA,EAAAA,UAAAA;AAAAA,IAAAA;AAAAA,IACAC;AAAAA,EAAAA,EAAwF,CAAA,GACxFX,QAAAU,IAAAV,QAAAW,IAAAX,QAAAa,MAAAA,KAAAb,EAAA,EAAA,GAHHa;AAGG;;"}
1
+ {"version":3,"file":"refractor.cjs","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 value: React.ReactNode\n },\n) {\n const {language: languageProp, value} = props\n const language = typeof languageProp === 'string' ? languageProp : undefined\n const registered = language ? Refractor.hasLanguage(language) : false\n\n return (\n <>\n {!(language && registered) && <code>{value}</code>}\n {language && registered && <Refractor inline language={language} value={String(value)} />}\n </>\n )\n}\n"],"names":["LazyRefractor","props","$","_c","language","languageProp","value","undefined","t0","Refractor","hasLanguage","registered","t1","t2","String","t3"],"mappings":";;;;;;AAEA,SAAeA,cAAAC,OAAA;AAAAC,QAAAA,IAAAC,kBAAA,EAAA,GAKb;AAAA,IAAAC,UAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAwCL,OACxCG,WAAiB,OAAOC,gBAAiB,WAAWA,eAAYE;AAAYC,MAAAA;AAAAN,WAAAE,YACzDI,KAAAJ,WAAWK,mBAAAA,QAAAC,YAAsBN,QAAQ,IAAS,IAAAF,OAAAE,UAAAF,OAAAM,MAAAA,KAAAN,EAAA,CAAA;AAArE,QAAAS,aAAmBH;AAAkDI,MAAAA;AAAAV,IAAAE,CAAAA,MAAAA,YAAAF,SAAAS,cAAAT,EAAA,CAAA,MAAAI,SAIhEM,KAAA,EAAER,YAAYO,sDAAsBL,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,6CAAeF,mBAAU,SAAA,EAAA,QAAK,IAAYL,UAAiB,OAAAU,OAAOR,KAAK,EAAA,CAAK,GAAAJ,OAAAE,UAAAF,OAAAS,YAAAT,OAAAI,OAAAJ,OAAAW,MAAAA,KAAAX,EAAA,CAAA;AAAAa,MAAAA;AAAAb,SAAAA,EAAAU,EAAAA,MAAAA,MAAAV,UAAAW,MAF3FE,KACGH,2BAAAA,KAAAA,WAAAA,UAAAA,EAAAA,UAAAA;AAAAA,IAAAA;AAAAA,IACAC;AAAAA,EAAAA,EAAwF,CAAA,GACxFX,QAAAU,IAAAV,QAAAW,IAAAX,QAAAa,MAAAA,KAAAb,EAAA,EAAA,GAHHa;AAGG;;"}
@@ -21,7 +21,10 @@ function getGlobalScope() {
21
21
  const globalScope = getGlobalScope();
22
22
  function createGlobalScopedContext(key2, defaultValue) {
23
23
  const symbol = Symbol.for(key2);
24
- return typeof document > "u" ? createContext(defaultValue) : (globalScope[symbol] = globalScope[symbol] || createContext(defaultValue), globalScope[symbol]);
24
+ if (typeof document > "u")
25
+ return createContext(defaultValue);
26
+ const symbolMap = globalScope;
27
+ return symbolMap[symbol] = symbolMap[symbol] || createContext(defaultValue), symbolMap[symbol];
25
28
  }
26
29
  const CardContext = createGlobalScopedContext("@sanity/ui/context/card", null);
27
30
  function CardProvider(props) {
@@ -543,16 +546,20 @@ function useBoundaryElement() {
543
546
  throw new Error("useBoundaryElement(): the context value is not compatible");
544
547
  return value || DEFAULT_VALUE;
545
548
  }
549
+ function getElementRef(element) {
550
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
551
+ return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
552
+ }
546
553
  function useCard() {
547
554
  return useContext(CardContext);
548
555
  }
549
- const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
550
- globalScope[elementKey] = null;
556
+ const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`), elementMap = globalScope;
557
+ elementMap[elementKey] = null;
551
558
  const defaultContextValue = {
552
559
  version: 0,
553
560
  boundaryElement: null,
554
561
  get element() {
555
- return typeof document > "u" ? null : (globalScope[elementKey] || (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey])), globalScope[elementKey]);
562
+ return typeof document > "u" ? null : (elementMap[elementKey] || (elementMap[elementKey] = document.createElement("div"), elementMap[elementKey].setAttribute("data-portal", ""), document.body.appendChild(elementMap[elementKey])), elementMap[elementKey]);
556
563
  }
557
564
  }, PortalContext = createGlobalScopedContext(key, defaultContextValue);
558
565
  function usePortal() {
@@ -1159,8 +1166,8 @@ function Popover(props) {
1159
1166
  }, []), setFloating = useCallback((node) => {
1160
1167
  ref.current = node, refs.setFloating(node);
1161
1168
  }, [refs]), setReference = useCallback((node_0) => {
1162
- refs.setReference(node_0);
1163
- const childRef = getElementRef$1(childProp);
1169
+ if (refs.setReference(node_0), !childProp) return;
1170
+ const childRef = getElementRef(childProp);
1164
1171
  typeof childRef == "function" ? childRef(node_0) : childRef && (childRef.current = node_0);
1165
1172
  }, [childProp, refs]), child = useMemo(() => referenceElement ? childProp : childProp ? cloneElement(childProp, {
1166
1173
  ref: setReference
@@ -1180,10 +1187,6 @@ function Popover(props) {
1180
1187
  child
1181
1188
  ] });
1182
1189
  }
1183
- function getElementRef$1(element) {
1184
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
1185
- return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
1186
- }
1187
1190
  const DEFAULT_SELECTABLE_ELEMENT = "button";
1188
1191
  function Selectable(props) {
1189
1192
  const $ = c(16), t0 = props;
@@ -2050,10 +2053,6 @@ function useDelayedState(initialState) {
2050
2053
  let t1;
2051
2054
  return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
2052
2055
  }
2053
- function getElementRef(element) {
2054
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
2055
- return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
2056
- }
2057
2056
  const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAULT_TOOLTIP_ARROW_RADIUS = 2, DEFAULT_TOOLTIP_DISTANCE = 4, DEFAULT_TOOLTIP_PADDING = 4, DEFAULT_FALLBACK_PLACEMENTS = {
2058
2057
  top: ["top-end", "top-start", "bottom", "left", "right"],
2059
2058
  "top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],