@sanity/ui 2.6.8 → 2.7.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 +79 -73
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +78 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +26 -26
- 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 +46 -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,27 @@ 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
|
+
const getMatchMedia = () => (MEDIA_QUERY_CACHE || (MEDIA_QUERY_CACHE = window.matchMedia(mediaQueryString)), MEDIA_QUERY_CACHE);
|
|
524
|
+
return {
|
|
525
|
+
subscribe: (onStoreChange) => {
|
|
526
|
+
const matchMedia = getMatchMedia();
|
|
527
|
+
return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
|
|
528
|
+
},
|
|
529
|
+
getSnapshot: () => getMatchMedia().matches
|
|
530
|
+
};
|
|
531
|
+
}, [mediaQueryString]);
|
|
532
|
+
return useDebugValue(mediaQueryString), useSyncExternalStore(subscribe2, getSnapshot, getServerSnapshot2);
|
|
533
|
+
}
|
|
510
534
|
function getGlobalScope() {
|
|
511
535
|
if (typeof globalThis < "u") return globalThis;
|
|
512
536
|
if (typeof window < "u") return window;
|
|
@@ -516,9 +540,13 @@ function getGlobalScope() {
|
|
|
516
540
|
}
|
|
517
541
|
const globalScope = getGlobalScope();
|
|
518
542
|
function createGlobalScopedContext(key2, defaultValue) {
|
|
519
|
-
|
|
543
|
+
const symbol = Symbol.for(key2);
|
|
544
|
+
return typeof document > "u" ? createContext(defaultValue) : (globalScope[symbol] = globalScope[symbol] || createContext(defaultValue), globalScope[symbol]);
|
|
520
545
|
}
|
|
521
|
-
const
|
|
546
|
+
const ThemeContext = createGlobalScopedContext(
|
|
547
|
+
"@sanity/ui/context/theme",
|
|
548
|
+
null
|
|
549
|
+
);
|
|
522
550
|
function ThemeProvider(props) {
|
|
523
551
|
const parentTheme = useContext(ThemeContext), {
|
|
524
552
|
children,
|
|
@@ -549,7 +577,6 @@ function useTheme() {
|
|
|
549
577
|
function useTheme_v2() {
|
|
550
578
|
return getTheme_v2(useTheme$1());
|
|
551
579
|
}
|
|
552
|
-
const MEDIA_STORE_CACHE = /* @__PURE__ */ new WeakMap();
|
|
553
580
|
function _getMediaQuery(media, index) {
|
|
554
581
|
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
582
|
}
|
|
@@ -584,57 +611,18 @@ function _createMediaStore(media) {
|
|
|
584
611
|
};
|
|
585
612
|
} };
|
|
586
613
|
}
|
|
587
|
-
function getServerSnapshot
|
|
614
|
+
function getServerSnapshot() {
|
|
588
615
|
return 0;
|
|
589
616
|
}
|
|
590
617
|
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;
|
|
618
|
+
const { media } = useTheme_v2(), store = useMemo(() => _createMediaStore(media), [media]);
|
|
619
|
+
return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
|
|
598
620
|
}
|
|
599
|
-
function
|
|
600
|
-
|
|
601
|
-
return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
|
|
621
|
+
function usePrefersDark(getServerSnapshot2 = () => !1) {
|
|
622
|
+
return useMatchMedia("(prefers-color-scheme: dark)", getServerSnapshot2);
|
|
602
623
|
}
|
|
603
|
-
function
|
|
604
|
-
return
|
|
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;
|
|
615
|
-
}
|
|
616
|
-
function subscribe$1(onStoreChange) {
|
|
617
|
-
const matchMedia = getMatchMedia();
|
|
618
|
-
return matchMedia.addEventListener("change", onStoreChange), () => matchMedia.removeEventListener("change", onStoreChange);
|
|
619
|
-
}
|
|
620
|
-
function getSnapshot() {
|
|
621
|
-
return getMatchMedia().matches;
|
|
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]);
|
|
624
|
+
function usePrefersReducedMotion(getServerSnapshot2 = () => !1) {
|
|
625
|
+
return useMatchMedia("(prefers-reduced-motion: reduce)", getServerSnapshot2);
|
|
638
626
|
}
|
|
639
627
|
function responsiveBorderStyle() {
|
|
640
628
|
return [border, borderTop, borderRight, borderBottom, borderLeft];
|
|
@@ -2813,8 +2801,8 @@ const Root$k = styled.div(
|
|
|
2813
2801
|
/* @__PURE__ */ jsx(StrokePath, { d: strokePath, mask: "url(#stroke-mask)", strokeWidth: strokeWidth * 2 }),
|
|
2814
2802
|
/* @__PURE__ */ jsx(ShapePath, { d: fillPath })
|
|
2815
2803
|
] }) });
|
|
2816
|
-
}),
|
|
2817
|
-
|
|
2804
|
+
}), BoundaryElementContext = createGlobalScopedContext(
|
|
2805
|
+
"@sanity/ui/context/boundaryElement",
|
|
2818
2806
|
null
|
|
2819
2807
|
);
|
|
2820
2808
|
function BoundaryElementProvider(props) {
|
|
@@ -2903,7 +2891,10 @@ function getLayerContext(contextValue) {
|
|
|
2903
2891
|
return contextValue;
|
|
2904
2892
|
throw new Error("could not get layer context");
|
|
2905
2893
|
}
|
|
2906
|
-
const
|
|
2894
|
+
const LayerContext = createGlobalScopedContext(
|
|
2895
|
+
"@sanity/ui/context/layer",
|
|
2896
|
+
null
|
|
2897
|
+
);
|
|
2907
2898
|
function useLayer() {
|
|
2908
2899
|
const value = useContext(LayerContext);
|
|
2909
2900
|
if (!value)
|
|
@@ -3038,7 +3029,7 @@ const Root$j = styled.div({ position: "relative" }), LayerChildren = forwardRef(
|
|
|
3038
3029
|
}), Layer = forwardRef(function(props, ref) {
|
|
3039
3030
|
const { children, zOffset = 1, ...restProps } = props;
|
|
3040
3031
|
return /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(LayerChildren, { ...restProps, ref, children }) });
|
|
3041
|
-
}), key
|
|
3032
|
+
}), key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
|
|
3042
3033
|
globalScope[elementKey] = null;
|
|
3043
3034
|
const defaultContextValue = {
|
|
3044
3035
|
version: 0,
|
|
@@ -3046,7 +3037,7 @@ const defaultContextValue = {
|
|
|
3046
3037
|
get element() {
|
|
3047
3038
|
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
3039
|
}
|
|
3049
|
-
}, PortalContext = createGlobalScopedContext(key
|
|
3040
|
+
}, PortalContext = createGlobalScopedContext(key, defaultContextValue);
|
|
3050
3041
|
function usePortal() {
|
|
3051
3042
|
const value = useContext(PortalContext);
|
|
3052
3043
|
if (!value)
|
|
@@ -3060,16 +3051,6 @@ function Portal(props) {
|
|
|
3060
3051
|
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
3052
|
return portalElement ? createPortal(children, portalElement) : null;
|
|
3062
3053
|
}
|
|
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
3054
|
function PortalProvider(props) {
|
|
3074
3055
|
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(
|
|
3075
3056
|
emptySubscribe,
|
|
@@ -3084,7 +3065,18 @@ function PortalProvider(props) {
|
|
|
3084
3065
|
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
3085
3066
|
}
|
|
3086
3067
|
const emptySubscribe = () => () => {
|
|
3087
|
-
}
|
|
3068
|
+
};
|
|
3069
|
+
function useUnique(value) {
|
|
3070
|
+
const valueRef = useRef(value);
|
|
3071
|
+
return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
|
|
3072
|
+
}
|
|
3073
|
+
function _isEqual(objA, objB) {
|
|
3074
|
+
if (!objA || !objB)
|
|
3075
|
+
return objA === objB;
|
|
3076
|
+
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
3077
|
+
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
3078
|
+
}
|
|
3079
|
+
const Root$i = styled.div`
|
|
3088
3080
|
display: block;
|
|
3089
3081
|
width: 0;
|
|
3090
3082
|
height: 0;
|
|
@@ -4318,7 +4310,10 @@ const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAUL
|
|
|
4318
4310
|
})
|
|
4319
4311
|
);
|
|
4320
4312
|
TooltipCard.displayName = "TooltipCard";
|
|
4321
|
-
const
|
|
4313
|
+
const TooltipDelayGroupContext = createGlobalScopedContext(
|
|
4314
|
+
"@sanity/ui/context/tooltipDelayGroup",
|
|
4315
|
+
null
|
|
4316
|
+
);
|
|
4322
4317
|
function useTooltipDelayGroup() {
|
|
4323
4318
|
return useContext(TooltipDelayGroupContext);
|
|
4324
4319
|
}
|
|
@@ -5053,9 +5048,10 @@ function animationDialogStyle(props) {
|
|
|
5053
5048
|
}
|
|
5054
5049
|
` : css``;
|
|
5055
5050
|
}
|
|
5056
|
-
const
|
|
5057
|
-
|
|
5058
|
-
}
|
|
5051
|
+
const DialogContext = createGlobalScopedContext(
|
|
5052
|
+
"@sanity/ui/context/dialog",
|
|
5053
|
+
{ version: 0 }
|
|
5054
|
+
);
|
|
5059
5055
|
function useDialog() {
|
|
5060
5056
|
return useContext(DialogContext);
|
|
5061
5057
|
}
|
|
@@ -5281,7 +5277,10 @@ const Root$6 = styled.kbd`
|
|
|
5281
5277
|
`, Hotkeys = forwardRef(function(props, ref) {
|
|
5282
5278
|
const { fontSize: fontSize2, keys, padding, radius, space: spaceProp = 0.5, ...restProps } = props, space = useArrayProp(spaceProp);
|
|
5283
5279
|
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
|
-
}),
|
|
5280
|
+
}), MenuContext = createGlobalScopedContext(
|
|
5281
|
+
"@sanity/ui/context/menu",
|
|
5282
|
+
null
|
|
5283
|
+
);
|
|
5285
5284
|
function _isFocusable(element) {
|
|
5286
5285
|
return isHTMLAnchorElement(element) && element.getAttribute("data-disabled") !== "true" || isHTMLButtonElement(element) && !element.disabled;
|
|
5287
5286
|
}
|
|
@@ -6255,7 +6254,10 @@ function useMounted() {
|
|
|
6255
6254
|
);
|
|
6256
6255
|
}
|
|
6257
6256
|
const subscribe = () => () => {
|
|
6258
|
-
},
|
|
6257
|
+
}, ToastContext = createGlobalScopedContext(
|
|
6258
|
+
"@sanity/ui/context/toast",
|
|
6259
|
+
null
|
|
6260
|
+
), Root$1 = styled(Layer)`
|
|
6259
6261
|
position: fixed;
|
|
6260
6262
|
top: 0;
|
|
6261
6263
|
left: 0;
|
|
@@ -6414,7 +6416,10 @@ function _focusItemElement(el) {
|
|
|
6414
6416
|
firstChild && firstChild instanceof HTMLElement && firstChild.focus();
|
|
6415
6417
|
}
|
|
6416
6418
|
}
|
|
6417
|
-
const
|
|
6419
|
+
const TreeContext = createGlobalScopedContext(
|
|
6420
|
+
"@sanity/ui/context/tree",
|
|
6421
|
+
null
|
|
6422
|
+
), Tree = memo(
|
|
6418
6423
|
forwardRef(function(props, forwardedRef) {
|
|
6419
6424
|
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
6425
|
useImperativeHandle(
|
|
@@ -6867,6 +6872,7 @@ export {
|
|
|
6867
6872
|
useForwardedRef,
|
|
6868
6873
|
useGlobalKeyDown,
|
|
6869
6874
|
useLayer,
|
|
6875
|
+
useMatchMedia,
|
|
6870
6876
|
useMediaIndex,
|
|
6871
6877
|
usePortal,
|
|
6872
6878
|
usePrefersDark,
|