@sanity/ui 2.1.1 → 2.1.3-canary.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.
package/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import {BaseTheme as BaseTheme_2} from '@sanity/ui/theme'
4
4
  import {Component} from 'react'
5
+ import {Context} from 'react'
5
6
  import {CSSObject} from '@sanity/ui/theme'
6
7
  import {DetailedHTMLProps} from 'react'
7
8
  import {ElementType} from 'react'
@@ -718,7 +719,7 @@ export declare const Dialog: ForwardRefExoticComponent<
718
719
  /**
719
720
  * @internal
720
721
  */
721
- export declare const DialogContext: React.Context<DialogContextValue>
722
+ export declare const DialogContext: Context<DialogContextValue>
722
723
 
723
724
  /**
724
725
  * This API might change. DO NOT USE IN PRODUCTION.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import {BaseTheme as BaseTheme_2} from '@sanity/ui/theme'
4
4
  import {Component} from 'react'
5
+ import {Context} from 'react'
5
6
  import {CSSObject} from '@sanity/ui/theme'
6
7
  import {DetailedHTMLProps} from 'react'
7
8
  import {ElementType} from 'react'
@@ -718,7 +719,7 @@ export declare const Dialog: ForwardRefExoticComponent<
718
719
  /**
719
720
  * @internal
720
721
  */
721
- export declare const DialogContext: React.Context<DialogContextValue>
722
+ export declare const DialogContext: Context<DialogContextValue>
722
723
 
723
724
  /**
724
725
  * This API might change. DO NOT USE IN PRODUCTION.
package/dist/index.esm.js CHANGED
@@ -517,9 +517,11 @@ function getGlobalScope() {
517
517
  return global;
518
518
  throw new Error("@sanity/ui: could not locate global scope");
519
519
  }
520
- const globalScope = getGlobalScope(), key$8 = Symbol.for("@sanity/ui/context/theme");
521
- globalScope[key$8] = globalScope[key$8] || createContext(null);
522
- const ThemeContext = globalScope[key$8];
520
+ const globalScope = getGlobalScope();
521
+ function createGlobalScopedContext(key2, defaultValue) {
522
+ return typeof document > "u" ? createContext(defaultValue) : (globalScope[key2] = globalScope[key2] || createContext(defaultValue), globalScope[key2]);
523
+ }
524
+ const key$8 = Symbol.for("@sanity/ui/context/theme"), ThemeContext = createGlobalScopedContext(key$8, null);
523
525
  function ThemeProvider(props) {
524
526
  const parentTheme = useContext(ThemeContext), {
525
527
  children,
@@ -3091,17 +3093,21 @@ function _isEqual(objA, objB) {
3091
3093
  const keysA = Object.keys(objA), keysB = Object.keys(objB);
3092
3094
  return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
3093
3095
  }
3094
- const __BROWSER__ = typeof document < "u";
3095
3096
  function PortalProvider(props) {
3096
- const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), value = useMemo(() => ({
3097
+ const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(
3098
+ emptySubscribe$1,
3099
+ () => document.body,
3100
+ () => null
3101
+ ), value = useMemo(() => ({
3097
3102
  version: 0,
3098
3103
  boundaryElement: boundaryElement || null,
3099
- element: element || __BROWSER__ && document.body || null,
3104
+ element: element || fallbackElement,
3100
3105
  elements
3101
- }), [boundaryElement, element, elements]);
3106
+ }), [boundaryElement, element, elements, fallbackElement]);
3102
3107
  return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
3103
3108
  }
3104
- const Root$i = styled.div`
3109
+ const emptySubscribe$1 = () => () => {
3110
+ }, Root$i = styled.div`
3105
3111
  display: block;
3106
3112
  width: 0;
3107
3113
  height: 0;
@@ -5057,9 +5063,9 @@ function animationDialogStyle(props) {
5057
5063
  }
5058
5064
  ` : css``;
5059
5065
  }
5060
- const key$3 = Symbol.for("@sanity/ui/context/dialog");
5061
- globalScope[key$3] = globalScope[key$3] || createContext({ version: 0 });
5062
- const DialogContext = globalScope[key$3];
5066
+ const key$3 = Symbol.for("@sanity/ui/context/dialog"), DialogContext = createGlobalScopedContext(key$3, {
5067
+ version: 0
5068
+ });
5063
5069
  function useDialog() {
5064
5070
  return useContext(DialogContext);
5065
5071
  }