@sanity/ui 2.1.5 → 2.1.7
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 +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.esm.js +40 -75
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +40 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -75
- package/dist/index.mjs.map +1 -1
- package/dist/theme.esm.js +9 -18
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +9 -18
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +9 -18
- package/dist/theme.mjs.map +1 -1
- package/package.json +8 -8
- package/src/core/components/menu/menuButton.tsx +13 -15
package/dist/index.mjs
CHANGED
|
@@ -154,8 +154,7 @@ function useClickOutside(listener, elementsArg = EMPTY_ARRAY, boundaryElement) {
|
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
}, [element, elementsArg]), useEffect(() => {
|
|
157
|
-
if (!listener)
|
|
158
|
-
return;
|
|
157
|
+
if (!listener) return;
|
|
159
158
|
const handleWindowMouseDown = (evt) => {
|
|
160
159
|
const target = evt.target;
|
|
161
160
|
if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) {
|
|
@@ -507,14 +506,10 @@ function useGlobalKeyDown(onKeyDown) {
|
|
|
507
506
|
return useEffect(() => (addEventListener("keydown", onKeyDown), () => removeEventListener("keydown", onKeyDown)), [onKeyDown]);
|
|
508
507
|
}
|
|
509
508
|
function getGlobalScope() {
|
|
510
|
-
if (typeof globalThis < "u")
|
|
511
|
-
|
|
512
|
-
if (typeof
|
|
513
|
-
|
|
514
|
-
if (typeof self < "u")
|
|
515
|
-
return self;
|
|
516
|
-
if (typeof global < "u")
|
|
517
|
-
return global;
|
|
509
|
+
if (typeof globalThis < "u") return globalThis;
|
|
510
|
+
if (typeof window < "u") return window;
|
|
511
|
+
if (typeof self < "u") return self;
|
|
512
|
+
if (typeof global < "u") return global;
|
|
518
513
|
throw new Error("@sanity/ui: could not locate global scope");
|
|
519
514
|
}
|
|
520
515
|
const globalScope = getGlobalScope();
|
|
@@ -571,8 +566,7 @@ function _createMediaStore(media) {
|
|
|
571
566
|
};
|
|
572
567
|
return { getSnapshot: () => {
|
|
573
568
|
for (const { index, mq } of getSizes())
|
|
574
|
-
if (mq.matches)
|
|
575
|
-
return index;
|
|
569
|
+
if (mq.matches) return index;
|
|
576
570
|
return 0;
|
|
577
571
|
}, subscribe: (onStoreChange) => {
|
|
578
572
|
const disposeFns = [];
|
|
@@ -1190,8 +1184,7 @@ function toBoxShadow(shadow, color) {
|
|
|
1190
1184
|
return `${shadow.map(rem).join(" ")} ${color}`;
|
|
1191
1185
|
}
|
|
1192
1186
|
function shadowStyle(shadow, outlineWidth = 1) {
|
|
1193
|
-
if (!shadow)
|
|
1194
|
-
return EMPTY_RECORD;
|
|
1187
|
+
if (!shadow) return EMPTY_RECORD;
|
|
1195
1188
|
const outline = `0 0 0 ${rem(outlineWidth)} var(--card-shadow-outline-color)`, umbra = toBoxShadow(shadow.umbra, "var(--card-shadow-umbra-color)"), penumbra = toBoxShadow(shadow.penumbra, "var(--card-shadow-penumbra-color)"), ambient = toBoxShadow(shadow.ambient, "var(--card-shadow-ambient-color)");
|
|
1196
1189
|
return { boxShadow: `${outline}, ${umbra}, ${penumbra}, ${ambient}` };
|
|
1197
1190
|
}
|
|
@@ -1426,8 +1419,7 @@ const Root$B = styled.div(
|
|
|
1426
1419
|
animateArrowFrom || arrowPositionProp || "inside"
|
|
1427
1420
|
), [imageFailed, setImageFailed] = useState(!1), imageId = `avatar-image-${elementId}`;
|
|
1428
1421
|
useEffect(() => {
|
|
1429
|
-
if (arrowPosition === arrowPositionProp)
|
|
1430
|
-
return;
|
|
1422
|
+
if (arrowPosition === arrowPositionProp) return;
|
|
1431
1423
|
const raf = requestAnimationFrame(() => setArrowPosition(arrowPositionProp));
|
|
1432
1424
|
return () => cancelAnimationFrame(raf);
|
|
1433
1425
|
}, [arrowPosition, arrowPositionProp]), useEffect(() => {
|
|
@@ -2883,7 +2875,7 @@ const ElementQuery = forwardRef(function(props, ref) {
|
|
|
2883
2875
|
}
|
|
2884
2876
|
);
|
|
2885
2877
|
});
|
|
2886
|
-
var __defProp = Object.defineProperty, __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value, __publicField = (obj, key2, value) =>
|
|
2878
|
+
var __defProp = Object.defineProperty, __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value, __publicField = (obj, key2, value) => __defNormalProp(obj, key2 + "", value);
|
|
2887
2879
|
class ErrorBoundary extends Component {
|
|
2888
2880
|
constructor() {
|
|
2889
2881
|
super(...arguments), __publicField(this, "state", { error: null });
|
|
@@ -2994,8 +2986,7 @@ function focusLastDescendant(element) {
|
|
|
2994
2986
|
return !1;
|
|
2995
2987
|
}
|
|
2996
2988
|
function _isScrollable(el) {
|
|
2997
|
-
if (!(el instanceof Element))
|
|
2998
|
-
return !1;
|
|
2989
|
+
if (!(el instanceof Element)) return !1;
|
|
2999
2990
|
const style = window.getComputedStyle(el);
|
|
3000
2991
|
return style.overflowX.includes("auto") || style.overflowX.includes("scroll") || style.overflowY.includes("auto") || style.overflowY.includes("scroll");
|
|
3001
2992
|
}
|
|
@@ -3123,20 +3114,17 @@ const emptySubscribe$1 = () => () => {
|
|
|
3123
3114
|
`, VirtualList = forwardRef(function(props, ref) {
|
|
3124
3115
|
const { as = "div", gap = 0, getItemKey, items = [], onChange, renderItem, ...restProps } = props, { space } = useTheme_v2(), forwardedRef = useForwardedRef(ref), wrapperRef = useRef(null), [scrollTop, setScrollTop] = useState(0), [scrollHeight, setScrollHeight] = useState(0), [itemHeight, setItemHeight] = useState(-1);
|
|
3125
3116
|
useEffect(() => {
|
|
3126
|
-
if (!wrapperRef.current)
|
|
3127
|
-
return;
|
|
3117
|
+
if (!wrapperRef.current) return;
|
|
3128
3118
|
const firstElement = wrapperRef.current.firstChild;
|
|
3129
3119
|
firstElement instanceof HTMLElement && setItemHeight(firstElement.offsetHeight);
|
|
3130
3120
|
}, [renderItem]), useEffect(() => {
|
|
3131
|
-
if (!forwardedRef.current)
|
|
3132
|
-
return;
|
|
3121
|
+
if (!forwardedRef.current) return;
|
|
3133
3122
|
let _scrollEl = forwardedRef.current.parentNode;
|
|
3134
3123
|
for (; _scrollEl && !_isScrollable(_scrollEl); )
|
|
3135
3124
|
_scrollEl = _scrollEl.parentNode;
|
|
3136
3125
|
if (_scrollEl) {
|
|
3137
3126
|
const scrollEl = _scrollEl;
|
|
3138
|
-
if (!(scrollEl instanceof HTMLElement))
|
|
3139
|
-
return;
|
|
3127
|
+
if (!(scrollEl instanceof HTMLElement)) return;
|
|
3140
3128
|
const handleScroll2 = () => {
|
|
3141
3129
|
setScrollTop(scrollEl.scrollTop);
|
|
3142
3130
|
};
|
|
@@ -3358,8 +3346,7 @@ const Popover = memo(
|
|
|
3358
3346
|
const referenceWidthRef = useRef();
|
|
3359
3347
|
useEffect(() => {
|
|
3360
3348
|
const floatingElement = forwardedRef.current;
|
|
3361
|
-
if (!open || !floatingElement)
|
|
3362
|
-
return;
|
|
3349
|
+
if (!open || !floatingElement) return;
|
|
3363
3350
|
const referenceWidth = referenceWidthRef.current;
|
|
3364
3351
|
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`);
|
|
3365
3352
|
}, [width, forwardedRef, matchReferenceWidth, maxWidth, open]);
|
|
@@ -4231,8 +4218,7 @@ function useDelayedState(initialState) {
|
|
|
4231
4218
|
const action = () => {
|
|
4232
4219
|
setState(nextState);
|
|
4233
4220
|
};
|
|
4234
|
-
if (delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), !delay)
|
|
4235
|
-
return action();
|
|
4221
|
+
if (delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), !delay) return action();
|
|
4236
4222
|
delayedAction.current = setTimeout(action, delay);
|
|
4237
4223
|
}, []);
|
|
4238
4224
|
return [state, onStateChange];
|
|
@@ -4445,8 +4431,7 @@ const Root$a = styled(Layer)`
|
|
|
4445
4431
|
[childProp == null ? void 0 : childProp.props, handleIsOpenChange]
|
|
4446
4432
|
);
|
|
4447
4433
|
useEffect(() => {
|
|
4448
|
-
if (!showTooltip)
|
|
4449
|
-
return;
|
|
4434
|
+
if (!showTooltip) return;
|
|
4450
4435
|
function handleWindowMouseMove(event) {
|
|
4451
4436
|
referenceElement && (referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target) || (handleIsOpenChange(!1), window.removeEventListener("mousemove", handleWindowMouseMove)));
|
|
4452
4437
|
}
|
|
@@ -4458,8 +4443,7 @@ const Root$a = styled(Layer)`
|
|
|
4458
4443
|
}, [disabled, handleIsOpenChange, showTooltip]), useEffect(() => {
|
|
4459
4444
|
!content && showTooltip && handleIsOpenChange(!1);
|
|
4460
4445
|
}, [content, handleIsOpenChange, showTooltip]), useEffect(() => refs.setReference(referenceElement), [referenceElement, refs]), useEffect(() => {
|
|
4461
|
-
if (!showTooltip)
|
|
4462
|
-
return;
|
|
4446
|
+
if (!showTooltip) return;
|
|
4463
4447
|
function handleWindowKeyDown(event) {
|
|
4464
4448
|
event.key === "Escape" && handleIsOpenChange(!1, !0);
|
|
4465
4449
|
}
|
|
@@ -4500,10 +4484,8 @@ const Root$a = styled(Layer)`
|
|
|
4500
4484
|
handleMouseLeave,
|
|
4501
4485
|
setReference
|
|
4502
4486
|
]);
|
|
4503
|
-
if (!child)
|
|
4504
|
-
|
|
4505
|
-
if (disabled)
|
|
4506
|
-
return child;
|
|
4487
|
+
if (!child) return /* @__PURE__ */ jsx(Fragment, {});
|
|
4488
|
+
if (disabled) return child;
|
|
4507
4489
|
const tooltip = /* @__PURE__ */ jsx(
|
|
4508
4490
|
Root$a,
|
|
4509
4491
|
{
|
|
@@ -4691,15 +4673,13 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4691
4673
|
(event) => {
|
|
4692
4674
|
var _a, _b;
|
|
4693
4675
|
if (event.key === "ArrowDown") {
|
|
4694
|
-
if (event.preventDefault(), !filteredOptionsLen)
|
|
4695
|
-
return;
|
|
4676
|
+
if (event.preventDefault(), !filteredOptionsLen) return;
|
|
4696
4677
|
const activeOption = filteredOptions.find((o) => o.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
|
|
4697
4678
|
nextActiveOption && dispatch({ type: "root/setActiveValue", value: nextActiveOption.value, listFocused: !0 });
|
|
4698
4679
|
return;
|
|
4699
4680
|
}
|
|
4700
4681
|
if (event.key === "ArrowUp") {
|
|
4701
|
-
if (event.preventDefault(), !filteredOptionsLen)
|
|
4702
|
-
return;
|
|
4682
|
+
if (event.preventDefault(), !filteredOptionsLen) return;
|
|
4703
4683
|
const activeOption = filteredOptions.find((o) => o.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[activeIndex === -1 ? filteredOptionsLen - 1 : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen];
|
|
4704
4684
|
nextActiveOption && dispatch({ type: "root/setActiveValue", value: nextActiveOption.value, listFocused: !0 });
|
|
4705
4685
|
return;
|
|
@@ -4746,8 +4726,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4746
4726
|
!focused && valueRef.current && dispatch({ type: "root/setActiveValue", value: valueRef.current });
|
|
4747
4727
|
}, [focused]), useEffect(() => {
|
|
4748
4728
|
const listElement = listBoxElementRef.current;
|
|
4749
|
-
if (!listElement)
|
|
4750
|
-
return;
|
|
4729
|
+
if (!listElement) return;
|
|
4751
4730
|
const activeOption = filteredOptions.find((o) => o.value === activeValue);
|
|
4752
4731
|
if (activeOption) {
|
|
4753
4732
|
const activeIndex = filteredOptions.indexOf(activeOption), activeItemElement = listElement.childNodes[activeIndex];
|
|
@@ -5123,8 +5102,7 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
|
|
|
5123
5102
|
}, [autoFocus, forwardedRef]), useGlobalKeyDown(
|
|
5124
5103
|
useCallback(
|
|
5125
5104
|
(event) => {
|
|
5126
|
-
if (!isTopLayer || !onClose)
|
|
5127
|
-
return;
|
|
5105
|
+
if (!isTopLayer || !onClose) return;
|
|
5128
5106
|
const target = document.activeElement;
|
|
5129
5107
|
target && !isTargetWithinScope(boundaryElement, portalElement, target) || event.key === "Escape" && (event.preventDefault(), event.stopPropagation(), onClose());
|
|
5130
5108
|
},
|
|
@@ -5133,8 +5111,7 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
|
|
|
5133
5111
|
), useClickOutside(
|
|
5134
5112
|
useCallback(
|
|
5135
5113
|
(event) => {
|
|
5136
|
-
if (!isTopLayer || !onClickOutside)
|
|
5137
|
-
return;
|
|
5114
|
+
if (!isTopLayer || !onClickOutside) return;
|
|
5138
5115
|
const target = event.target;
|
|
5139
5116
|
target && !isTargetWithinScope(boundaryElement, portalElement, target) || onClickOutside();
|
|
5140
5117
|
},
|
|
@@ -5305,8 +5282,7 @@ function _getDOMPath(rootElement, el) {
|
|
|
5305
5282
|
let e = el;
|
|
5306
5283
|
for (; e !== rootElement; ) {
|
|
5307
5284
|
const parentElement = e.parentElement;
|
|
5308
|
-
if (!parentElement)
|
|
5309
|
-
return path;
|
|
5285
|
+
if (!parentElement) return path;
|
|
5310
5286
|
const index = Array.from(parentElement.childNodes).indexOf(e);
|
|
5311
5287
|
if (path.unshift(index), parentElement === rootElement)
|
|
5312
5288
|
return path;
|
|
@@ -5316,8 +5292,7 @@ function _getDOMPath(rootElement, el) {
|
|
|
5316
5292
|
}
|
|
5317
5293
|
const EMPTY_PATH = [];
|
|
5318
5294
|
function _sortElements(rootElement, elements) {
|
|
5319
|
-
if (!rootElement)
|
|
5320
|
-
return;
|
|
5295
|
+
if (!rootElement) return;
|
|
5321
5296
|
const map = /* @__PURE__ */ new WeakMap();
|
|
5322
5297
|
for (const el of elements)
|
|
5323
5298
|
map.set(el, _getDOMPath(rootElement, el));
|
|
@@ -5337,9 +5312,8 @@ function useMenuController(props) {
|
|
|
5337
5312
|
_setActiveIndex(nextActiveIndex), activeIndexRef.current = nextActiveIndex;
|
|
5338
5313
|
}, []), mount = useCallback(
|
|
5339
5314
|
(element, selected) => {
|
|
5340
|
-
if (!element)
|
|
5341
|
-
|
|
5342
|
-
};
|
|
5315
|
+
if (!element) return () => {
|
|
5316
|
+
};
|
|
5343
5317
|
if (elementsRef.current.indexOf(element) === -1 && (elementsRef.current.push(element), _sortElements(rootElement, elementsRef.current)), selected) {
|
|
5344
5318
|
const selectedIndex = elementsRef.current.indexOf(element);
|
|
5345
5319
|
setActiveIndex(selectedIndex);
|
|
@@ -5359,8 +5333,7 @@ function useMenuController(props) {
|
|
|
5359
5333
|
if (event.key === "Home") {
|
|
5360
5334
|
event.preventDefault(), event.stopPropagation();
|
|
5361
5335
|
const el = _getFocusableElements(elementsRef.current)[0];
|
|
5362
|
-
if (!el)
|
|
5363
|
-
return;
|
|
5336
|
+
if (!el) return;
|
|
5364
5337
|
const currentIndex = elementsRef.current.indexOf(el);
|
|
5365
5338
|
setActiveIndex(currentIndex);
|
|
5366
5339
|
return;
|
|
@@ -5368,8 +5341,7 @@ function useMenuController(props) {
|
|
|
5368
5341
|
if (event.key === "End") {
|
|
5369
5342
|
event.preventDefault(), event.stopPropagation();
|
|
5370
5343
|
const focusableElements = _getFocusableElements(elementsRef.current), el = focusableElements[focusableElements.length - 1];
|
|
5371
|
-
if (!el)
|
|
5372
|
-
return;
|
|
5344
|
+
if (!el) return;
|
|
5373
5345
|
const currentIndex = elementsRef.current.indexOf(el);
|
|
5374
5346
|
setActiveIndex(currentIndex);
|
|
5375
5347
|
return;
|
|
@@ -5377,8 +5349,7 @@ function useMenuController(props) {
|
|
|
5377
5349
|
if (event.key === "ArrowUp") {
|
|
5378
5350
|
event.preventDefault(), event.stopPropagation();
|
|
5379
5351
|
const focusableElements = _getFocusableElements(elementsRef.current), focusableLen = focusableElements.length;
|
|
5380
|
-
if (focusableLen === 0)
|
|
5381
|
-
return;
|
|
5352
|
+
if (focusableLen === 0) return;
|
|
5382
5353
|
const focusedElement = elementsRef.current[activeIndexRef.current];
|
|
5383
5354
|
let focusedIndex = focusableElements.indexOf(focusedElement);
|
|
5384
5355
|
focusedIndex = (focusedIndex - 1 + focusableLen) % focusableLen;
|
|
@@ -5389,8 +5360,7 @@ function useMenuController(props) {
|
|
|
5389
5360
|
if (event.key === "ArrowDown") {
|
|
5390
5361
|
event.preventDefault(), event.stopPropagation();
|
|
5391
5362
|
const focusableElements = _getFocusableElements(elementsRef.current), focusableLen = focusableElements.length;
|
|
5392
|
-
if (focusableLen === 0)
|
|
5393
|
-
return;
|
|
5363
|
+
if (focusableLen === 0) return;
|
|
5394
5364
|
const focusedElement = elementsRef.current[activeIndexRef.current];
|
|
5395
5365
|
let focusedIndex = focusableElements.indexOf(focusedElement);
|
|
5396
5366
|
focusedIndex = (focusedIndex + 1) % focusableLen;
|
|
@@ -5411,8 +5381,7 @@ function useMenuController(props) {
|
|
|
5411
5381
|
setActiveIndex(-2), rootElement == null || rootElement.focus();
|
|
5412
5382
|
}, [setActiveIndex, rootElement]);
|
|
5413
5383
|
return useEffect(() => {
|
|
5414
|
-
if (!mounted)
|
|
5415
|
-
return;
|
|
5384
|
+
if (!mounted) return;
|
|
5416
5385
|
const rafId = window.requestAnimationFrame(() => {
|
|
5417
5386
|
const _activeIndex = activeIndexRef.current;
|
|
5418
5387
|
if (_activeIndex === -1) {
|
|
@@ -5633,13 +5602,13 @@ const Root$5 = styled(Box)`
|
|
|
5633
5602
|
registerElement,
|
|
5634
5603
|
shouldFocus
|
|
5635
5604
|
]
|
|
5636
|
-
), menu =
|
|
5605
|
+
), menu = menuProp && cloneElement(menuProp, menuProps), setButtonRef = useCallback(
|
|
5637
5606
|
(el) => {
|
|
5638
5607
|
typeof ref == "function" ? ref(el) : ref && (ref.current = el), setButtonElement(el);
|
|
5639
5608
|
},
|
|
5640
5609
|
[ref]
|
|
5641
5610
|
), button = useMemo(
|
|
5642
|
-
() =>
|
|
5611
|
+
() => buttonProp && cloneElement(buttonProp, {
|
|
5643
5612
|
"data-ui": "MenuButton",
|
|
5644
5613
|
id,
|
|
5645
5614
|
onClick: handleButtonClick,
|
|
@@ -5649,7 +5618,7 @@ const Root$5 = styled(Box)`
|
|
|
5649
5618
|
"aria-expanded": open,
|
|
5650
5619
|
ref: setButtonRef,
|
|
5651
5620
|
selected: open
|
|
5652
|
-
})
|
|
5621
|
+
}),
|
|
5653
5622
|
[buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open, setButtonRef]
|
|
5654
5623
|
), popoverProps = useMemo(
|
|
5655
5624
|
() => ({
|
|
@@ -6449,11 +6418,9 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
|
|
|
6449
6418
|
if (event.key === "ArrowLeft") {
|
|
6450
6419
|
event.preventDefault();
|
|
6451
6420
|
const itemKey = focusedElementRef.current.getAttribute("data-tree-key");
|
|
6452
|
-
if (!itemKey)
|
|
6453
|
-
return;
|
|
6421
|
+
if (!itemKey) return;
|
|
6454
6422
|
const itemState = stateRef.current[itemKey];
|
|
6455
|
-
if (!itemState)
|
|
6456
|
-
return;
|
|
6423
|
+
if (!itemState) return;
|
|
6457
6424
|
if (itemState.expanded)
|
|
6458
6425
|
setState((s) => {
|
|
6459
6426
|
const itemState2 = s[itemKey];
|
|
@@ -6470,8 +6437,7 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
|
|
|
6470
6437
|
if (event.key === "ArrowRight") {
|
|
6471
6438
|
event.preventDefault();
|
|
6472
6439
|
const focusedKey = focusedElementRef.current.getAttribute("data-tree-key");
|
|
6473
|
-
if (!focusedKey)
|
|
6474
|
-
return;
|
|
6440
|
+
if (!focusedKey) return;
|
|
6475
6441
|
(_a = stateRef.current[focusedKey]) != null && _a.expanded || setState((s) => {
|
|
6476
6442
|
const itemState = s[focusedKey];
|
|
6477
6443
|
return itemState ? { ...s, [focusedKey]: { ...itemState, expanded: !0 } } : s;
|
|
@@ -6488,8 +6454,7 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
|
|
|
6488
6454
|
[onFocus]
|
|
6489
6455
|
);
|
|
6490
6456
|
return useEffect(() => {
|
|
6491
|
-
if (!forwardedRef.current)
|
|
6492
|
-
return;
|
|
6457
|
+
if (!forwardedRef.current) return;
|
|
6493
6458
|
const _itemElements = Array.from(
|
|
6494
6459
|
forwardedRef.current.querySelectorAll('[data-ui="TreeItem"]')
|
|
6495
6460
|
);
|