@sanity/ui 2.1.2 → 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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +17 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +43 -47
- package/src/core/components/dialog/dialogContext.ts +4 -5
- package/src/core/lib/createGlobalScopedContext.ts +24 -0
- package/src/core/theme/themeContext.ts +2 -5
- package/src/core/theme/themeProvider.tsx +4 -4
- package/src/core/utils/portal/portalProvider.tsx +10 -5
package/dist/index.js
CHANGED
|
@@ -514,9 +514,11 @@ function getGlobalScope() {
|
|
|
514
514
|
return global;
|
|
515
515
|
throw new Error("@sanity/ui: could not locate global scope");
|
|
516
516
|
}
|
|
517
|
-
const globalScope = getGlobalScope()
|
|
518
|
-
|
|
519
|
-
|
|
517
|
+
const globalScope = getGlobalScope();
|
|
518
|
+
function createGlobalScopedContext(key2, defaultValue) {
|
|
519
|
+
return typeof document > "u" ? react.createContext(defaultValue) : (globalScope[key2] = globalScope[key2] || react.createContext(defaultValue), globalScope[key2]);
|
|
520
|
+
}
|
|
521
|
+
const key$8 = Symbol.for("@sanity/ui/context/theme"), ThemeContext = createGlobalScopedContext(key$8, null);
|
|
520
522
|
function ThemeProvider(props) {
|
|
521
523
|
const parentTheme = react.useContext(ThemeContext), {
|
|
522
524
|
children,
|
|
@@ -3088,17 +3090,21 @@ function _isEqual(objA, objB) {
|
|
|
3088
3090
|
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
3089
3091
|
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
3090
3092
|
}
|
|
3091
|
-
const __BROWSER__ = typeof document < "u";
|
|
3092
3093
|
function PortalProvider(props) {
|
|
3093
|
-
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp),
|
|
3094
|
+
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(
|
|
3095
|
+
emptySubscribe$1,
|
|
3096
|
+
() => document.body,
|
|
3097
|
+
() => null
|
|
3098
|
+
), value = react.useMemo(() => ({
|
|
3094
3099
|
version: 0,
|
|
3095
3100
|
boundaryElement: boundaryElement || null,
|
|
3096
|
-
element: element ||
|
|
3101
|
+
element: element || fallbackElement,
|
|
3097
3102
|
elements
|
|
3098
|
-
}), [boundaryElement, element, elements]);
|
|
3103
|
+
}), [boundaryElement, element, elements, fallbackElement]);
|
|
3099
3104
|
return /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children });
|
|
3100
3105
|
}
|
|
3101
|
-
const
|
|
3106
|
+
const emptySubscribe$1 = () => () => {
|
|
3107
|
+
}, Root$i = styledComponents.styled.div`
|
|
3102
3108
|
display: block;
|
|
3103
3109
|
width: 0;
|
|
3104
3110
|
height: 0;
|
|
@@ -5054,9 +5060,9 @@ function animationDialogStyle(props) {
|
|
|
5054
5060
|
}
|
|
5055
5061
|
` : styledComponents.css``;
|
|
5056
5062
|
}
|
|
5057
|
-
const key$3 = Symbol.for("@sanity/ui/context/dialog")
|
|
5058
|
-
|
|
5059
|
-
|
|
5063
|
+
const key$3 = Symbol.for("@sanity/ui/context/dialog"), DialogContext = createGlobalScopedContext(key$3, {
|
|
5064
|
+
version: 0
|
|
5065
|
+
});
|
|
5060
5066
|
function useDialog() {
|
|
5061
5067
|
return react.useContext(DialogContext);
|
|
5062
5068
|
}
|