@sanity/ui 2.3.6-canary.4 → 2.3.6-canary.6

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.mjs CHANGED
@@ -3264,7 +3264,7 @@ const Popover = memo(
3264
3264
  animate: _animate = !1,
3265
3265
  arrow: arrowProp = !1,
3266
3266
  boundaryElement: _boundaryElement,
3267
- children,
3267
+ children: _children,
3268
3268
  constrainSize = !1,
3269
3269
  content,
3270
3270
  disabled,
@@ -3378,10 +3378,16 @@ const Popover = memo(
3378
3378
  },
3379
3379
  [refs]
3380
3380
  );
3381
- if (useImperativeHandle(updateRef, () => update, [update]), useEffect(() => {
3382
- children || refs.setReference(referenceElement || null);
3383
- }, [children, referenceElement, refs]), disabled)
3384
- return children || /* @__PURE__ */ jsx(Fragment, {});
3381
+ useImperativeHandle(updateRef, () => update, [update]), useEffect(() => {
3382
+ _children || refs.setReference(referenceElement || null);
3383
+ }, [_children, referenceElement, refs]);
3384
+ const children = useMemo(() => !_children || referenceElement ? null : cloneElement(_children, {
3385
+ ref: (node) => {
3386
+ logDeprecatedWarning(), refs.setReference(node);
3387
+ }
3388
+ }), [_children, referenceElement, refs]);
3389
+ if (disabled)
3390
+ return _children || /* @__PURE__ */ jsx(Fragment, {});
3385
3391
  const popover = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(
3386
3392
  PopoverCard,
3387
3393
  {
@@ -3426,16 +3432,7 @@ const Popover = memo(
3426
3432
  )
3427
3433
  }
3428
3434
  ),
3429
- children && !referenceElement && /* @__PURE__ */ jsx(
3430
- "div",
3431
- {
3432
- ref: (node) => {
3433
- logDeprecatedWarning(), refs.setReference(node);
3434
- },
3435
- style: { display: "contents" },
3436
- children
3437
- }
3438
- )
3435
+ children
3439
3436
  ] });
3440
3437
  })
3441
3438
  );
@@ -5560,28 +5557,16 @@ const Root$5 = styled(Box)`
5560
5557
  setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
5561
5558
  }, [buttonElement, disableRestoreFocusOnClose]), registerElement = useCallback((el) => (setChildMenuElements((els) => els.concat([el])), () => {
5562
5559
  setChildMenuElements((els) => els.filter((_el) => _el !== el));
5563
- }), []), menuProps = useMemo(
5564
- () => ({
5565
- "aria-labelledby": id,
5566
- onBlurCapture: handleBlur,
5567
- onClickOutside: handleMenuClickOutside,
5568
- onEscape: handleMenuEscape,
5569
- onItemClick: handleItemClick,
5570
- originElement: buttonElement,
5571
- registerElement,
5572
- shouldFocus
5573
- }),
5574
- [
5575
- buttonElement,
5576
- handleMenuClickOutside,
5577
- handleMenuEscape,
5578
- handleItemClick,
5579
- id,
5580
- handleBlur,
5581
- registerElement,
5582
- shouldFocus
5583
- ]
5584
- ), menu = menuProp && cloneElement(menuProp, menuProps), ref = useRef(null), button = useMemo(
5560
+ }), []), menu = menuProp && cloneElement(menuProp, {
5561
+ "aria-labelledby": id,
5562
+ onBlurCapture: handleBlur,
5563
+ onClickOutside: handleMenuClickOutside,
5564
+ onEscape: handleMenuEscape,
5565
+ onItemClick: handleItemClick,
5566
+ originElement: buttonElement,
5567
+ registerElement,
5568
+ shouldFocus
5569
+ }), button = useMemo(
5585
5570
  () => {
5586
5571
  var _a;
5587
5572
  return buttonProp && cloneElement(buttonProp, {
@@ -5592,7 +5577,7 @@ const Root$5 = styled(Box)`
5592
5577
  onMouseDown: handleMouseDown,
5593
5578
  "aria-haspopup": !0,
5594
5579
  "aria-expanded": open,
5595
- ref,
5580
+ ref: setButtonElement,
5596
5581
  selected: (_a = buttonProp.props.selected) != null ? _a : open
5597
5582
  });
5598
5583
  },
@@ -5600,11 +5585,9 @@ const Root$5 = styled(Box)`
5600
5585
  );
5601
5586
  useImperativeHandle(
5602
5587
  forwardedRef,
5603
- () => ref.current
5604
- ), useEffect(() => {
5605
- if (button)
5606
- return setButtonElement(ref.current), () => setButtonElement(null);
5607
- }, [button]);
5588
+ () => buttonElement,
5589
+ [buttonElement]
5590
+ );
5608
5591
  const popoverProps = useMemo(
5609
5592
  () => ({
5610
5593
  boundaryElement: deprecated_boundaryElement,
@@ -5626,7 +5609,19 @@ const Root$5 = styled(Box)`
5626
5609
  popover
5627
5610
  ]
5628
5611
  );
5629
- return /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: button || /* @__PURE__ */ jsx(Fragment, {}) });
5612
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
5613
+ /* @__PURE__ */ jsx(
5614
+ Popover,
5615
+ {
5616
+ "data-ui": "MenuButton__popover",
5617
+ referenceElement: buttonElement,
5618
+ ...popoverProps,
5619
+ content: menu,
5620
+ open
5621
+ }
5622
+ ),
5623
+ button
5624
+ ] });
5630
5625
  }), MenuDivider = styled.hr`
5631
5626
  height: 1px;
5632
5627
  border: 0;