@sanity/ui 2.8.13-canary.0 → 2.8.13-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.esm.js CHANGED
@@ -5504,16 +5504,28 @@ function _sortElements(rootElement, elements) {
5504
5504
  elements.sort(_sort);
5505
5505
  }
5506
5506
  function useMenuController(props) {
5507
- const {
5507
+ const $ = c(21), {
5508
5508
  onKeyDown,
5509
5509
  originElement,
5510
5510
  shouldFocus,
5511
5511
  rootElementRef
5512
- } = props, elementsRef = useRef([]), [activeIndex, _setActiveIndex] = useState(-1), activeIndexRef = useRef(activeIndex), activeElement = useMemo(() => elementsRef.current[activeIndex] || null, [activeIndex]), mounted = !!rootElementRef.current, setActiveIndex = useCallback((nextActiveIndex) => {
5512
+ } = props;
5513
+ let t0;
5514
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
5515
+ const elementsRef = useRef(t0), [activeIndex, _setActiveIndex] = useState(-1), activeIndexRef = useRef(activeIndex);
5516
+ let t1;
5517
+ t1 = elementsRef.current[activeIndex] || null;
5518
+ const activeElement = t1, mounted = !!rootElementRef.current;
5519
+ let t2;
5520
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = (nextActiveIndex) => {
5513
5521
  _setActiveIndex(nextActiveIndex), activeIndexRef.current = nextActiveIndex;
5514
- }, []), mount = useCallback((element, selected) => {
5515
- if (!element) return () => {
5516
- };
5522
+ }, $[1] = t2) : t2 = $[1];
5523
+ const setActiveIndex = t2;
5524
+ let t3;
5525
+ $[2] !== rootElementRef.current ? (t3 = (element, selected) => {
5526
+ if (!element)
5527
+ return () => {
5528
+ };
5517
5529
  if (elementsRef.current.indexOf(element) === -1 && (elementsRef.current.push(element), _sortElements(rootElementRef.current, elementsRef.current)), selected) {
5518
5530
  const selectedIndex = elementsRef.current.indexOf(element);
5519
5531
  setActiveIndex(selectedIndex);
@@ -5522,7 +5534,10 @@ function useMenuController(props) {
5522
5534
  const idx = elementsRef.current.indexOf(element);
5523
5535
  idx > -1 && elementsRef.current.splice(idx, 1);
5524
5536
  };
5525
- }, [rootElementRef, setActiveIndex]), handleKeyDown = useCallback((event) => {
5537
+ }, $[2] = rootElementRef.current, $[3] = t3) : t3 = $[3];
5538
+ const mount = t3;
5539
+ let t4;
5540
+ $[4] !== originElement || $[5] !== onKeyDown ? (t4 = (event) => {
5526
5541
  if (event.key === "Tab") {
5527
5542
  originElement && originElement.focus();
5528
5543
  return;
@@ -5530,7 +5545,8 @@ function useMenuController(props) {
5530
5545
  if (event.key === "Home") {
5531
5546
  event.preventDefault(), event.stopPropagation();
5532
5547
  const el = _getFocusableElements(elementsRef.current)[0];
5533
- if (!el) return;
5548
+ if (!el)
5549
+ return;
5534
5550
  const currentIndex = elementsRef.current.indexOf(el);
5535
5551
  setActiveIndex(currentIndex);
5536
5552
  return;
@@ -5538,7 +5554,8 @@ function useMenuController(props) {
5538
5554
  if (event.key === "End") {
5539
5555
  event.preventDefault(), event.stopPropagation();
5540
5556
  const focusableElements_0 = _getFocusableElements(elementsRef.current), el_0 = focusableElements_0[focusableElements_0.length - 1];
5541
- if (!el_0) return;
5557
+ if (!el_0)
5558
+ return;
5542
5559
  const currentIndex_0 = elementsRef.current.indexOf(el_0);
5543
5560
  setActiveIndex(currentIndex_0);
5544
5561
  return;
@@ -5546,7 +5563,8 @@ function useMenuController(props) {
5546
5563
  if (event.key === "ArrowUp") {
5547
5564
  event.preventDefault(), event.stopPropagation();
5548
5565
  const focusableElements_1 = _getFocusableElements(elementsRef.current), focusableLen = focusableElements_1.length;
5549
- if (focusableLen === 0) return;
5566
+ if (focusableLen === 0)
5567
+ return;
5550
5568
  const focusedElement = elementsRef.current[activeIndexRef.current];
5551
5569
  let focusedIndex = focusableElements_1.indexOf(focusedElement);
5552
5570
  focusedIndex = (focusedIndex - 1 + focusableLen) % focusableLen;
@@ -5557,7 +5575,8 @@ function useMenuController(props) {
5557
5575
  if (event.key === "ArrowDown") {
5558
5576
  event.preventDefault(), event.stopPropagation();
5559
5577
  const focusableElements_2 = _getFocusableElements(elementsRef.current), focusableLen_0 = focusableElements_2.length;
5560
- if (focusableLen_0 === 0) return;
5578
+ if (focusableLen_0 === 0)
5579
+ return;
5561
5580
  const focusedElement_0 = elementsRef.current[activeIndexRef.current];
5562
5581
  let focusedIndex_0 = focusableElements_2.indexOf(focusedElement_0);
5563
5582
  focusedIndex_0 = (focusedIndex_0 + 1) % focusableLen_0;
@@ -5566,14 +5585,23 @@ function useMenuController(props) {
5566
5585
  return;
5567
5586
  }
5568
5587
  onKeyDown && onKeyDown(event);
5569
- }, [onKeyDown, originElement, setActiveIndex]), handleItemMouseEnter = useCallback((event_0) => {
5588
+ }, $[4] = originElement, $[5] = onKeyDown, $[6] = t4) : t4 = $[6];
5589
+ const handleKeyDown = t4;
5590
+ let t5;
5591
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t5 = (event_0) => {
5570
5592
  const element_0 = event_0.currentTarget, currentIndex_3 = elementsRef.current.indexOf(element_0);
5571
5593
  setActiveIndex(currentIndex_3);
5572
- }, [setActiveIndex]), handleItemMouseLeave = useCallback(() => {
5594
+ }, $[7] = t5) : t5 = $[7];
5595
+ const handleItemMouseEnter = t5;
5596
+ let t6;
5597
+ $[8] !== rootElementRef.current ? (t6 = () => {
5573
5598
  setActiveIndex(-2), rootElementRef.current?.focus();
5574
- }, [rootElementRef, setActiveIndex]);
5575
- return useEffect(() => {
5576
- if (!mounted) return;
5599
+ }, $[8] = rootElementRef.current, $[9] = t6) : t6 = $[9];
5600
+ const handleItemMouseLeave = t6;
5601
+ let t7, t8;
5602
+ $[10] !== mounted || $[11] !== activeIndex || $[12] !== shouldFocus ? (t7 = () => {
5603
+ if (!mounted)
5604
+ return;
5577
5605
  const rafId = requestAnimationFrame(() => {
5578
5606
  if (activeIndex === -1) {
5579
5607
  if (shouldFocus === "first") {
@@ -5595,14 +5623,16 @@ function useMenuController(props) {
5595
5623
  (elementsRef.current[activeIndex] || null)?.focus();
5596
5624
  });
5597
5625
  return () => cancelAnimationFrame(rafId);
5598
- }, [activeIndex, mounted, setActiveIndex, shouldFocus]), {
5626
+ }, t8 = [activeIndex, mounted, setActiveIndex, shouldFocus], $[10] = mounted, $[11] = activeIndex, $[12] = shouldFocus, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), useEffect(t7, t8);
5627
+ let t9;
5628
+ return $[15] !== activeElement || $[16] !== activeIndex || $[17] !== handleItemMouseLeave || $[18] !== handleKeyDown || $[19] !== mount ? (t9 = {
5599
5629
  activeElement,
5600
5630
  activeIndex,
5601
5631
  handleItemMouseEnter,
5602
5632
  handleItemMouseLeave,
5603
5633
  handleKeyDown,
5604
5634
  mount
5605
- };
5635
+ }, $[15] = activeElement, $[16] = activeIndex, $[17] = handleItemMouseLeave, $[18] = handleKeyDown, $[19] = mount, $[20] = t9) : t9 = $[20], t9;
5606
5636
  }
5607
5637
  const Root$5 = styled(Box)`
5608
5638
  outline: none;