2023-04-02 00:29:53 +08:00
|
|
|
import React from 'react';
|
2023-04-02 04:15:07 +08:00
|
|
|
import { Button } from '../ui/Button.tsx';
|
2023-04-05 03:58:22 +08:00
|
|
|
import CrossIcon from '../svg/CrossIcon';
|
2023-04-01 14:27:34 -04:00
|
|
|
// import SaveIcon from '../svg/SaveIcon';
|
|
|
|
|
import { Save } from 'lucide-react';
|
2023-06-13 16:42:01 -04:00
|
|
|
import { cn } from '~/utils/';
|
2023-04-02 00:29:53 +08:00
|
|
|
|
2023-05-13 16:29:06 -04:00
|
|
|
function EndpointOptionsPopover({
|
|
|
|
|
content,
|
|
|
|
|
visible,
|
|
|
|
|
saveAsPreset,
|
|
|
|
|
switchToSimpleMode,
|
2023-07-14 09:36:49 -04:00
|
|
|
additionalButton = null,
|
2023-05-13 16:29:06 -04:00
|
|
|
}) {
|
2023-04-02 00:29:53 +08:00
|
|
|
const cardStyle =
|
|
|
|
|
'shadow-md rounded-md min-w-[75px] font-normal bg-white border-black/10 border dark:bg-gray-700 text-black dark:text-white';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div
|
|
|
|
|
className={
|
2023-06-13 16:42:01 -04:00
|
|
|
' endpointOptionsPopover-container absolute bottom-[-10px] flex w-full flex-col items-center md:px-4 z-0' +
|
2023-04-02 00:29:53 +08:00
|
|
|
(visible ? ' show' : '')
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
className={
|
|
|
|
|
cardStyle +
|
2023-05-13 16:29:06 -04:00
|
|
|
' border-d-0 flex w-full flex-col overflow-hidden rounded-none border-s-0 border-t bg-slate-200 px-0 pb-[10px] dark:border-white/10 md:rounded-md md:border lg:w-[736px]'
|
2023-04-02 00:29:53 +08:00
|
|
|
}
|
|
|
|
|
>
|
2023-05-13 16:29:06 -04:00
|
|
|
<div className="flex w-full items-center bg-slate-100 px-2 py-2 dark:bg-gray-800/60">
|
2023-04-02 00:29:53 +08:00
|
|
|
{/* <span className="text-xs font-medium font-normal">Advanced settings for OpenAI endpoint</span> */}
|
|
|
|
|
<Button
|
|
|
|
|
type="button"
|
2023-05-13 16:29:06 -04:00
|
|
|
className="h-auto justify-start bg-transparent px-2 py-1 text-xs font-medium font-normal text-black hover:bg-slate-200 hover:text-black focus:ring-0 dark:bg-transparent dark:text-white dark:hover:bg-gray-700 dark:hover:text-white dark:focus:outline-none dark:focus:ring-offset-0"
|
2023-04-02 00:29:53 +08:00
|
|
|
onClick={saveAsPreset}
|
|
|
|
|
>
|
2023-04-01 14:27:34 -04:00
|
|
|
<Save className="mr-1 w-[14px]" />
|
2023-04-02 00:29:53 +08:00
|
|
|
Save as preset
|
|
|
|
|
</Button>
|
2023-05-13 16:29:06 -04:00
|
|
|
{additionalButton && (
|
|
|
|
|
<Button
|
|
|
|
|
type="button"
|
2023-07-14 09:36:49 -04:00
|
|
|
className={cn(additionalButton.buttonClass, 'ml-1 h-auto justify-start bg-transparent px-2 py-1 text-xs font-medium font-normal text-black hover:bg-slate-200 hover:text-black focus:ring-0 focus:ring-offset-0 dark:bg-transparent dark:text-white dark:hover:bg-gray-700 dark:hover:text-white dark:focus:outline-none dark:focus:ring-offset-0')}
|
2023-05-13 16:29:06 -04:00
|
|
|
onClick={additionalButton.handler}
|
|
|
|
|
>
|
|
|
|
|
{additionalButton.icon}
|
|
|
|
|
{additionalButton.label}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2023-04-02 00:29:53 +08:00
|
|
|
<Button
|
|
|
|
|
type="button"
|
2023-05-13 16:29:06 -04:00
|
|
|
className="ml-auto h-auto bg-transparent px-2 py-1 text-xs font-medium font-normal text-black hover:bg-slate-200 hover:text-black focus:ring-offset-0 dark:bg-transparent dark:text-white dark:hover:bg-gray-700 dark:hover:text-white"
|
2023-04-02 00:29:53 +08:00
|
|
|
onClick={switchToSimpleMode}
|
|
|
|
|
>
|
2023-04-05 03:58:22 +08:00
|
|
|
<CrossIcon className="mr-1" />
|
|
|
|
|
{/* Switch to simple mode */}
|
2023-04-02 00:29:53 +08:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<div>{content}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default EndpointOptionsPopover;
|