@sanity/ui 2.1.14 → 2.1.15-canary.1
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 +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.esm.js +143 -131
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +142 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -131
- package/dist/index.mjs.map +1 -1
- package/package.json +29 -31
- package/src/core/components/autocomplete/autocomplete.tsx +9 -12
- package/src/core/components/dialog/dialog.tsx +20 -32
- package/src/core/components/menu/menu.tsx +8 -6
- package/src/core/components/menu/menuItem.tsx +10 -10
- package/src/core/components/tab/tab.tsx +9 -12
- package/src/core/components/tree/tree.tsx +21 -8
- package/src/core/hooks/useForwardedRef.ts +9 -11
- package/src/core/hooks/useIsomorphicEffect.ts +1 -0
- package/src/core/primitives/checkbox/checkbox.tsx +10 -5
- package/src/core/primitives/popover/popover.tsx +13 -13
- package/src/core/primitives/radio/radio.tsx +8 -3
- package/src/core/primitives/select/select.tsx +8 -3
- package/src/core/primitives/switch/switch.tsx +8 -4
- package/src/core/primitives/textArea/textArea.tsx +8 -3
- package/src/core/primitives/textInput/textInput.tsx +16 -4
- package/src/core/primitives/tooltip/tooltip.tsx +8 -5
- package/src/core/utils/elementQuery/elementQuery.tsx +10 -11
- package/src/core/utils/layer/layer.tsx +8 -13
- package/src/core/utils/virtualList/virtualList.tsx +10 -8
package/dist/index.d.mts
CHANGED
|
@@ -2684,6 +2684,13 @@ export declare function useElementSize(element: HTMLElement | null): ElementSize
|
|
|
2684
2684
|
|
|
2685
2685
|
/**
|
|
2686
2686
|
* @beta
|
|
2687
|
+
* @deprecated use `useImperativeHandle` instead
|
|
2688
|
+
* @example
|
|
2689
|
+
* ```diff
|
|
2690
|
+
* -const ref = useForwardedRef(forwardedRef)
|
|
2691
|
+
* +const ref = useRef(null)
|
|
2692
|
+
* +useImperativeHandle(forwardedRef, () => ref.current)
|
|
2693
|
+
* ```
|
|
2687
2694
|
*/
|
|
2688
2695
|
export declare function useForwardedRef<T>(
|
|
2689
2696
|
ref: React.ForwardedRef<T>,
|
package/dist/index.d.ts
CHANGED
|
@@ -2684,6 +2684,13 @@ export declare function useElementSize(element: HTMLElement | null): ElementSize
|
|
|
2684
2684
|
|
|
2685
2685
|
/**
|
|
2686
2686
|
* @beta
|
|
2687
|
+
* @deprecated use `useImperativeHandle` instead
|
|
2688
|
+
* @example
|
|
2689
|
+
* ```diff
|
|
2690
|
+
* -const ref = useForwardedRef(forwardedRef)
|
|
2691
|
+
* +const ref = useRef(null)
|
|
2692
|
+
* +useImperativeHandle(forwardedRef, () => ref.current)
|
|
2693
|
+
* ```
|
|
2687
2694
|
*/
|
|
2688
2695
|
export declare function useForwardedRef<T>(
|
|
2689
2696
|
ref: React.ForwardedRef<T>,
|
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, createContext, useContext, useSyncExternalStore,
|
|
3
|
+
import { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useImperativeHandle, forwardRef, useId, useCallback, cloneElement, isValidElement, createElement, Component, memo, useReducer, Children, Fragment as Fragment$1, startTransition } from "react";
|
|
4
4
|
import ReactIs, { isElement as isElement$1, isFragment, 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";
|
|
@@ -199,7 +199,16 @@ var freeze = function(obj) {
|
|
|
199
199
|
}
|
|
200
200
|
return DOMRectReadOnly2.prototype.toJSON = function() {
|
|
201
201
|
var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
|
|
202
|
-
return {
|
|
202
|
+
return {
|
|
203
|
+
x,
|
|
204
|
+
y,
|
|
205
|
+
top,
|
|
206
|
+
right,
|
|
207
|
+
bottom,
|
|
208
|
+
left,
|
|
209
|
+
width,
|
|
210
|
+
height
|
|
211
|
+
};
|
|
203
212
|
}, DOMRectReadOnly2.fromRect = function(rectangle) {
|
|
204
213
|
return new DOMRectReadOnly2(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
|
|
205
214
|
}, DOMRectReadOnly2;
|
|
@@ -311,7 +320,9 @@ var freeze = function(obj) {
|
|
|
311
320
|
});
|
|
312
321
|
}, queueMicroTask = function(callback) {
|
|
313
322
|
if (!trigger) {
|
|
314
|
-
var toggle_1 = 0, el_1 = document.createTextNode(""), config = {
|
|
323
|
+
var toggle_1 = 0, el_1 = document.createTextNode(""), config = {
|
|
324
|
+
characterData: !0
|
|
325
|
+
};
|
|
315
326
|
new MutationObserver(function() {
|
|
316
327
|
return notify();
|
|
317
328
|
}).observe(el_1, config), trigger = function() {
|
|
@@ -325,22 +336,12 @@ var freeze = function(obj) {
|
|
|
325
336
|
});
|
|
326
337
|
}, watching = 0, isWatching = function() {
|
|
327
338
|
return !!watching;
|
|
328
|
-
}, CATCH_PERIOD = 250, observerConfig = {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
"animationiteration",
|
|
335
|
-
"keyup",
|
|
336
|
-
"keydown",
|
|
337
|
-
"mouseup",
|
|
338
|
-
"mousedown",
|
|
339
|
-
"mouseover",
|
|
340
|
-
"mouseout",
|
|
341
|
-
"blur",
|
|
342
|
-
"focus"
|
|
343
|
-
], time = function(timeout) {
|
|
339
|
+
}, CATCH_PERIOD = 250, observerConfig = {
|
|
340
|
+
attributes: !0,
|
|
341
|
+
characterData: !0,
|
|
342
|
+
childList: !0,
|
|
343
|
+
subtree: !0
|
|
344
|
+
}, events = ["resize", "load", "transitionend", "animationend", "animationstart", "animationiteration", "keyup", "keydown", "mouseup", "mousedown", "mouseover", "mouseout", "blur", "focus"], time = function(timeout) {
|
|
344
345
|
return timeout === void 0 && (timeout = 0), Date.now() + timeout;
|
|
345
346
|
}, scheduled = !1, Scheduler = function() {
|
|
346
347
|
function Scheduler2() {
|
|
@@ -624,12 +625,9 @@ function getServerSnapshot() {
|
|
|
624
625
|
function usePrefersReducedMotion() {
|
|
625
626
|
return useSyncExternalStore(subscribe$1, getSnapshot, getServerSnapshot);
|
|
626
627
|
}
|
|
627
|
-
const useIsomorphicEffect = typeof window < "u" ? useLayoutEffect : useEffect;
|
|
628
628
|
function useForwardedRef(ref) {
|
|
629
629
|
const innerRef = useRef(null);
|
|
630
|
-
return
|
|
631
|
-
ref && (typeof ref == "function" ? ref(innerRef.current) : ref.current = innerRef.current);
|
|
632
|
-
}), innerRef;
|
|
630
|
+
return useImperativeHandle(ref, () => innerRef.current), innerRef;
|
|
633
631
|
}
|
|
634
632
|
function useCustomValidity(ref, customValidity) {
|
|
635
633
|
useEffect(() => {
|
|
@@ -2375,10 +2373,13 @@ const Root$r = styled.div(checkboxBaseStyles), Input$5 = styled.input(inputEleme
|
|
|
2375
2373
|
readOnly,
|
|
2376
2374
|
style,
|
|
2377
2375
|
...restProps
|
|
2378
|
-
} = props, ref =
|
|
2379
|
-
return
|
|
2376
|
+
} = props, ref = useRef(null);
|
|
2377
|
+
return useImperativeHandle(
|
|
2378
|
+
forwardedRef,
|
|
2379
|
+
() => ref.current
|
|
2380
|
+
), useEffect(() => {
|
|
2380
2381
|
ref.current && (ref.current.indeterminate = indeterminate || !1);
|
|
2381
|
-
}, [indeterminate, ref
|
|
2382
|
+
}, [indeterminate]), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxs(Root$r, { className, "data-ui": "Checkbox", style, children: [
|
|
2382
2383
|
/* @__PURE__ */ jsx(
|
|
2383
2384
|
Input$5,
|
|
2384
2385
|
{
|
|
@@ -2853,16 +2854,15 @@ function findMinBreakpoints(media, width) {
|
|
|
2853
2854
|
media[i] <= width && ret.push(i);
|
|
2854
2855
|
return ret;
|
|
2855
2856
|
}
|
|
2856
|
-
const ElementQuery = forwardRef(function(props,
|
|
2857
|
-
const theme = useTheme_v2(), { children, media = theme.media, ...restProps } = props,
|
|
2857
|
+
const ElementQuery = forwardRef(function(props, forwardedRef) {
|
|
2858
|
+
const theme = useTheme_v2(), { children, media = theme.media, ...restProps } = props, ref = useRef(null), [element, setElement] = useState(null), elementSize = useElementSize(element), width = useMemo(() => {
|
|
2858
2859
|
var _a;
|
|
2859
2860
|
return (_a = elementSize == null ? void 0 : elementSize.border.width) != null ? _a : window.innerWidth;
|
|
2860
|
-
}, [elementSize]), max = useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = useMemo(() => findMinBreakpoints(media, width), [media, width])
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
);
|
|
2861
|
+
}, [elementSize]), max = useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = useMemo(() => findMinBreakpoints(media, width), [media, width]);
|
|
2862
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
2863
|
+
const setRef = useCallback((el) => {
|
|
2864
|
+
ref.current = el, setElement(el);
|
|
2865
|
+
}, []);
|
|
2866
2866
|
return /* @__PURE__ */ jsx(
|
|
2867
2867
|
"div",
|
|
2868
2868
|
{
|
|
@@ -3022,30 +3022,20 @@ function LayerProvider(props) {
|
|
|
3022
3022
|
);
|
|
3023
3023
|
return /* @__PURE__ */ jsx(LayerContext.Provider, { value, children });
|
|
3024
3024
|
}
|
|
3025
|
-
const Root$j = styled.div({ position: "relative" }), LayerChildren = forwardRef(function(props,
|
|
3026
|
-
const { children, onActivate, onFocus, style = EMPTY_RECORD, ...restProps } = props, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = useRef(null),
|
|
3027
|
-
useEffect(() => {
|
|
3025
|
+
const Root$j = styled.div({ position: "relative" }), LayerChildren = forwardRef(function(props, forwardedRef) {
|
|
3026
|
+
const { children, onActivate, onFocus, style = EMPTY_RECORD, ...restProps } = props, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = useRef(null), ref = useRef(null), isTopLayerRef = useRef(isTopLayer);
|
|
3027
|
+
useImperativeHandle(forwardedRef, () => ref.current), useEffect(() => {
|
|
3028
3028
|
isTopLayerRef.current !== isTopLayer && isTopLayer && (onActivate == null || onActivate({ activeElement: lastFocusedRef.current })), isTopLayerRef.current = isTopLayer;
|
|
3029
3029
|
}, [isTopLayer, onActivate]);
|
|
3030
3030
|
const handleFocus = useCallback(
|
|
3031
3031
|
(event) => {
|
|
3032
3032
|
onFocus == null || onFocus(event);
|
|
3033
|
-
const rootElement =
|
|
3033
|
+
const rootElement = ref.current, target = document.activeElement;
|
|
3034
3034
|
!isTopLayer || !rootElement || !target || isHTMLElement(target) && containsOrEqualsElement(rootElement, target) && (lastFocusedRef.current = target);
|
|
3035
3035
|
},
|
|
3036
|
-
[
|
|
3037
|
-
);
|
|
3038
|
-
return /* @__PURE__ */ jsx(
|
|
3039
|
-
Root$j,
|
|
3040
|
-
{
|
|
3041
|
-
...restProps,
|
|
3042
|
-
"data-ui": "Layer",
|
|
3043
|
-
onFocus: handleFocus,
|
|
3044
|
-
ref: forwardedRef,
|
|
3045
|
-
style: { ...style, zIndex },
|
|
3046
|
-
children
|
|
3047
|
-
}
|
|
3036
|
+
[isTopLayer, onFocus]
|
|
3048
3037
|
);
|
|
3038
|
+
return /* @__PURE__ */ jsx(Root$j, { ...restProps, "data-ui": "Layer", onFocus: handleFocus, ref, style: { ...style, zIndex }, children });
|
|
3049
3039
|
}), Layer = forwardRef(function(props, ref) {
|
|
3050
3040
|
const { children, zOffset = 1, ...restProps } = props;
|
|
3051
3041
|
return /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(LayerChildren, { ...restProps, ref, children }) });
|
|
@@ -3111,15 +3101,15 @@ const emptySubscribe$1 = () => () => {
|
|
|
3111
3101
|
position: absolute;
|
|
3112
3102
|
left: 0;
|
|
3113
3103
|
right: 0;
|
|
3114
|
-
`, VirtualList = forwardRef(function(props,
|
|
3115
|
-
const { as = "div", gap = 0, getItemKey, items = [], onChange, renderItem, ...restProps } = props, { space } = useTheme_v2(),
|
|
3116
|
-
useEffect(() => {
|
|
3104
|
+
`, VirtualList = forwardRef(function(props, forwardedRef) {
|
|
3105
|
+
const { as = "div", gap = 0, getItemKey, items = [], onChange, renderItem, ...restProps } = props, { space } = useTheme_v2(), ref = useRef(null), wrapperRef = useRef(null), [scrollTop, setScrollTop] = useState(0), [scrollHeight, setScrollHeight] = useState(0), [itemHeight, setItemHeight] = useState(-1);
|
|
3106
|
+
useImperativeHandle(forwardedRef, () => ref.current), useEffect(() => {
|
|
3117
3107
|
if (!wrapperRef.current) return;
|
|
3118
3108
|
const firstElement = wrapperRef.current.firstChild;
|
|
3119
3109
|
firstElement instanceof HTMLElement && setItemHeight(firstElement.offsetHeight);
|
|
3120
3110
|
}, [renderItem]), useEffect(() => {
|
|
3121
|
-
if (!
|
|
3122
|
-
let _scrollEl =
|
|
3111
|
+
if (!ref.current) return;
|
|
3112
|
+
let _scrollEl = ref.current.parentNode;
|
|
3123
3113
|
for (; _scrollEl && !_isScrollable(_scrollEl); )
|
|
3124
3114
|
_scrollEl = _scrollEl.parentNode;
|
|
3125
3115
|
if (_scrollEl) {
|
|
@@ -3144,7 +3134,7 @@ const emptySubscribe$1 = () => () => {
|
|
|
3144
3134
|
return window.addEventListener("scroll", handleScroll, { passive: !0 }), window.addEventListener("resize", handleResize), setScrollHeight(window.innerHeight), handleScroll(), () => {
|
|
3145
3135
|
window.removeEventListener("scroll", handleScroll), window.removeEventListener("resize", handleResize);
|
|
3146
3136
|
};
|
|
3147
|
-
}, [
|
|
3137
|
+
}, []);
|
|
3148
3138
|
const len = items.length, height = itemHeight ? len * (itemHeight + space[gap]) - space[gap] : 0, fromIndex = height ? Math.max(Math.floor(scrollTop / height * len) - 2, 0) : 0, toIndex = height ? Math.ceil((scrollTop + scrollHeight) / height * len) + 1 : 0;
|
|
3149
3139
|
useEffect(() => {
|
|
3150
3140
|
onChange && onChange({ fromIndex, gap: space[gap], itemHeight, scrollHeight, scrollTop, toIndex });
|
|
@@ -3153,7 +3143,7 @@ const emptySubscribe$1 = () => () => {
|
|
|
3153
3143
|
const itemIndex = fromIndex + _itemIndex, node = renderItem(item), key2 = getItemKey ? getItemKey(item, itemIndex) : itemIndex;
|
|
3154
3144
|
return /* @__PURE__ */ jsx(ItemWrapper, { style: { top: itemIndex * (itemHeight + space[gap]) }, children: node }, key2);
|
|
3155
3145
|
}), [fromIndex, gap, getItemKey, itemHeight, items, renderItem, space, toIndex]), wrapperStyle = useMemo(() => ({ height }), [height]);
|
|
3156
|
-
return /* @__PURE__ */ jsx(Root$h, { as, "data-ui": "VirtualList", ...restProps, ref
|
|
3146
|
+
return /* @__PURE__ */ jsx(Root$h, { as, "data-ui": "VirtualList", ...restProps, ref, children: /* @__PURE__ */ jsx("div", { ref: wrapperRef, style: wrapperStyle, children }) });
|
|
3157
3147
|
}), DEFAULT_POPOVER_DISTANCE = 4, DEFAULT_POPOVER_PADDING = 4, DEFAULT_POPOVER_ARROW_WIDTH = 19, DEFAULT_POPOVER_ARROW_HEIGHT = 8, DEFAULT_POPOVER_ARROW_RADIUS = 2, DEFAULT_POPOVER_MARGINS = [0, 0, 0, 0], DEFAULT_FALLBACK_PLACEMENTS$1 = {
|
|
3158
3148
|
top: ["bottom", "left", "right"],
|
|
3159
3149
|
"top-start": ["bottom-start", "left-start", "right-start"],
|
|
@@ -3299,7 +3289,7 @@ const MotionCard$1 = styled(motion(Card))`
|
|
|
3299
3289
|
);
|
|
3300
3290
|
PopoverCard.displayName = "PopoverCard";
|
|
3301
3291
|
const Popover = memo(
|
|
3302
|
-
forwardRef(function(props,
|
|
3292
|
+
forwardRef(function(props, forwardedRef) {
|
|
3303
3293
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3304
3294
|
const { container, layer } = useTheme_v2(), boundaryElementContext = useBoundaryElement(), {
|
|
3305
3295
|
__unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
|
|
@@ -3331,7 +3321,12 @@ const Popover = memo(
|
|
|
3331
3321
|
zOffset: zOffsetProp = layer.popover.zOffset,
|
|
3332
3322
|
updateRef,
|
|
3333
3323
|
...restProps
|
|
3334
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = (_e = useElementSize(boundaryElement)) == null ? void 0 : _e.border, padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), widthArrayProp = useArrayProp(widthProp), zOffset = useArrayProp(zOffsetProp),
|
|
3324
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = (_e = useElementSize(boundaryElement)) == null ? void 0 : _e.border, padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), widthArrayProp = useArrayProp(widthProp), zOffset = useArrayProp(zOffsetProp), ref = useRef(null), arrowRef = useRef(null), rootBoundary = "viewport";
|
|
3325
|
+
useImperativeHandle(
|
|
3326
|
+
forwardedRef,
|
|
3327
|
+
() => ref.current
|
|
3328
|
+
);
|
|
3329
|
+
const mediaIndex = useMediaIndex(), boundaryWidth = constrainSize || preventOverflow ? boundarySize == null ? void 0 : boundarySize.width : void 0, width = calcCurrentWidth({
|
|
3335
3330
|
container,
|
|
3336
3331
|
mediaIndex,
|
|
3337
3332
|
width: widthArrayProp
|
|
@@ -3345,11 +3340,11 @@ const Popover = memo(
|
|
|
3345
3340
|
}, [maxWidth]);
|
|
3346
3341
|
const referenceWidthRef = useRef();
|
|
3347
3342
|
useEffect(() => {
|
|
3348
|
-
const floatingElement =
|
|
3343
|
+
const floatingElement = ref.current;
|
|
3349
3344
|
if (!open || !floatingElement) return;
|
|
3350
3345
|
const referenceWidth = referenceWidthRef.current;
|
|
3351
3346
|
matchReferenceWidth ? referenceWidth !== void 0 && (floatingElement.style.width = `${referenceWidth}px`) : width !== void 0 && (floatingElement.style.width = `${width}px`), typeof maxWidth == "number" && (floatingElement.style.maxWidth = `${maxWidth}px`);
|
|
3352
|
-
}, [width,
|
|
3347
|
+
}, [width, matchReferenceWidth, maxWidth, open]);
|
|
3353
3348
|
const middleware = useMemo(() => {
|
|
3354
3349
|
const ret = [];
|
|
3355
3350
|
return (constrainSize || preventOverflow) && ret.push(
|
|
@@ -3411,9 +3406,9 @@ const Popover = memo(
|
|
|
3411
3406
|
arrowRef.current = arrowEl;
|
|
3412
3407
|
}, []), setFloating = useCallback(
|
|
3413
3408
|
(node) => {
|
|
3414
|
-
|
|
3409
|
+
ref.current = node, refs.setFloating(node);
|
|
3415
3410
|
},
|
|
3416
|
-
[
|
|
3411
|
+
[refs]
|
|
3417
3412
|
), setReference = useCallback(
|
|
3418
3413
|
(node) => {
|
|
3419
3414
|
refs.setReference(node);
|
|
@@ -3586,8 +3581,11 @@ function inputElementStyle(props) {
|
|
|
3586
3581
|
`;
|
|
3587
3582
|
}
|
|
3588
3583
|
const Root$g = styled.div(radioBaseStyle), Input$4 = styled.input(inputElementStyle), Radio = forwardRef(function(props, forwardedRef) {
|
|
3589
|
-
const { className, disabled, style, customValidity, readOnly, ...restProps } = props, ref =
|
|
3590
|
-
return
|
|
3584
|
+
const { className, disabled, style, customValidity, readOnly, ...restProps } = props, ref = useRef(null);
|
|
3585
|
+
return useImperativeHandle(
|
|
3586
|
+
forwardedRef,
|
|
3587
|
+
() => ref.current
|
|
3588
|
+
), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxs(Root$g, { className, "data-ui": "Radio", style, children: [
|
|
3591
3589
|
/* @__PURE__ */ jsx(
|
|
3592
3590
|
Input$4,
|
|
3593
3591
|
{
|
|
@@ -3748,8 +3746,11 @@ const selectStyle = {
|
|
|
3748
3746
|
readOnly,
|
|
3749
3747
|
space = 3,
|
|
3750
3748
|
...restProps
|
|
3751
|
-
} = props, ref =
|
|
3752
|
-
return
|
|
3749
|
+
} = props, ref = useRef(null);
|
|
3750
|
+
return useImperativeHandle(
|
|
3751
|
+
forwardedRef,
|
|
3752
|
+
() => ref.current
|
|
3753
|
+
), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxs(Root$f, { "data-ui": "Select", children: [
|
|
3753
3754
|
/* @__PURE__ */ jsx(
|
|
3754
3755
|
Input$3,
|
|
3755
3756
|
{
|
|
@@ -3943,10 +3944,13 @@ function switchThumbStyles(props) {
|
|
|
3943
3944
|
`;
|
|
3944
3945
|
}
|
|
3945
3946
|
const Root$d = styled.span(switchBaseStyles), Input$2 = styled.input(switchInputStyles), Representation = styled.span(switchRepresentationStyles), Track = styled.span(switchTrackStyles), Thumb = styled.span(switchThumbStyles), Switch = forwardRef(function(props, forwardedRef) {
|
|
3946
|
-
const { checked, className, disabled, indeterminate, readOnly, style, ...restProps } = props, ref =
|
|
3947
|
-
return
|
|
3947
|
+
const { checked, className, disabled, indeterminate, readOnly, style, ...restProps } = props, ref = useRef(null);
|
|
3948
|
+
return useImperativeHandle(
|
|
3949
|
+
forwardedRef,
|
|
3950
|
+
() => ref.current
|
|
3951
|
+
), useEffect(() => {
|
|
3948
3952
|
ref.current && (ref.current.indeterminate = indeterminate || !1);
|
|
3949
|
-
}, [indeterminate
|
|
3953
|
+
}, [indeterminate]), /* @__PURE__ */ jsxs(Root$d, { className, "data-ui": "Switch", style, children: [
|
|
3950
3954
|
/* @__PURE__ */ jsx(
|
|
3951
3955
|
Input$2,
|
|
3952
3956
|
{
|
|
@@ -3985,8 +3989,11 @@ const Root$d = styled.span(switchBaseStyles), Input$2 = styled.input(switchInput
|
|
|
3985
3989
|
radius = 2,
|
|
3986
3990
|
weight,
|
|
3987
3991
|
...restProps
|
|
3988
|
-
} = props, ref =
|
|
3989
|
-
return
|
|
3992
|
+
} = props, ref = useRef(null), rootTheme = useRootTheme();
|
|
3993
|
+
return useImperativeHandle(
|
|
3994
|
+
forwardedRef,
|
|
3995
|
+
() => ref.current
|
|
3996
|
+
), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsx(Root$c, { "data-ui": "TextArea", children: /* @__PURE__ */ jsxs(InputRoot$1, { children: [
|
|
3990
3997
|
/* @__PURE__ */ jsx(
|
|
3991
3998
|
Input$1,
|
|
3992
3999
|
{
|
|
@@ -4081,8 +4088,11 @@ const Root$d = styled.span(switchBaseStyles), Input$2 = styled.input(switchInput
|
|
|
4081
4088
|
type = "text",
|
|
4082
4089
|
weight,
|
|
4083
4090
|
...restProps
|
|
4084
|
-
} = props, ref =
|
|
4085
|
-
|
|
4091
|
+
} = props, ref = useRef(null), rootTheme = useRootTheme(), fontSize2 = useArrayProp(fontSizeProp), padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), space = useArrayProp(spaceProp), $hasClearButton = !!clearButton, $hasIcon = !!icon, $hasIconRight = !!iconRight, $hasSuffix = !!suffix, $hasPrefix = !!prefix;
|
|
4092
|
+
useImperativeHandle(
|
|
4093
|
+
forwardedRef,
|
|
4094
|
+
() => ref.current
|
|
4095
|
+
), useCustomValidity(ref, customValidity);
|
|
4086
4096
|
const handleClearMouseDown = useCallback((event) => {
|
|
4087
4097
|
event.preventDefault(), event.stopPropagation();
|
|
4088
4098
|
}, []), handleClearClick = useCallback(
|
|
@@ -4329,7 +4339,7 @@ function TooltipDelayGroupProvider(props) {
|
|
|
4329
4339
|
const Root$a = styled(Layer)`
|
|
4330
4340
|
pointer-events: none;
|
|
4331
4341
|
max-width: ${({ $maxWidth }) => $maxWidth}px;
|
|
4332
|
-
`, Tooltip = forwardRef(function(props,
|
|
4342
|
+
`, Tooltip = forwardRef(function(props, forwardedRef) {
|
|
4333
4343
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4334
4344
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
4335
4345
|
animate: _animate = !1,
|
|
@@ -4348,7 +4358,9 @@ const Root$a = styled(Layer)`
|
|
|
4348
4358
|
zOffset = layer.tooltip.zOffset,
|
|
4349
4359
|
delay,
|
|
4350
4360
|
...restProps
|
|
4351
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp),
|
|
4361
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport";
|
|
4362
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
4363
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, documentBodyOffsetWidth = useSyncExternalStore(
|
|
4352
4364
|
emptySubscribe,
|
|
4353
4365
|
() => document.body.offsetWidth,
|
|
4354
4366
|
// We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
|
|
@@ -4458,9 +4470,9 @@ const Root$a = styled(Layer)`
|
|
|
4458
4470
|
[update]
|
|
4459
4471
|
), setFloating = useCallback(
|
|
4460
4472
|
(node) => {
|
|
4461
|
-
|
|
4473
|
+
ref.current = node, refs.setFloating(node);
|
|
4462
4474
|
},
|
|
4463
|
-
[
|
|
4475
|
+
[refs]
|
|
4464
4476
|
), childRef = childProp == null ? void 0 : childProp.ref, setReference = useCallback(
|
|
4465
4477
|
(node) => {
|
|
4466
4478
|
typeof childRef == "function" ? childRef(node) : childRef && (childRef.current = node), setReferenceElement(node);
|
|
@@ -4594,7 +4606,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4594
4606
|
"Meta",
|
|
4595
4607
|
"Tab",
|
|
4596
4608
|
"CapsLock"
|
|
4597
|
-
], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1, InnerAutocomplete = forwardRef(function(props,
|
|
4609
|
+
], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1, InnerAutocomplete = forwardRef(function(props, forwardedRef) {
|
|
4598
4610
|
const {
|
|
4599
4611
|
border: border2 = !0,
|
|
4600
4612
|
customValidity,
|
|
@@ -4633,7 +4645,12 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4633
4645
|
}), { activeValue, focused, listFocused, query, value } = state, defaultRenderOption = useCallback(
|
|
4634
4646
|
({ value: value2 }) => /* @__PURE__ */ jsx(Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsx(Text, { size: fontSize2, textOverflow: "ellipsis", children: value2 }) }),
|
|
4635
4647
|
[fontSize2, paddingProp]
|
|
4636
|
-
), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = useRef(null), resultsPopoverElementRef = useRef(null), inputElementRef = useRef(null), listBoxElementRef = useRef(null), listFocusedRef = useRef(!1), valueRef = useRef(value), valuePropRef = useRef(valueProp), popoverMouseWithinRef = useRef(!1)
|
|
4648
|
+
), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = useRef(null), resultsPopoverElementRef = useRef(null), inputElementRef = useRef(null), listBoxElementRef = useRef(null), listFocusedRef = useRef(!1), valueRef = useRef(value), valuePropRef = useRef(valueProp), popoverMouseWithinRef = useRef(!1);
|
|
4649
|
+
useImperativeHandle(
|
|
4650
|
+
forwardedRef,
|
|
4651
|
+
() => inputElementRef.current
|
|
4652
|
+
);
|
|
4653
|
+
const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useArrayProp(paddingProp), currentOption = useMemo(
|
|
4637
4654
|
() => value !== null ? options.find((o) => o.value === value) : void 0,
|
|
4638
4655
|
[options, value]
|
|
4639
4656
|
), filteredOptions = useMemo(
|
|
@@ -4737,12 +4754,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4737
4754
|
}
|
|
4738
4755
|
}
|
|
4739
4756
|
}, [activeValue, filteredOptions]);
|
|
4740
|
-
const
|
|
4741
|
-
(el) => {
|
|
4742
|
-
inputElementRef.current = el, forwardedRef.current = el;
|
|
4743
|
-
},
|
|
4744
|
-
[forwardedRef]
|
|
4745
|
-
), clearButton = useMemo(() => {
|
|
4757
|
+
const clearButton = useMemo(() => {
|
|
4746
4758
|
if (!loading && !disabled && value)
|
|
4747
4759
|
return {
|
|
4748
4760
|
"aria-label": "Clear",
|
|
@@ -4817,7 +4829,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4817
4829
|
prefix,
|
|
4818
4830
|
radius,
|
|
4819
4831
|
readOnly,
|
|
4820
|
-
ref:
|
|
4832
|
+
ref: inputElementRef,
|
|
4821
4833
|
role: "combobox",
|
|
4822
4834
|
spellCheck: !1,
|
|
4823
4835
|
suffix: suffix || openButtonNode,
|
|
@@ -5079,13 +5091,13 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
|
|
|
5079
5091
|
`, DialogFooter = styled(Box)`
|
|
5080
5092
|
position: relative;
|
|
5081
5093
|
z-index: 3;
|
|
5082
|
-
`, DialogCard = forwardRef(function(props,
|
|
5094
|
+
`, DialogCard = forwardRef(function(props, forwardedRef) {
|
|
5083
5095
|
var _a;
|
|
5084
5096
|
const {
|
|
5085
5097
|
__unstable_autoFocus: autoFocus,
|
|
5086
5098
|
__unstable_hideCloseButton: hideCloseButton,
|
|
5087
5099
|
children,
|
|
5088
|
-
contentRef,
|
|
5100
|
+
contentRef: forwardedContentRef,
|
|
5089
5101
|
footer,
|
|
5090
5102
|
header,
|
|
5091
5103
|
id,
|
|
@@ -5096,10 +5108,13 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
|
|
|
5096
5108
|
scheme,
|
|
5097
5109
|
shadow: shadowProp,
|
|
5098
5110
|
width: widthProp
|
|
5099
|
-
} = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp),
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5111
|
+
} = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp), ref = useRef(null), [rootElement, setRootElement] = useState(null), contentRef = useRef(null), layer = useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
|
|
5112
|
+
useImperativeHandle(forwardedRef, () => ref.current), useImperativeHandle(
|
|
5113
|
+
forwardedContentRef,
|
|
5114
|
+
() => contentRef.current
|
|
5115
|
+
), useEffect(() => {
|
|
5116
|
+
autoFocus && ref.current && focusFirstDescendant(ref.current);
|
|
5117
|
+
}, [autoFocus, ref]), useGlobalKeyDown(
|
|
5103
5118
|
useCallback(
|
|
5104
5119
|
(event) => {
|
|
5105
5120
|
if (!isTopLayer || !onClose) return;
|
|
@@ -5119,17 +5134,9 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
|
|
|
5119
5134
|
),
|
|
5120
5135
|
[rootElement]
|
|
5121
5136
|
);
|
|
5122
|
-
const setRef = useCallback(
|
|
5123
|
-
(el)
|
|
5124
|
-
|
|
5125
|
-
},
|
|
5126
|
-
[forwardedRef]
|
|
5127
|
-
), setContentRef = useCallback(
|
|
5128
|
-
(el) => {
|
|
5129
|
-
localContentRef.current = el, typeof contentRef == "function" ? contentRef(el) : contentRef && (contentRef.current = el);
|
|
5130
|
-
},
|
|
5131
|
-
[contentRef]
|
|
5132
|
-
);
|
|
5137
|
+
const setRef = useCallback((el) => {
|
|
5138
|
+
setRootElement(el), ref.current = el;
|
|
5139
|
+
}, []);
|
|
5133
5140
|
return /* @__PURE__ */ jsx(DialogContainer, { "data-ui": "DialogCard", width, children: /* @__PURE__ */ jsx(DialogCardRoot, { radius, ref: setRef, scheme, shadow, children: /* @__PURE__ */ jsxs(DialogLayout, { direction: "column", children: [
|
|
5134
5141
|
showHeader && /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(Flex, { align: "center", padding: 3, children: [
|
|
5135
5142
|
/* @__PURE__ */ jsx(Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsx(Text, { id: labelId, size: 1, weight: "semibold", children: header }) }),
|
|
@@ -5145,7 +5152,7 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
|
|
|
5145
5152
|
}
|
|
5146
5153
|
) })
|
|
5147
5154
|
] }) }),
|
|
5148
|
-
/* @__PURE__ */ jsx(DialogContent, { flex: 1, ref:
|
|
5155
|
+
/* @__PURE__ */ jsx(DialogContent, { flex: 1, ref: contentRef, tabIndex: -1, children }),
|
|
5149
5156
|
footer && /* @__PURE__ */ jsx(DialogFooter, { children: footer })
|
|
5150
5157
|
] }) }) });
|
|
5151
5158
|
}), Dialog = forwardRef(function(props, ref) {
|
|
@@ -5421,7 +5428,7 @@ function useMenuController(props) {
|
|
|
5421
5428
|
const Root$5 = styled(Box)`
|
|
5422
5429
|
outline: none;
|
|
5423
5430
|
overflow: auto;
|
|
5424
|
-
`, Menu = forwardRef(function(props,
|
|
5431
|
+
`, Menu = forwardRef(function(props, forwardedRef) {
|
|
5425
5432
|
const {
|
|
5426
5433
|
children,
|
|
5427
5434
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -5439,7 +5446,9 @@ const Root$5 = styled(Box)`
|
|
|
5439
5446
|
shouldFocus = props.focusFirst && "first" || props.focusLast && "last" || null,
|
|
5440
5447
|
space = 1,
|
|
5441
5448
|
...restProps
|
|
5442
|
-
} = props,
|
|
5449
|
+
} = props, ref = useRef(null);
|
|
5450
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
5451
|
+
const { isTopLayer } = useLayer(), {
|
|
5443
5452
|
activeElement,
|
|
5444
5453
|
activeIndex,
|
|
5445
5454
|
handleItemMouseEnter,
|
|
@@ -5450,9 +5459,9 @@ const Root$5 = styled(Box)`
|
|
|
5450
5459
|
setRootElement
|
|
5451
5460
|
} = useMenuController({ onKeyDown, originElement, shouldFocus }), handleRefChange = useCallback(
|
|
5452
5461
|
(el) => {
|
|
5453
|
-
setRootElement(el),
|
|
5462
|
+
setRootElement(el), ref.current = el;
|
|
5454
5463
|
},
|
|
5455
|
-
[
|
|
5464
|
+
[setRootElement]
|
|
5456
5465
|
);
|
|
5457
5466
|
useEffect(() => {
|
|
5458
5467
|
onItemSelect && onItemSelect(activeIndex);
|
|
@@ -5887,9 +5896,9 @@ const MenuItem = forwardRef(function(props, forwardedRef) {
|
|
|
5887
5896
|
onItemClick,
|
|
5888
5897
|
onItemMouseEnter = menu.onMouseEnter,
|
|
5889
5898
|
onItemMouseLeave = menu.onMouseLeave
|
|
5890
|
-
} = menu, [rootElement, setRootElement] = useState(null), active = !!activeElement && activeElement === rootElement;
|
|
5891
|
-
useEffect(() => mount(rootElement, selectedProp), [mount, rootElement, selectedProp]);
|
|
5892
|
-
const
|
|
5899
|
+
} = menu, [rootElement, setRootElement] = useState(null), active = !!activeElement && activeElement === rootElement, ref = useRef(null);
|
|
5900
|
+
useImperativeHandle(forwardedRef, () => ref.current), useEffect(() => mount(rootElement, selectedProp), [mount, rootElement, selectedProp]);
|
|
5901
|
+
const handleClick = useCallback(
|
|
5893
5902
|
(event) => {
|
|
5894
5903
|
disabled || (onClick && onClick(event), onItemClick && onItemClick());
|
|
5895
5904
|
},
|
|
@@ -5905,12 +5914,9 @@ const MenuItem = forwardRef(function(props, forwardedRef) {
|
|
|
5905
5914
|
paddingLeft
|
|
5906
5915
|
}),
|
|
5907
5916
|
[padding, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft]
|
|
5908
|
-
), hotkeysFontSize = useArrayProp(fontSize2).map((s) => s - 1), setRef = useCallback(
|
|
5909
|
-
(el)
|
|
5910
|
-
|
|
5911
|
-
},
|
|
5912
|
-
[ref]
|
|
5913
|
-
);
|
|
5917
|
+
), hotkeysFontSize = useArrayProp(fontSize2).map((s) => s - 1), setRef = useCallback((el) => {
|
|
5918
|
+
ref.current = el, setRootElement(el);
|
|
5919
|
+
}, []);
|
|
5914
5920
|
return /* @__PURE__ */ jsxs(
|
|
5915
5921
|
Selectable,
|
|
5916
5922
|
{
|
|
@@ -6049,16 +6055,21 @@ const MenuItem = forwardRef(function(props, forwardedRef) {
|
|
|
6049
6055
|
padding = 2,
|
|
6050
6056
|
selected,
|
|
6051
6057
|
...restProps
|
|
6052
|
-
} = props,
|
|
6058
|
+
} = props, ref = useRef(null), focusedRef = useRef(!1);
|
|
6059
|
+
useImperativeHandle(
|
|
6060
|
+
forwardedRef,
|
|
6061
|
+
() => ref.current
|
|
6062
|
+
);
|
|
6063
|
+
const handleBlur = useCallback(() => {
|
|
6053
6064
|
focusedRef.current = !1;
|
|
6054
6065
|
}, []), handleFocus = useCallback(
|
|
6055
6066
|
(event) => {
|
|
6056
6067
|
focusedRef.current = !0, onFocus && onFocus(event);
|
|
6057
6068
|
},
|
|
6058
6069
|
[onFocus]
|
|
6059
|
-
)
|
|
6070
|
+
);
|
|
6060
6071
|
return useEffect(() => {
|
|
6061
|
-
focused && !focusedRef.current && (
|
|
6072
|
+
focused && !focusedRef.current && (ref.current && ref.current.focus(), focusedRef.current = !0);
|
|
6062
6073
|
}, [focused]), /* @__PURE__ */ jsx(
|
|
6063
6074
|
CustomButton,
|
|
6064
6075
|
{
|
|
@@ -6073,9 +6084,7 @@ const MenuItem = forwardRef(function(props, forwardedRef) {
|
|
|
6073
6084
|
onBlur: handleBlur,
|
|
6074
6085
|
onFocus: handleFocus,
|
|
6075
6086
|
padding,
|
|
6076
|
-
ref
|
|
6077
|
-
elementRef.current = el, ref.current = el;
|
|
6078
|
-
},
|
|
6087
|
+
ref,
|
|
6079
6088
|
role: "tab",
|
|
6080
6089
|
selected,
|
|
6081
6090
|
tabIndex: selected ? 0 : -1,
|
|
@@ -6358,9 +6367,12 @@ function _focusItemElement(el) {
|
|
|
6358
6367
|
}
|
|
6359
6368
|
}
|
|
6360
6369
|
const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalScopedContext(key, null), Tree = memo(
|
|
6361
|
-
forwardRef(function(props,
|
|
6362
|
-
const { children, space = 1, onFocus, ...restProps } = props,
|
|
6363
|
-
|
|
6370
|
+
forwardRef(function(props, forwardedRef) {
|
|
6371
|
+
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);
|
|
6372
|
+
useImperativeHandle(
|
|
6373
|
+
forwardedRef,
|
|
6374
|
+
() => ref.current
|
|
6375
|
+
), useEffect(() => {
|
|
6364
6376
|
focusedElementRef.current = focusedElement;
|
|
6365
6377
|
}, [focusedElement]), useEffect(() => {
|
|
6366
6378
|
stateRef.current = state;
|
|
@@ -6454,12 +6466,12 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
|
|
|
6454
6466
|
[onFocus]
|
|
6455
6467
|
);
|
|
6456
6468
|
return useEffect(() => {
|
|
6457
|
-
if (!
|
|
6469
|
+
if (!ref.current) return;
|
|
6458
6470
|
const _itemElements = Array.from(
|
|
6459
|
-
|
|
6471
|
+
ref.current.querySelectorAll('[data-ui="TreeItem"]')
|
|
6460
6472
|
);
|
|
6461
6473
|
setItemElements(_itemElements);
|
|
6462
|
-
}, [children,
|
|
6474
|
+
}, [children, ref]), /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
6463
6475
|
Stack,
|
|
6464
6476
|
{
|
|
6465
6477
|
as: "ul",
|
|
@@ -6467,7 +6479,7 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
|
|
|
6467
6479
|
...restProps,
|
|
6468
6480
|
onFocus: handleFocus,
|
|
6469
6481
|
onKeyDown: handleKeyDown,
|
|
6470
|
-
ref
|
|
6482
|
+
ref,
|
|
6471
6483
|
role: "tree",
|
|
6472
6484
|
space,
|
|
6473
6485
|
children
|