@sanity/ui 2.11.6 → 2.11.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.js CHANGED
@@ -3736,6 +3736,10 @@ function findScrollable(parentNode) {
3736
3736
  _scrollEl = _scrollEl.parentNode;
3737
3737
  return _scrollEl;
3738
3738
  }
3739
+ function getElementRef(element) {
3740
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
3741
+ return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
3742
+ }
3739
3743
  const 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 = {
3740
3744
  top: ["bottom", "left", "right"],
3741
3745
  "top-start": ["bottom-start", "left-start", "right-start"],
@@ -4015,10 +4019,6 @@ const Popover = react.memo(react.forwardRef(function(props, forwardedRef) {
4015
4019
  ] });
4016
4020
  }));
4017
4021
  Popover.displayName = "Memo(ForwardRef(Popover))";
4018
- function getElementRef(element) {
4019
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
4020
- return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
4021
- }
4022
4022
  function radioBaseStyle() {
4023
4023
  return styledComponents.css`
4024
4024
  position: relative;
@@ -4978,21 +4978,16 @@ const StyledTooltip = styledComponents.styled(Layer).withConfig({
4978
4978
  arrowRef.current = arrowEl, update();
4979
4979
  }, [update]), setFloating = react.useCallback((node) => {
4980
4980
  ref.current = node, refs.setFloating(node);
4981
- }, [refs]), childRef = react.useRef(null);
4982
- react.useImperativeHandle(childProp?.ref, () => childRef.current);
4983
- const child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
4981
+ }, [refs]), child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
4984
4982
  onBlur: handleBlur,
4985
4983
  onFocus: handleFocus,
4986
4984
  onMouseEnter: handleMouseEnter,
4987
4985
  onMouseLeave: handleMouseLeave,
4988
4986
  onClick: handleClick,
4989
4987
  onContextMenu: handleContextMenu,
4990
- ref: childRef
4988
+ ref: setReferenceElement
4991
4989
  }) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
4992
- if (react.useEffect(() => {
4993
- if (child)
4994
- return setReferenceElement(childRef.current), () => setReferenceElement(null);
4995
- }, [child]), !child) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
4990
+ if (react.useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
4996
4991
  if (disabled) return child;
4997
4992
  const tooltip = /* @__PURE__ */ jsxRuntime.jsx(StyledTooltip, { "data-ui": "Tooltip", ...restProps, ref: setFloating, style: {
4998
4993
  ...floatingStyles,