@sanity/ui 2.6.8 → 2.7.1-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 +29 -2
- package/dist/index.d.ts +29 -2
- package/dist/index.esm.js +87 -73
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +86 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +50 -58
- package/src/core/components/dialog/dialogContext.ts +4 -5
- package/src/core/components/menu/menuContext.ts +4 -3
- package/src/core/components/toast/toastContext.ts +4 -3
- package/src/core/components/tree/treeContext.ts +4 -3
- package/src/core/hooks/index.ts +3 -2
- package/src/core/hooks/useMatchMedia.ts +52 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -10
- package/src/core/hooks/usePrefersDark.ts +10 -55
- package/src/core/hooks/usePrefersReducedMotion.ts +10 -56
- package/src/core/lib/createGlobalScopedContext.ts +15 -6
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +8 -6
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx +4 -3
- package/src/core/theme/themeContext.ts +4 -3
- package/src/core/utils/boundaryElement/boundaryElementContext.ts +1 -3
- package/src/core/utils/layer/layerContext.ts +4 -3
- package/src/core/utils/portal/__workshop__/named.tsx +10 -8
- package/src/core/utils/portal/portalContext.ts +2 -2
- package/src/core/utils/portal/portalProvider.tsx +32 -2
- package/src/core/hooks/_internal/index.ts +0 -1
- package/src/core/hooks/_internal/useUnique.ts +0 -34
package/dist/index.d.mts
CHANGED
|
@@ -2713,6 +2713,18 @@ export declare function useGlobalKeyDown(onKeyDown: (event: KeyboardEvent) => vo
|
|
|
2713
2713
|
*/
|
|
2714
2714
|
export declare function useLayer(): LayerContextValue
|
|
2715
2715
|
|
|
2716
|
+
/**
|
|
2717
|
+
* Efficiently subscribes to `window.matchMedia` queries
|
|
2718
|
+
*
|
|
2719
|
+
* @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Required if the hook is called during SSR (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
|
|
2720
|
+
*
|
|
2721
|
+
* @public
|
|
2722
|
+
*/
|
|
2723
|
+
export declare function useMatchMedia(
|
|
2724
|
+
mediaQueryString: `(${string})`,
|
|
2725
|
+
getServerSnapshot?: () => boolean,
|
|
2726
|
+
): boolean
|
|
2727
|
+
|
|
2716
2728
|
/**
|
|
2717
2729
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
2718
2730
|
* @beta
|
|
@@ -2725,15 +2737,30 @@ export declare function useMediaIndex(): number
|
|
|
2725
2737
|
export declare function usePortal(): PortalContextValue
|
|
2726
2738
|
|
|
2727
2739
|
/**
|
|
2740
|
+
* Returns true if a dark color scheme is preferred, false if a light color scheme is preferred or the preference is not known.
|
|
2741
|
+
*
|
|
2742
|
+
* @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-color-scheme: light)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
|
|
2743
|
+
*
|
|
2744
|
+
* If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
|
|
2745
|
+
* Chrome supports reading the `prefers-color-scheme` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Color-Scheme
|
|
2746
|
+
* @example https://gist.github.com/stipsan/13c0cccf8dfc34f4b44bb1b984baf7df
|
|
2747
|
+
*
|
|
2728
2748
|
* @public
|
|
2729
2749
|
*/
|
|
2730
|
-
export declare function usePrefersDark(): boolean
|
|
2750
|
+
export declare function usePrefersDark(getServerSnapshot?: () => boolean): boolean
|
|
2731
2751
|
|
|
2732
2752
|
/**
|
|
2733
2753
|
* Returns true if motion should be reduced
|
|
2754
|
+
*
|
|
2755
|
+
* @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-reduced-motion: no-preference)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
|
|
2756
|
+
*
|
|
2757
|
+
* If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
|
|
2758
|
+
* Chrome supports reading the `prefers-reduced-motion` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Reduced-Motion
|
|
2759
|
+
* @example https://gist.github.com/stipsan/0c0f839a27842249cada893e9fb7767b
|
|
2760
|
+
*
|
|
2734
2761
|
* @public
|
|
2735
2762
|
*/
|
|
2736
|
-
export declare function usePrefersReducedMotion(): boolean
|
|
2763
|
+
export declare function usePrefersReducedMotion(getServerSnapshot?: () => boolean): boolean
|
|
2737
2764
|
|
|
2738
2765
|
/**
|
|
2739
2766
|
* @public
|
package/dist/index.d.ts
CHANGED
|
@@ -2713,6 +2713,18 @@ export declare function useGlobalKeyDown(onKeyDown: (event: KeyboardEvent) => vo
|
|
|
2713
2713
|
*/
|
|
2714
2714
|
export declare function useLayer(): LayerContextValue
|
|
2715
2715
|
|
|
2716
|
+
/**
|
|
2717
|
+
* Efficiently subscribes to `window.matchMedia` queries
|
|
2718
|
+
*
|
|
2719
|
+
* @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Required if the hook is called during SSR (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
|
|
2720
|
+
*
|
|
2721
|
+
* @public
|
|
2722
|
+
*/
|
|
2723
|
+
export declare function useMatchMedia(
|
|
2724
|
+
mediaQueryString: `(${string})`,
|
|
2725
|
+
getServerSnapshot?: () => boolean,
|
|
2726
|
+
): boolean
|
|
2727
|
+
|
|
2716
2728
|
/**
|
|
2717
2729
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
2718
2730
|
* @beta
|
|
@@ -2725,15 +2737,30 @@ export declare function useMediaIndex(): number
|
|
|
2725
2737
|
export declare function usePortal(): PortalContextValue
|
|
2726
2738
|
|
|
2727
2739
|
/**
|
|
2740
|
+
* Returns true if a dark color scheme is preferred, false if a light color scheme is preferred or the preference is not known.
|
|
2741
|
+
*
|
|
2742
|
+
* @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-color-scheme: light)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
|
|
2743
|
+
*
|
|
2744
|
+
* If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
|
|
2745
|
+
* Chrome supports reading the `prefers-color-scheme` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Color-Scheme
|
|
2746
|
+
* @example https://gist.github.com/stipsan/13c0cccf8dfc34f4b44bb1b984baf7df
|
|
2747
|
+
*
|
|
2728
2748
|
* @public
|
|
2729
2749
|
*/
|
|
2730
|
-
export declare function usePrefersDark(): boolean
|
|
2750
|
+
export declare function usePrefersDark(getServerSnapshot?: () => boolean): boolean
|
|
2731
2751
|
|
|
2732
2752
|
/**
|
|
2733
2753
|
* Returns true if motion should be reduced
|
|
2754
|
+
*
|
|
2755
|
+
* @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-reduced-motion: no-preference)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
|
|
2756
|
+
*
|
|
2757
|
+
* If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
|
|
2758
|
+
* Chrome supports reading the `prefers-reduced-motion` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Reduced-Motion
|
|
2759
|
+
* @example https://gist.github.com/stipsan/0c0f839a27842249cada893e9fb7767b
|
|
2760
|
+
*
|
|
2734
2761
|
* @public
|
|
2735
2762
|
*/
|
|
2736
|
-
export declare function usePrefersReducedMotion(): boolean
|
|
2763
|
+
export declare function usePrefersReducedMotion(getServerSnapshot?: () => boolean): boolean
|
|
2737
2764
|
|
|
2738
2765
|
/**
|
|
2739
2766
|
* @public
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
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";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo, useState, useRef, useEffect,
|
|
3
|
+
import { useMemo, useState, useRef, useEffect, useImperativeHandle, useDebugValue, useSyncExternalStore, createContext, useContext, forwardRef, useId, useCallback, Children, isValidElement, cloneElement, Component, memo, useLayoutEffect, useReducer, Fragment as Fragment$1, startTransition } from "react";
|
|
4
4
|
import ReactIs, { isValidElementType } from "react-is";
|
|
5
5
|
import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
|
|
6
6
|
import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon, ToggleArrowRightIcon } from "@sanity/icons";
|
|
@@ -171,6 +171,12 @@ function useClickOutside(listener, elementsArg = EMPTY_ARRAY, boundaryElement) {
|
|
|
171
171
|
};
|
|
172
172
|
}, [boundaryElement, listener, elements]), setElement;
|
|
173
173
|
}
|
|
174
|
+
function useCustomValidity(ref, customValidity) {
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
var _a;
|
|
177
|
+
(_a = ref.current) == null || _a.setCustomValidity(customValidity || "");
|
|
178
|
+
}, [customValidity, ref]);
|
|
179
|
+
}
|
|
174
180
|
var resizeObservers = [], hasActiveObservations = function() {
|
|
175
181
|
return resizeObservers.some(function(ro) {
|
|
176
182
|
return ro.activeTargets.length > 0;
|
|
@@ -504,9 +510,35 @@ function useElementRect(element) {
|
|
|
504
510
|
const elementSize = useElementSize(element);
|
|
505
511
|
return (elementSize == null ? void 0 : elementSize._contentRect) || null;
|
|
506
512
|
}
|
|
513
|
+
function useForwardedRef(ref) {
|
|
514
|
+
const innerRef = useRef(null);
|
|
515
|
+
return useImperativeHandle(ref, () => innerRef.current), innerRef;
|
|
516
|
+
}
|
|
507
517
|
function useGlobalKeyDown(onKeyDown) {
|
|
508
518
|
return useEffect(() => (addEventListener("keydown", onKeyDown), () => removeEventListener("keydown", onKeyDown)), [onKeyDown]);
|
|
509
519
|
}
|
|
520
|
+
function useMatchMedia(mediaQueryString, getServerSnapshot2) {
|
|
521
|
+
const { subscribe: subscribe2, getSnapshot } = useMemo(() => {
|
|
522
|
+
let MEDIA_QUERY_CACHE;
|
|
523
|
+
function getMatchMedia() {
|
|
524
|
+
return MEDIA_QUERY_CACHE === void 0 && (MEDIA_QUERY_CACHE = window.matchMedia(mediaQueryString)), MEDIA_QUERY_CACHE;
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
subscribe: (onStoreChange) => {
|
|
528
|
+
const matchMedia = getMatchMedia();
|
|
529
|
+
return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
|
|
530
|
+
},
|
|
531
|
+
getSnapshot: () => {
|
|
532
|
+
try {
|
|
533
|
+
return getMatchMedia().matches;
|
|
534
|
+
} catch (err) {
|
|
535
|
+
throw new Error(`Failed to match media query: ${mediaQueryString}`, { cause: err });
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
}, [mediaQueryString]);
|
|
540
|
+
return useDebugValue(mediaQueryString), useSyncExternalStore(subscribe2, getSnapshot, getServerSnapshot2);
|
|
541
|
+
}
|
|
510
542
|
function getGlobalScope() {
|
|
511
543
|
if (typeof globalThis < "u") return globalThis;
|
|
512
544
|
if (typeof window < "u") return window;
|
|
@@ -516,9 +548,13 @@ function getGlobalScope() {
|
|
|
516
548
|
}
|
|
517
549
|
const globalScope = getGlobalScope();
|
|
518
550
|
function createGlobalScopedContext(key2, defaultValue) {
|
|
519
|
-
|
|
551
|
+
const symbol = Symbol.for(key2);
|
|
552
|
+
return typeof document > "u" ? createContext(defaultValue) : (globalScope[symbol] = globalScope[symbol] || createContext(defaultValue), globalScope[symbol]);
|
|
520
553
|
}
|
|
521
|
-
const
|
|
554
|
+
const ThemeContext = createGlobalScopedContext(
|
|
555
|
+
"@sanity/ui/context/theme",
|
|
556
|
+
null
|
|
557
|
+
);
|
|
522
558
|
function ThemeProvider(props) {
|
|
523
559
|
const parentTheme = useContext(ThemeContext), {
|
|
524
560
|
children,
|
|
@@ -549,7 +585,6 @@ function useTheme() {
|
|
|
549
585
|
function useTheme_v2() {
|
|
550
586
|
return getTheme_v2(useTheme$1());
|
|
551
587
|
}
|
|
552
|
-
const MEDIA_STORE_CACHE = /* @__PURE__ */ new WeakMap();
|
|
553
588
|
function _getMediaQuery(media, index) {
|
|
554
589
|
return index === 0 ? `screen and (max-width: ${media[index] - 1}px)` : index === media.length ? `screen and (min-width: ${media[index - 1]}px)` : `screen and (min-width: ${media[index - 1]}px) and (max-width: ${media[index] - 1}px)`;
|
|
555
590
|
}
|
|
@@ -584,57 +619,18 @@ function _createMediaStore(media) {
|
|
|
584
619
|
};
|
|
585
620
|
} };
|
|
586
621
|
}
|
|
587
|
-
function getServerSnapshot
|
|
622
|
+
function getServerSnapshot() {
|
|
588
623
|
return 0;
|
|
589
624
|
}
|
|
590
625
|
function useMediaIndex() {
|
|
591
|
-
const { media } = useTheme_v2();
|
|
592
|
-
|
|
593
|
-
return store || (store = _createMediaStore(media), MEDIA_STORE_CACHE.set(media, store)), useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot$2);
|
|
594
|
-
}
|
|
595
|
-
let MEDIA_QUERY_CACHE$1;
|
|
596
|
-
function getMatchMedia$1() {
|
|
597
|
-
return MEDIA_QUERY_CACHE$1 || (MEDIA_QUERY_CACHE$1 = window.matchMedia("(prefers-color-scheme: dark)")), MEDIA_QUERY_CACHE$1;
|
|
598
|
-
}
|
|
599
|
-
function subscribe$2(onStoreChange) {
|
|
600
|
-
const matchMedia = getMatchMedia$1();
|
|
601
|
-
return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
|
|
602
|
-
}
|
|
603
|
-
function getSnapshot$1() {
|
|
604
|
-
return getMatchMedia$1().matches;
|
|
605
|
-
}
|
|
606
|
-
function getServerSnapshot$1() {
|
|
607
|
-
return !1;
|
|
608
|
-
}
|
|
609
|
-
function usePrefersDark() {
|
|
610
|
-
return useSyncExternalStore(subscribe$2, getSnapshot$1, getServerSnapshot$1);
|
|
611
|
-
}
|
|
612
|
-
let MEDIA_QUERY_CACHE;
|
|
613
|
-
function getMatchMedia() {
|
|
614
|
-
return MEDIA_QUERY_CACHE || (MEDIA_QUERY_CACHE = window.matchMedia("(prefers-reduced-motion: reduce)")), MEDIA_QUERY_CACHE;
|
|
626
|
+
const { media } = useTheme_v2(), store = useMemo(() => _createMediaStore(media), [media]);
|
|
627
|
+
return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
|
|
615
628
|
}
|
|
616
|
-
function
|
|
617
|
-
|
|
618
|
-
return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
|
|
629
|
+
function usePrefersDark(getServerSnapshot2 = () => !1) {
|
|
630
|
+
return useMatchMedia("(prefers-color-scheme: dark)", getServerSnapshot2);
|
|
619
631
|
}
|
|
620
|
-
function
|
|
621
|
-
return
|
|
622
|
-
}
|
|
623
|
-
function getServerSnapshot() {
|
|
624
|
-
return !1;
|
|
625
|
-
}
|
|
626
|
-
function usePrefersReducedMotion() {
|
|
627
|
-
return useSyncExternalStore(subscribe$1, getSnapshot, getServerSnapshot);
|
|
628
|
-
}
|
|
629
|
-
function useForwardedRef(ref) {
|
|
630
|
-
const innerRef = useRef(null);
|
|
631
|
-
return useImperativeHandle(ref, () => innerRef.current), innerRef;
|
|
632
|
-
}
|
|
633
|
-
function useCustomValidity(ref, customValidity) {
|
|
634
|
-
useEffect(() => {
|
|
635
|
-
var _a;
|
|
636
|
-
(_a = ref.current) == null || _a.setCustomValidity(customValidity || "");
|
|
637
|
-
}, [customValidity, ref]);
|
|
632
|
+
function usePrefersReducedMotion(getServerSnapshot2 = () => !1) {
|
|
633
|
+
return useMatchMedia("(prefers-reduced-motion: reduce)", getServerSnapshot2);
|
|
638
634
|
}
|
|
639
635
|
function responsiveBorderStyle() {
|
|
640
636
|
return [border, borderTop, borderRight, borderBottom, borderLeft];
|
|
@@ -2813,8 +2809,8 @@ const Root$k = styled.div(
|
|
|
2813
2809
|
/* @__PURE__ */ jsx(StrokePath, { d: strokePath, mask: "url(#stroke-mask)", strokeWidth: strokeWidth * 2 }),
|
|
2814
2810
|
/* @__PURE__ */ jsx(ShapePath, { d: fillPath })
|
|
2815
2811
|
] }) });
|
|
2816
|
-
}),
|
|
2817
|
-
|
|
2812
|
+
}), BoundaryElementContext = createGlobalScopedContext(
|
|
2813
|
+
"@sanity/ui/context/boundaryElement",
|
|
2818
2814
|
null
|
|
2819
2815
|
);
|
|
2820
2816
|
function BoundaryElementProvider(props) {
|
|
@@ -2903,7 +2899,10 @@ function getLayerContext(contextValue) {
|
|
|
2903
2899
|
return contextValue;
|
|
2904
2900
|
throw new Error("could not get layer context");
|
|
2905
2901
|
}
|
|
2906
|
-
const
|
|
2902
|
+
const LayerContext = createGlobalScopedContext(
|
|
2903
|
+
"@sanity/ui/context/layer",
|
|
2904
|
+
null
|
|
2905
|
+
);
|
|
2907
2906
|
function useLayer() {
|
|
2908
2907
|
const value = useContext(LayerContext);
|
|
2909
2908
|
if (!value)
|
|
@@ -3038,7 +3037,7 @@ const Root$j = styled.div({ position: "relative" }), LayerChildren = forwardRef(
|
|
|
3038
3037
|
}), Layer = forwardRef(function(props, ref) {
|
|
3039
3038
|
const { children, zOffset = 1, ...restProps } = props;
|
|
3040
3039
|
return /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(LayerChildren, { ...restProps, ref, children }) });
|
|
3041
|
-
}), key
|
|
3040
|
+
}), key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
|
|
3042
3041
|
globalScope[elementKey] = null;
|
|
3043
3042
|
const defaultContextValue = {
|
|
3044
3043
|
version: 0,
|
|
@@ -3046,7 +3045,7 @@ const defaultContextValue = {
|
|
|
3046
3045
|
get element() {
|
|
3047
3046
|
return typeof document > "u" ? null : (globalScope[elementKey] || (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey])), globalScope[elementKey]);
|
|
3048
3047
|
}
|
|
3049
|
-
}, PortalContext = createGlobalScopedContext(key
|
|
3048
|
+
}, PortalContext = createGlobalScopedContext(key, defaultContextValue);
|
|
3050
3049
|
function usePortal() {
|
|
3051
3050
|
const value = useContext(PortalContext);
|
|
3052
3051
|
if (!value)
|
|
@@ -3060,16 +3059,6 @@ function Portal(props) {
|
|
|
3060
3059
|
const { children, __unstable_name: name } = props, portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || ((_a = portal.elements) == null ? void 0 : _a.default);
|
|
3061
3060
|
return portalElement ? createPortal(children, portalElement) : null;
|
|
3062
3061
|
}
|
|
3063
|
-
function useUnique(value) {
|
|
3064
|
-
const valueRef = useRef(value);
|
|
3065
|
-
return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
|
|
3066
|
-
}
|
|
3067
|
-
function _isEqual(objA, objB) {
|
|
3068
|
-
if (!objA || !objB)
|
|
3069
|
-
return objA === objB;
|
|
3070
|
-
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
3071
|
-
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
3072
|
-
}
|
|
3073
3062
|
function PortalProvider(props) {
|
|
3074
3063
|
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(
|
|
3075
3064
|
emptySubscribe,
|
|
@@ -3084,7 +3073,18 @@ function PortalProvider(props) {
|
|
|
3084
3073
|
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
3085
3074
|
}
|
|
3086
3075
|
const emptySubscribe = () => () => {
|
|
3087
|
-
}
|
|
3076
|
+
};
|
|
3077
|
+
function useUnique(value) {
|
|
3078
|
+
const valueRef = useRef(value);
|
|
3079
|
+
return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
|
|
3080
|
+
}
|
|
3081
|
+
function _isEqual(objA, objB) {
|
|
3082
|
+
if (!objA || !objB)
|
|
3083
|
+
return objA === objB;
|
|
3084
|
+
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
3085
|
+
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
3086
|
+
}
|
|
3087
|
+
const Root$i = styled.div`
|
|
3088
3088
|
display: block;
|
|
3089
3089
|
width: 0;
|
|
3090
3090
|
height: 0;
|
|
@@ -4318,7 +4318,10 @@ const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAUL
|
|
|
4318
4318
|
})
|
|
4319
4319
|
);
|
|
4320
4320
|
TooltipCard.displayName = "TooltipCard";
|
|
4321
|
-
const
|
|
4321
|
+
const TooltipDelayGroupContext = createGlobalScopedContext(
|
|
4322
|
+
"@sanity/ui/context/tooltipDelayGroup",
|
|
4323
|
+
null
|
|
4324
|
+
);
|
|
4322
4325
|
function useTooltipDelayGroup() {
|
|
4323
4326
|
return useContext(TooltipDelayGroupContext);
|
|
4324
4327
|
}
|
|
@@ -5053,9 +5056,10 @@ function animationDialogStyle(props) {
|
|
|
5053
5056
|
}
|
|
5054
5057
|
` : css``;
|
|
5055
5058
|
}
|
|
5056
|
-
const
|
|
5057
|
-
|
|
5058
|
-
}
|
|
5059
|
+
const DialogContext = createGlobalScopedContext(
|
|
5060
|
+
"@sanity/ui/context/dialog",
|
|
5061
|
+
{ version: 0 }
|
|
5062
|
+
);
|
|
5059
5063
|
function useDialog() {
|
|
5060
5064
|
return useContext(DialogContext);
|
|
5061
5065
|
}
|
|
@@ -5281,7 +5285,10 @@ const Root$6 = styled.kbd`
|
|
|
5281
5285
|
`, Hotkeys = forwardRef(function(props, ref) {
|
|
5282
5286
|
const { fontSize: fontSize2, keys, padding, radius, space: spaceProp = 0.5, ...restProps } = props, space = useArrayProp(spaceProp);
|
|
5283
5287
|
return !keys || keys.length === 0 ? /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(Root$6, { "data-ui": "Hotkeys", ...restProps, ref, children: /* @__PURE__ */ jsx(Inline, { as: "span", space, children: keys.map((key2, i) => /* @__PURE__ */ jsx(Key, { fontSize: fontSize2, padding, radius, children: key2 }, i)) }) });
|
|
5284
|
-
}),
|
|
5288
|
+
}), MenuContext = createGlobalScopedContext(
|
|
5289
|
+
"@sanity/ui/context/menu",
|
|
5290
|
+
null
|
|
5291
|
+
);
|
|
5285
5292
|
function _isFocusable(element) {
|
|
5286
5293
|
return isHTMLAnchorElement(element) && element.getAttribute("data-disabled") !== "true" || isHTMLButtonElement(element) && !element.disabled;
|
|
5287
5294
|
}
|
|
@@ -6255,7 +6262,10 @@ function useMounted() {
|
|
|
6255
6262
|
);
|
|
6256
6263
|
}
|
|
6257
6264
|
const subscribe = () => () => {
|
|
6258
|
-
},
|
|
6265
|
+
}, ToastContext = createGlobalScopedContext(
|
|
6266
|
+
"@sanity/ui/context/toast",
|
|
6267
|
+
null
|
|
6268
|
+
), Root$1 = styled(Layer)`
|
|
6259
6269
|
position: fixed;
|
|
6260
6270
|
top: 0;
|
|
6261
6271
|
left: 0;
|
|
@@ -6414,7 +6424,10 @@ function _focusItemElement(el) {
|
|
|
6414
6424
|
firstChild && firstChild instanceof HTMLElement && firstChild.focus();
|
|
6415
6425
|
}
|
|
6416
6426
|
}
|
|
6417
|
-
const
|
|
6427
|
+
const TreeContext = createGlobalScopedContext(
|
|
6428
|
+
"@sanity/ui/context/tree",
|
|
6429
|
+
null
|
|
6430
|
+
), Tree = memo(
|
|
6418
6431
|
forwardRef(function(props, forwardedRef) {
|
|
6419
6432
|
const { children, space = 1, onFocus, ...restProps } = props, ref = useRef(null), [focusedElement, setFocusedElement] = useState(null), focusedElementRef = useRef(focusedElement), path = useMemo(() => [], []), [itemElements, setItemElements] = useState([]), [state, setState] = useState({}), stateRef = useRef(state);
|
|
6420
6433
|
useImperativeHandle(
|
|
@@ -6867,6 +6880,7 @@ export {
|
|
|
6867
6880
|
useForwardedRef,
|
|
6868
6881
|
useGlobalKeyDown,
|
|
6869
6882
|
useLayer,
|
|
6883
|
+
useMatchMedia,
|
|
6870
6884
|
useMediaIndex,
|
|
6871
6885
|
usePortal,
|
|
6872
6886
|
usePrefersDark,
|