UEA-PRODEM
This commit is contained in:
+53
-10
@@ -29,7 +29,18 @@ var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
||||
var Popper = (props) => {
|
||||
const { __scopePopper, children } = props;
|
||||
const [anchor, setAnchor] = React.useState(null);
|
||||
return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
|
||||
const [placementState, setPlacementState] = React.useState(void 0);
|
||||
return /* @__PURE__ */ jsx(
|
||||
PopperProvider,
|
||||
{
|
||||
scope: __scopePopper,
|
||||
anchor,
|
||||
onAnchorChange: setAnchor,
|
||||
placementState,
|
||||
setPlacementState,
|
||||
children
|
||||
}
|
||||
);
|
||||
};
|
||||
Popper.displayName = POPPER_NAME;
|
||||
var ANCHOR_NAME = "PopperAnchor";
|
||||
@@ -38,16 +49,40 @@ var PopperAnchor = React.forwardRef(
|
||||
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
||||
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
||||
const ref = React.useRef(null);
|
||||
const composedRefs = useComposedRefs(forwardedRef, ref);
|
||||
const onAnchorChange = context.onAnchorChange;
|
||||
const callbackRef = React.useCallback(
|
||||
(node) => {
|
||||
ref.current = node;
|
||||
if (node) {
|
||||
onAnchorChange(node);
|
||||
}
|
||||
},
|
||||
[onAnchorChange]
|
||||
);
|
||||
const composedRefs = useComposedRefs(forwardedRef, callbackRef);
|
||||
const anchorRef = React.useRef(null);
|
||||
React.useEffect(() => {
|
||||
if (!virtualRef) {
|
||||
return;
|
||||
}
|
||||
const previousAnchor = anchorRef.current;
|
||||
anchorRef.current = virtualRef?.current || ref.current;
|
||||
anchorRef.current = virtualRef.current;
|
||||
if (previousAnchor !== anchorRef.current) {
|
||||
context.onAnchorChange(anchorRef.current);
|
||||
onAnchorChange(anchorRef.current);
|
||||
}
|
||||
});
|
||||
return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
|
||||
const sideAndAlign = context.placementState && getSideAndAlignFromPlacement(context.placementState);
|
||||
const placedSide = sideAndAlign?.[0];
|
||||
const placedAlign = sideAndAlign?.[1];
|
||||
return virtualRef ? null : /* @__PURE__ */ jsx(
|
||||
Primitive.div,
|
||||
{
|
||||
"data-radix-popper-side": placedSide,
|
||||
"data-radix-popper-align": placedAlign,
|
||||
...anchorProps,
|
||||
ref: composedRefs
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
PopperAnchor.displayName = ANCHOR_NAME;
|
||||
@@ -63,7 +98,7 @@ var PopperContent = React.forwardRef(
|
||||
alignOffset = 0,
|
||||
arrowPadding = 0,
|
||||
avoidCollisions = true,
|
||||
collisionBoundary = [],
|
||||
collisionBoundary,
|
||||
collisionPadding: collisionPaddingProp = 0,
|
||||
sticky = "partial",
|
||||
hideWhenDetached = false,
|
||||
@@ -80,11 +115,11 @@ var PopperContent = React.forwardRef(
|
||||
const arrowHeight = arrowSize?.height ?? 0;
|
||||
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
||||
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
|
||||
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
|
||||
const hasExplicitBoundaries = boundary.length > 0;
|
||||
const boundary = collisionBoundary ? Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary] : void 0;
|
||||
const hasExplicitBoundaries = boundary !== void 0 && boundary.length > 0;
|
||||
const detectOverflowOptions = {
|
||||
padding: collisionPadding,
|
||||
boundary: boundary.filter(isNotNull),
|
||||
boundary: boundary?.filter(isNotNull),
|
||||
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
||||
altBoundary: hasExplicitBoundaries
|
||||
};
|
||||
@@ -126,6 +161,13 @@ var PopperContent = React.forwardRef(
|
||||
hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
|
||||
]
|
||||
});
|
||||
const setPlacementState = context.setPlacementState;
|
||||
useLayoutEffect(() => {
|
||||
setPlacementState(placement);
|
||||
return () => {
|
||||
setPlacementState(void 0);
|
||||
};
|
||||
}, [placement, setPlacementState]);
|
||||
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
||||
const handlePlaced = useCallbackRef(onPlaced);
|
||||
useLayoutEffect(() => {
|
||||
@@ -151,7 +193,7 @@ var PopperContent = React.forwardRef(
|
||||
// keep off the page when measuring
|
||||
minWidth: "max-content",
|
||||
zIndex: contentZIndex,
|
||||
["--radix-popper-transform-origin"]: [
|
||||
"--radix-popper-transform-origin": [
|
||||
middlewareData.transformOrigin?.x,
|
||||
middlewareData.transformOrigin?.y
|
||||
].join(" "),
|
||||
@@ -169,6 +211,7 @@ var PopperContent = React.forwardRef(
|
||||
{
|
||||
scope: __scopePopper,
|
||||
placedSide,
|
||||
placedAlign,
|
||||
onArrowChange: setArrow,
|
||||
arrowX,
|
||||
arrowY,
|
||||
|
||||
Reference in New Issue
Block a user