@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.esm.js +7 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/core/primitives/popover/popover.tsx +1 -26
- package/src/core/primitives/tooltip/tooltip.tsx +5 -13
- package/src/core/utils/getElementRef.ts +26 -0
package/dist/index.esm.js
CHANGED
|
@@ -3742,6 +3742,10 @@ function findScrollable(parentNode) {
|
|
|
3742
3742
|
_scrollEl = _scrollEl.parentNode;
|
|
3743
3743
|
return _scrollEl;
|
|
3744
3744
|
}
|
|
3745
|
+
function getElementRef(element) {
|
|
3746
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
3747
|
+
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);
|
|
3748
|
+
}
|
|
3745
3749
|
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 = {
|
|
3746
3750
|
top: ["bottom", "left", "right"],
|
|
3747
3751
|
"top-start": ["bottom-start", "left-start", "right-start"],
|
|
@@ -4021,10 +4025,6 @@ const Popover = memo(forwardRef(function(props, forwardedRef) {
|
|
|
4021
4025
|
] });
|
|
4022
4026
|
}));
|
|
4023
4027
|
Popover.displayName = "Memo(ForwardRef(Popover))";
|
|
4024
|
-
function getElementRef(element) {
|
|
4025
|
-
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
4026
|
-
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);
|
|
4027
|
-
}
|
|
4028
4028
|
function radioBaseStyle() {
|
|
4029
4029
|
return css`
|
|
4030
4030
|
position: relative;
|
|
@@ -4984,21 +4984,16 @@ const StyledTooltip = styled(Layer).withConfig({
|
|
|
4984
4984
|
arrowRef.current = arrowEl, update();
|
|
4985
4985
|
}, [update]), setFloating = useCallback((node) => {
|
|
4986
4986
|
ref.current = node, refs.setFloating(node);
|
|
4987
|
-
}, [refs]),
|
|
4988
|
-
useImperativeHandle(childProp?.ref, () => childRef.current);
|
|
4989
|
-
const child = useMemo(() => childProp ? cloneElement(childProp, {
|
|
4987
|
+
}, [refs]), child = useMemo(() => childProp ? cloneElement(childProp, {
|
|
4990
4988
|
onBlur: handleBlur,
|
|
4991
4989
|
onFocus: handleFocus,
|
|
4992
4990
|
onMouseEnter: handleMouseEnter,
|
|
4993
4991
|
onMouseLeave: handleMouseLeave,
|
|
4994
4992
|
onClick: handleClick,
|
|
4995
4993
|
onContextMenu: handleContextMenu,
|
|
4996
|
-
ref:
|
|
4994
|
+
ref: setReferenceElement
|
|
4997
4995
|
}) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
|
|
4998
|
-
if (
|
|
4999
|
-
if (child)
|
|
5000
|
-
return setReferenceElement(childRef.current), () => setReferenceElement(null);
|
|
5001
|
-
}, [child]), !child) return /* @__PURE__ */ jsx(Fragment, {});
|
|
4996
|
+
if (useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsx(Fragment, {});
|
|
5002
4997
|
if (disabled) return child;
|
|
5003
4998
|
const tooltip = /* @__PURE__ */ jsx(StyledTooltip, { "data-ui": "Tooltip", ...restProps, ref: setFloating, style: {
|
|
5004
4999
|
...floatingStyles,
|