'use client' import type { FC } from 'react' import React, { useCallback, useRef, useState } from 'react' import copy from 'copy-to-clipboard' import cn from 'classnames' import PromptEditorHeightResizeWrap from './prompt-editor-height-resize-wrap' import ToggleExpandBtn from './toggle-expand-btn' import useToggleExpend from './use-toggle-expend' import { Clipboard, ClipboardCheck } from '@/app/components/base/icons/line/files' type Props = { className?: string title: JSX.Element | string headerRight?: JSX.Element children: JSX.Element minHeight?: number value: string isFocus: boolean } const Base: FC = ({ className, title, headerRight, children, minHeight = 120, value, isFocus, }) => { const ref = useRef(null) const { wrapClassName, isExpand, setIsExpand, editorExpandHeight, } = useToggleExpend({ ref, hasFooter: false }) const editorContentMinHeight = minHeight - 28 const [editorContentHeight, setEditorContentHeight] = useState(editorContentMinHeight) const [isCopied, setIsCopied] = React.useState(false) const handleCopy = useCallback(() => { copy(value) setIsCopied(true) }, [value]) return (
{title}
{headerRight} {!isCopied ? ( ) : ( ) }
{children}
) } export default React.memo(Base)