Files
gsfdc/demo-dify/dify/web/app/components/base/float-right-container/index.tsx
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

97 lines
2.7 KiB
TypeScript

'use client'
import type { DrawerPopupProps } from '@langgenius/dify-ui/drawer'
import { cn } from '@langgenius/dify-ui/cn'
import {
Drawer,
DrawerBackdrop,
DrawerClose,
DrawerContent,
DrawerPopup,
DrawerPortal,
DrawerTitle,
DrawerViewport,
} from '@langgenius/dify-ui/drawer'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useTranslation } from 'react-i18next'
type IFloatRightContainerProps = Pick<DrawerPopupProps, 'finalFocus'> & {
isMobile: boolean
isOpen: boolean
onClose: () => void
children?: React.ReactNode
showClose?: boolean
panelClassName?: string
title?: string
mask?: boolean
}
const FloatRightContainer = ({
isMobile,
children,
isOpen,
onClose,
showClose = false,
panelClassName,
title,
mask = true,
finalFocus,
}: IFloatRightContainerProps) => {
const { t } = useTranslation(['common'])
return (
<>
{isMobile && (
<Drawer
open={isOpen}
modal
swipeDirection="right"
onOpenChange={(open) => {
if (!open) onClose()
}}
>
<DrawerPortal>
<DrawerBackdrop className={cn(!mask && 'bg-transparent')} />
<DrawerViewport>
<DrawerPopup
finalFocus={finalFocus}
className={cn(
'data-[swipe-direction=right]:w-full data-[swipe-direction=right]:max-w-sm',
panelClassName,
)}
>
<DrawerContent className="flex min-h-0 flex-1 flex-col">
{(title || showClose) && (
<div className="mb-4 flex shrink-0 items-center justify-between">
{title && (
<DrawerTitle className="text-lg/6 font-medium text-text-primary">
{title}
</DrawerTitle>
)}
{showClose && (
<DrawerClose
render={
<IconButton
aria-label={t(($) => $['operation.close'], { ns: 'common' })}
size="md"
>
<span aria-hidden="true" className="i-ri-close-line size-4" />
</IconButton>
}
/>
)}
</div>
)}
{children}
</DrawerContent>
</DrawerPopup>
</DrawerViewport>
</DrawerPortal>
</Drawer>
)}
{!isMobile && isOpen && <>{children}</>}
</>
)
}
export default FloatRightContainer