InputMenu.svelte 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <script lang="ts">
  2. import { DropdownMenu } from 'bits-ui';
  3. import { flyAndScale } from '$lib/utils/transitions';
  4. import { getContext, onMount, tick } from 'svelte';
  5. import { config, user, tools as _tools, mobile } from '$lib/stores';
  6. import { getTools } from '$lib/apis/tools';
  7. import Dropdown from '$lib/components/common/Dropdown.svelte';
  8. import Tooltip from '$lib/components/common/Tooltip.svelte';
  9. import DocumentArrowUpSolid from '$lib/components/icons/DocumentArrowUpSolid.svelte';
  10. import Switch from '$lib/components/common/Switch.svelte';
  11. import GlobeAltSolid from '$lib/components/icons/GlobeAltSolid.svelte';
  12. import WrenchSolid from '$lib/components/icons/WrenchSolid.svelte';
  13. import CameraSolid from '$lib/components/icons/CameraSolid.svelte';
  14. import Camera from '$lib/components/icons/Camera.svelte';
  15. import Clip from '$lib/components/icons/Clip.svelte';
  16. const i18n = getContext('i18n');
  17. export let screenCaptureHandler: Function;
  18. export let uploadFilesHandler: Function;
  19. export let onClose: Function = () => {};
  20. let show = false;
  21. $: if (show) {
  22. init();
  23. }
  24. const init = async () => {};
  25. </script>
  26. <Dropdown
  27. bind:show
  28. on:change={(e) => {
  29. if (e.detail === false) {
  30. onClose();
  31. }
  32. }}
  33. >
  34. <Tooltip content={$i18n.t('More')}>
  35. <slot />
  36. </Tooltip>
  37. <div slot="content">
  38. <DropdownMenu.Content
  39. class="w-full max-w-[200px] rounded-2xl px-1 py-1 border border-gray-100 dark:border-gray-800 z-999 bg-white dark:bg-gray-850 dark:text-white shadow-lg transition"
  40. sideOffset={4}
  41. alignOffset={-6}
  42. side="bottom"
  43. align="start"
  44. transition={flyAndScale}
  45. >
  46. <DropdownMenu.Item
  47. class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
  48. on:click={() => {
  49. uploadFilesHandler();
  50. }}
  51. >
  52. <Clip />
  53. <div class="line-clamp-1">{$i18n.t('Upload Files')}</div>
  54. </DropdownMenu.Item>
  55. <DropdownMenu.Item
  56. class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
  57. on:click={() => {
  58. screenCaptureHandler();
  59. }}
  60. >
  61. <Camera />
  62. <div class=" line-clamp-1">{$i18n.t('Capture')}</div>
  63. </DropdownMenu.Item>
  64. </DropdownMenu.Content>
  65. </div>
  66. </Dropdown>