InputMenu.svelte 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <script lang="ts">
  2. import { DropdownMenu } from 'bits-ui';
  3. import { flyAndScale } from '$lib/utils/transitions';
  4. import { getContext } from 'svelte';
  5. import Dropdown from '$lib/components/common/Dropdown.svelte';
  6. import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
  7. import Pencil from '$lib/components/icons/Pencil.svelte';
  8. import Tooltip from '$lib/components/common/Tooltip.svelte';
  9. import Tags from '$lib/components/chat/Tags.svelte';
  10. import Share from '$lib/components/icons/Share.svelte';
  11. import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte';
  12. import DocumentArrowUpSolid from '$lib/components/icons/DocumentArrowUpSolid.svelte';
  13. import Switch from '$lib/components/common/Switch.svelte';
  14. import GlobeAltSolid from '$lib/components/icons/GlobeAltSolid.svelte';
  15. import { config } from '$lib/stores';
  16. const i18n = getContext('i18n');
  17. export let uploadFilesHandler: Function;
  18. export let webSearchEnabled: boolean;
  19. export let onClose: Function;
  20. let show = false;
  21. </script>
  22. <Dropdown
  23. bind:show
  24. on:change={(e) => {
  25. if (e.detail === false) {
  26. onClose();
  27. }
  28. }}
  29. >
  30. <Tooltip content={$i18n.t('More')}>
  31. <slot />
  32. </Tooltip>
  33. <div slot="content">
  34. <DropdownMenu.Content
  35. class="w-full max-w-[190px] rounded-xl px-1 py-1 border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow"
  36. sideOffset={15}
  37. alignOffset={-8}
  38. side="top"
  39. align="start"
  40. transition={flyAndScale}
  41. >
  42. {#if $config?.features?.enable_web_search}
  43. <div
  44. class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer rounded-xl"
  45. >
  46. <div class="flex-1 flex items-center gap-2">
  47. <GlobeAltSolid />
  48. <div class="flex items-center">{$i18n.t('Web Search')}</div>
  49. </div>
  50. <Switch bind:state={webSearchEnabled} />
  51. </div>
  52. <hr class="border-gray-100 dark:border-gray-800 my-1" />
  53. {/if}
  54. <DropdownMenu.Item
  55. class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
  56. on:click={() => {
  57. uploadFilesHandler();
  58. }}
  59. >
  60. <DocumentArrowUpSolid />
  61. <div class="flex items-center">{$i18n.t('Upload Files')}</div>
  62. </DropdownMenu.Item>
  63. </DropdownMenu.Content>
  64. </div>
  65. </Dropdown>