File size: 2,551 Bytes
9705b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import { Save } from 'lucide-react';
import { EModelEndpoint } from 'librechat-data-provider';
import { Button } from '~/components/ui';
import { CrossIcon } from '~/components/svg';
import PopoverButtons from './PopoverButtons';
import { cn, removeFocusOutlines } from '~/utils';
import { useLocalize } from '~/hooks';

type TEndpointOptionsPopoverProps = {
  children: React.ReactNode;
  visible: boolean;
  endpoint: EModelEndpoint;
  saveAsPreset: () => void;
  closePopover: () => void;
};

export default function EndpointOptionsPopover({
  children,
  endpoint,
  visible,
  saveAsPreset,
  closePopover,
}: TEndpointOptionsPopoverProps) {
  const localize = useLocalize();
  const cardStyle =
    'shadow-xl 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={cn(
          'endpointOptionsPopover-container absolute bottom-[-10px] z-0 flex w-full flex-col items-center md:px-4',
          visible ? ' show' : '',
        )}
      >
        <div
          className={cn(
            cardStyle,
            'border-d-0 flex w-full flex-col overflow-hidden rounded-none border-s-0 border-t bg-white px-0 pb-[10px] dark:border-white/10 md:rounded-md md:border lg:w-[736px]',
          )}
        >
          <div className="flex w-full items-center bg-slate-100 px-2 py-2 dark:bg-gray-800/60">
            <Button
              type="button"
              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"
              onClick={saveAsPreset}
            >
              <Save className="mr-1 w-[14px]" />
              {localize('com_endpoint_save_as_preset')}
            </Button>
            <PopoverButtons endpoint={endpoint} />
            <Button
              type="button"
              className={cn(
                'ml-auto h-auto bg-transparent px-3 py-2 text-xs font-medium font-normal text-black hover:bg-slate-200 hover:text-black dark:bg-transparent dark:text-white dark:hover:bg-gray-700 dark:hover:text-white',
                removeFocusOutlines,
              )}
              onClick={closePopover}
            >
              <CrossIcon />
            </Button>
          </div>
          <div>{children}</div>
        </div>
      </div>
    </>
  );
}