From a430284aa21e3ae1f0d5654e55b2ad2852519cc2 Mon Sep 17 00:00:00 2001 From: wwf <yearningwang@iqtogether.com> Date: 星期三, 04 六月 2025 15:17:49 +0800 Subject: [PATCH] 初始化 --- app/components/base/portal-to-follow-elem/index.tsx | 40 +++++++++++----------------------------- 1 files changed, 11 insertions(+), 29 deletions(-) diff --git a/app/components/base/portal-to-follow-elem/index.tsx b/app/components/base/portal-to-follow-elem/index.tsx index 1e2e198..4a380e6 100644 --- a/app/components/base/portal-to-follow-elem/index.tsx +++ b/app/components/base/portal-to-follow-elem/index.tsx @@ -6,7 +6,6 @@ flip, offset, shift, - size, useDismiss, useFloating, useFocus, @@ -28,7 +27,6 @@ open?: boolean offset?: number | OffsetOptions onOpenChange?: (open: boolean) => void - triggerPopupSameWidth?: boolean } export function usePortalToFollowElem({ @@ -36,7 +34,6 @@ open, offset: offsetValue = 0, onOpenChange: setControlledOpen, - triggerPopupSameWidth, }: PortalToFollowElemOptions = {}) { const setOpen = setControlledOpen @@ -53,12 +50,6 @@ padding: 5, }), shift({ padding: 5 }), - size({ - apply({ rects, elements }) { - if (triggerPopupSameWidth) - elements.floating.style.width = `${rects.reference.width}px` - }, - }), ], }) @@ -114,16 +105,12 @@ ) } -export const PortalToFollowElemTrigger = ( - { - ref: propRef, - children, - asChild = false, - ...props - }: React.HTMLProps<HTMLElement> & { ref?: React.RefObject<HTMLElement>, asChild?: boolean }, -) => { +export const PortalToFollowElemTrigger = React.forwardRef< +HTMLElement, +React.HTMLProps<HTMLElement> & { asChild?: boolean } +>(({ children, asChild = false, ...props }, propRef) => { const context = usePortalToFollowElemContext() - const childrenRef = (children as any).props?.ref + const childrenRef = (children as any).ref const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]) // `asChild` allows the user to pass any element as the anchor @@ -150,18 +137,13 @@ {children} </div> ) -} +}) PortalToFollowElemTrigger.displayName = 'PortalToFollowElemTrigger' -export const PortalToFollowElemContent = ( - { - ref: propRef, - style, - ...props - }: React.HTMLProps<HTMLDivElement> & { - ref?: React.RefObject<HTMLDivElement>; - }, -) => { +export const PortalToFollowElemContent = React.forwardRef< +HTMLDivElement, +React.HTMLProps<HTMLDivElement> +>(({ style, ...props }, propRef) => { const context = usePortalToFollowElemContext() const ref = useMergeRefs([context.refs.setFloating, propRef]) @@ -182,6 +164,6 @@ /> </FloatingPortal> ) -} +}) PortalToFollowElemContent.displayName = 'PortalToFollowElemContent' -- Gitblit v1.8.0