Documents.svelte 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <script lang="ts">
  2. import { toast } from 'svelte-sonner';
  3. import fileSaver from 'file-saver';
  4. const { saveAs } = fileSaver;
  5. import { onMount, getContext } from 'svelte';
  6. import { WEBUI_NAME, documents, showSidebar } from '$lib/stores';
  7. import { createNewDoc, deleteDocByName, getDocs } from '$lib/apis/documents';
  8. import { SUPPORTED_FILE_TYPE, SUPPORTED_FILE_EXTENSIONS } from '$lib/constants';
  9. import { processDocToVectorDB, uploadDocToVectorDB } from '$lib/apis/rag';
  10. import { blobToFile, transformFileName } from '$lib/utils';
  11. import Checkbox from '$lib/components/common/Checkbox.svelte';
  12. import EditDocModal from '$lib/components/documents/EditDocModal.svelte';
  13. import AddFilesPlaceholder from '$lib/components/AddFilesPlaceholder.svelte';
  14. import AddDocModal from '$lib/components/documents/AddDocModal.svelte';
  15. import { transcribeAudio } from '$lib/apis/audio';
  16. import { uploadFile } from '$lib/apis/files';
  17. const i18n = getContext('i18n');
  18. let importFiles = '';
  19. let inputFiles = '';
  20. let query = '';
  21. let documentsImportInputElement: HTMLInputElement;
  22. let tags = [];
  23. let showSettingsModal = false;
  24. let showAddDocModal = false;
  25. let showEditDocModal = false;
  26. let selectedDoc;
  27. let selectedTag = '';
  28. let dragged = false;
  29. const deleteDoc = async (name) => {
  30. await deleteDocByName(localStorage.token, name);
  31. await documents.set(await getDocs(localStorage.token));
  32. };
  33. const deleteDocs = async (docs) => {
  34. const res = await Promise.all(
  35. docs.map(async (doc) => {
  36. return await deleteDocByName(localStorage.token, doc.name);
  37. })
  38. );
  39. await documents.set(await getDocs(localStorage.token));
  40. };
  41. const uploadDoc = async (file, tags?: object) => {
  42. console.log(file);
  43. // Check if the file is an audio file and transcribe/convert it to text file
  44. if (['audio/mpeg', 'audio/wav'].includes(file['type'])) {
  45. const transcribeRes = await transcribeAudio(localStorage.token, file).catch((error) => {
  46. toast.error(error);
  47. return null;
  48. });
  49. if (transcribeRes) {
  50. console.log(transcribeRes);
  51. const blob = new Blob([transcribeRes.text], { type: 'text/plain' });
  52. file = blobToFile(blob, `${file.name}.txt`);
  53. }
  54. }
  55. // Upload the file to the server
  56. const uploadedFile = await uploadFile(localStorage.token, file).catch((error) => {
  57. toast.error(error);
  58. return null;
  59. });
  60. const res = await processDocToVectorDB(localStorage.token, uploadedFile.id).catch((error) => {
  61. toast.error(error);
  62. return null;
  63. });
  64. if (res) {
  65. await createNewDoc(
  66. localStorage.token,
  67. res.collection_name,
  68. res.filename,
  69. transformFileName(res.filename),
  70. res.filename,
  71. tags?.length > 0
  72. ? {
  73. tags: tags
  74. }
  75. : null
  76. ).catch((error) => {
  77. toast.error(error);
  78. return null;
  79. });
  80. await documents.set(await getDocs(localStorage.token));
  81. }
  82. };
  83. onMount(() => {
  84. documents.subscribe((docs) => {
  85. tags = docs.reduce((a, e, i, arr) => {
  86. return [...new Set([...a, ...(e?.content?.tags ?? []).map((tag) => tag.name)])];
  87. }, []);
  88. });
  89. const dropZone = document.querySelector('body');
  90. const onDragOver = (e) => {
  91. e.preventDefault();
  92. dragged = true;
  93. };
  94. const onDragLeave = () => {
  95. dragged = false;
  96. };
  97. const onDrop = async (e) => {
  98. e.preventDefault();
  99. if (e.dataTransfer?.files) {
  100. let reader = new FileReader();
  101. reader.onload = (event) => {
  102. files = [
  103. ...files,
  104. {
  105. type: 'image',
  106. url: `${event.target.result}`
  107. }
  108. ];
  109. };
  110. const inputFiles = e.dataTransfer?.files;
  111. if (inputFiles && inputFiles.length > 0) {
  112. for (const file of inputFiles) {
  113. console.log(file, file.name.split('.').at(-1));
  114. if (
  115. SUPPORTED_FILE_TYPE.includes(file['type']) ||
  116. SUPPORTED_FILE_EXTENSIONS.includes(file.name.split('.').at(-1))
  117. ) {
  118. uploadDoc(file);
  119. } else {
  120. toast.error(
  121. `Unknown File Type '${file['type']}', but accepting and treating as plain text`
  122. );
  123. uploadDoc(file);
  124. }
  125. }
  126. } else {
  127. toast.error($i18n.t(`File not found.`));
  128. }
  129. }
  130. dragged = false;
  131. };
  132. dropZone?.addEventListener('dragover', onDragOver);
  133. dropZone?.addEventListener('drop', onDrop);
  134. dropZone?.addEventListener('dragleave', onDragLeave);
  135. return () => {
  136. dropZone?.removeEventListener('dragover', onDragOver);
  137. dropZone?.removeEventListener('drop', onDrop);
  138. dropZone?.removeEventListener('dragleave', onDragLeave);
  139. };
  140. });
  141. let filteredDocs;
  142. $: filteredDocs = $documents.filter(
  143. (doc) =>
  144. (selectedTag === '' ||
  145. (doc?.content?.tags ?? []).map((tag) => tag.name).includes(selectedTag)) &&
  146. (query === '' || doc.name.includes(query))
  147. );
  148. </script>
  149. <svelte:head>
  150. <title>
  151. {$i18n.t('Documents')} | {$WEBUI_NAME}
  152. </title>
  153. </svelte:head>
  154. {#if dragged}
  155. <div
  156. class="fixed {$showSidebar
  157. ? 'left-0 md:left-[260px] md:w-[calc(100%-260px)]'
  158. : 'left-0'} w-full h-full flex z-50 touch-none pointer-events-none"
  159. id="dropzone"
  160. role="region"
  161. aria-label="Drag and Drop Container"
  162. >
  163. <div class="absolute w-full h-full backdrop-blur bg-gray-800/40 flex justify-center">
  164. <div class="m-auto pt-64 flex flex-col justify-center">
  165. <div class="max-w-md">
  166. <AddFilesPlaceholder>
  167. <div class=" mt-2 text-center text-sm dark:text-gray-200 w-full">
  168. Drop any files here to add to my documents
  169. </div>
  170. </AddFilesPlaceholder>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. {/if}
  176. {#key selectedDoc}
  177. <EditDocModal bind:show={showEditDocModal} {selectedDoc} />
  178. {/key}
  179. <AddDocModal bind:show={showAddDocModal} {uploadDoc} />
  180. <div class="mb-3">
  181. <div class="flex justify-between items-center">
  182. <div class=" text-lg font-semibold self-center">{$i18n.t('Documents')}</div>
  183. </div>
  184. </div>
  185. <div class=" flex w-full space-x-2">
  186. <div class="flex flex-1">
  187. <div class=" self-center ml-1 mr-3">
  188. <svg
  189. xmlns="http://www.w3.org/2000/svg"
  190. viewBox="0 0 20 20"
  191. fill="currentColor"
  192. class="w-4 h-4"
  193. >
  194. <path
  195. fill-rule="evenodd"
  196. d="M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z"
  197. clip-rule="evenodd"
  198. />
  199. </svg>
  200. </div>
  201. <input
  202. class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-none bg-transparent"
  203. bind:value={query}
  204. placeholder={$i18n.t('Search Documents')}
  205. />
  206. </div>
  207. <div>
  208. <button
  209. class=" px-2 py-2 rounded-xl border border-gray-200 dark:border-gray-600 dark:border-0 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 transition font-medium text-sm flex items-center space-x-1"
  210. aria-label={$i18n.t('Add Docs')}
  211. on:click={() => {
  212. showAddDocModal = true;
  213. }}
  214. >
  215. <svg
  216. xmlns="http://www.w3.org/2000/svg"
  217. viewBox="0 0 16 16"
  218. fill="currentColor"
  219. class="w-4 h-4"
  220. >
  221. <path
  222. d="M8.75 3.75a.75.75 0 0 0-1.5 0v3.5h-3.5a.75.75 0 0 0 0 1.5h3.5v3.5a.75.75 0 0 0 1.5 0v-3.5h3.5a.75.75 0 0 0 0-1.5h-3.5v-3.5Z"
  223. />
  224. </svg>
  225. </button>
  226. </div>
  227. </div>
  228. <!-- <div>
  229. <div
  230. class="my-3 py-16 rounded-lg border-2 border-dashed dark:border-gray-600 {dragged &&
  231. ' dark:bg-gray-700'} "
  232. role="region"
  233. on:drop={onDrop}
  234. on:dragover={onDragOver}
  235. on:dragleave={onDragLeave}
  236. >
  237. <div class=" pointer-events-none">
  238. <div class="text-center dark:text-white text-2xl font-semibold z-50">{$i18n.t('Add Files')}</div>
  239. <div class=" mt-2 text-center text-sm dark:text-gray-200 w-full">
  240. Drop any files here to add to my documents
  241. </div>
  242. </div>
  243. </div>
  244. </div> -->
  245. <hr class=" dark:border-gray-850 my-2.5" />
  246. {#if tags.length > 0}
  247. <div class="px-2.5 pt-1 flex gap-1 flex-wrap">
  248. <div class="ml-0.5 pr-3 my-auto flex items-center">
  249. <Checkbox
  250. state={filteredDocs.filter((doc) => doc?.selected === 'checked').length ===
  251. filteredDocs.length
  252. ? 'checked'
  253. : 'unchecked'}
  254. indeterminate={filteredDocs.filter((doc) => doc?.selected === 'checked').length > 0 &&
  255. filteredDocs.filter((doc) => doc?.selected === 'checked').length !== filteredDocs.length}
  256. on:change={(e) => {
  257. if (e.detail === 'checked') {
  258. filteredDocs = filteredDocs.map((doc) => ({ ...doc, selected: 'checked' }));
  259. } else if (e.detail === 'unchecked') {
  260. filteredDocs = filteredDocs.map((doc) => ({ ...doc, selected: 'unchecked' }));
  261. }
  262. }}
  263. />
  264. </div>
  265. {#if filteredDocs.filter((doc) => doc?.selected === 'checked').length === 0}
  266. <button
  267. class="px-2 py-0.5 space-x-1 flex h-fit items-center rounded-full transition bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:text-white"
  268. on:click={async () => {
  269. selectedTag = '';
  270. // await chats.set(await getChatListByTagName(localStorage.token, tag.name));
  271. }}
  272. >
  273. <div class=" text-xs font-medium self-center line-clamp-1">{$i18n.t('all')}</div>
  274. </button>
  275. {#each tags as tag}
  276. <button
  277. class="px-2 py-0.5 space-x-1 flex h-fit items-center rounded-full transition bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:text-white"
  278. on:click={async () => {
  279. selectedTag = tag;
  280. // await chats.set(await getChatListByTagName(localStorage.token, tag.name));
  281. }}
  282. >
  283. <div class=" text-xs font-medium self-center line-clamp-1">
  284. #{tag}
  285. </div>
  286. </button>
  287. {/each}
  288. {:else}
  289. <div class="flex-1 flex w-full justify-between items-center">
  290. <div class="text-xs font-medium py-0.5 self-center mr-1">
  291. {filteredDocs.filter((doc) => doc?.selected === 'checked').length} Selected
  292. </div>
  293. <div class="flex gap-1">
  294. <!-- <button
  295. class="px-2 py-0.5 space-x-1 flex h-fit items-center rounded-full transition bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:text-white"
  296. on:click={async () => {
  297. selectedTag = '';
  298. // await chats.set(await getChatListByTagName(localStorage.token, tag.name));
  299. }}
  300. >
  301. <div class=" text-xs font-medium self-center line-clamp-1">add tags</div>
  302. </button> -->
  303. <button
  304. class="px-2 py-0.5 space-x-1 flex h-fit items-center rounded-full transition bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:text-white"
  305. on:click={async () => {
  306. deleteDocs(filteredDocs.filter((doc) => doc.selected === 'checked'));
  307. // await chats.set(await getChatListByTagName(localStorage.token, tag.name));
  308. }}
  309. >
  310. <div class=" text-xs font-medium self-center line-clamp-1">
  311. {$i18n.t('delete')}
  312. </div>
  313. </button>
  314. </div>
  315. </div>
  316. {/if}
  317. </div>
  318. {/if}
  319. <div class="my-3 mb-5">
  320. {#each filteredDocs as doc}
  321. <button
  322. class=" flex space-x-4 cursor-pointer text-left w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl"
  323. on:click={() => {
  324. if (doc?.selected === 'checked') {
  325. doc.selected = 'unchecked';
  326. } else {
  327. doc.selected = 'checked';
  328. }
  329. }}
  330. >
  331. <div class="my-auto flex items-center">
  332. <Checkbox state={doc?.selected ?? 'unchecked'} />
  333. </div>
  334. <div class=" flex flex-1 space-x-4 cursor-pointer w-full">
  335. <div class=" flex items-center space-x-3">
  336. <div class="p-2.5 bg-red-400 text-white rounded-lg">
  337. {#if doc}
  338. <svg
  339. xmlns="http://www.w3.org/2000/svg"
  340. viewBox="0 0 24 24"
  341. fill="currentColor"
  342. class="w-6 h-6"
  343. >
  344. <path
  345. fill-rule="evenodd"
  346. d="M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z"
  347. clip-rule="evenodd"
  348. />
  349. <path
  350. d="M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"
  351. />
  352. </svg>
  353. {:else}
  354. <svg
  355. class=" w-6 h-6 translate-y-[0.5px]"
  356. fill="currentColor"
  357. viewBox="0 0 24 24"
  358. xmlns="http://www.w3.org/2000/svg"
  359. ><style>
  360. .spinner_qM83 {
  361. animation: spinner_8HQG 1.05s infinite;
  362. }
  363. .spinner_oXPr {
  364. animation-delay: 0.1s;
  365. }
  366. .spinner_ZTLf {
  367. animation-delay: 0.2s;
  368. }
  369. @keyframes spinner_8HQG {
  370. 0%,
  371. 57.14% {
  372. animation-timing-function: cubic-bezier(0.33, 0.66, 0.66, 1);
  373. transform: translate(0);
  374. }
  375. 28.57% {
  376. animation-timing-function: cubic-bezier(0.33, 0, 0.66, 0.33);
  377. transform: translateY(-6px);
  378. }
  379. 100% {
  380. transform: translate(0);
  381. }
  382. }
  383. </style><circle class="spinner_qM83" cx="4" cy="12" r="2.5" /><circle
  384. class="spinner_qM83 spinner_oXPr"
  385. cx="12"
  386. cy="12"
  387. r="2.5"
  388. /><circle class="spinner_qM83 spinner_ZTLf" cx="20" cy="12" r="2.5" /></svg
  389. >
  390. {/if}
  391. </div>
  392. <div class=" self-center flex-1">
  393. <div class=" font-semibold line-clamp-1">#{doc.name} ({doc.filename})</div>
  394. <div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
  395. {doc.title}
  396. </div>
  397. </div>
  398. </div>
  399. </div>
  400. <div class="flex flex-row space-x-1 self-center">
  401. <button
  402. class="self-center w-fit text-sm z-20 px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
  403. type="button"
  404. aria-label={$i18n.t('Edit Doc')}
  405. on:click={async (e) => {
  406. e.stopPropagation();
  407. showEditDocModal = !showEditDocModal;
  408. selectedDoc = doc;
  409. }}
  410. >
  411. <svg
  412. xmlns="http://www.w3.org/2000/svg"
  413. fill="none"
  414. viewBox="0 0 24 24"
  415. stroke-width="1.5"
  416. stroke="currentColor"
  417. class="w-4 h-4"
  418. >
  419. <path
  420. stroke-linecap="round"
  421. stroke-linejoin="round"
  422. d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125"
  423. />
  424. </svg>
  425. </button>
  426. <!-- <button
  427. class="self-center w-fit text-sm px-2 py-2 border dark:border-gray-600 rounded-xl"
  428. type="button"
  429. on:click={() => {
  430. console.log('download file');
  431. }}
  432. >
  433. <svg
  434. xmlns="http://www.w3.org/2000/svg"
  435. viewBox="0 0 16 16"
  436. fill="currentColor"
  437. class="w-4 h-4"
  438. >
  439. <path
  440. d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z"
  441. />
  442. <path
  443. d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z"
  444. />
  445. </svg>
  446. </button> -->
  447. <button
  448. class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
  449. type="button"
  450. aria-label={$i18n.t('Delete Doc')}
  451. on:click={(e) => {
  452. e.stopPropagation();
  453. deleteDoc(doc.name);
  454. }}
  455. >
  456. <svg
  457. xmlns="http://www.w3.org/2000/svg"
  458. fill="none"
  459. viewBox="0 0 24 24"
  460. stroke-width="1.5"
  461. stroke="currentColor"
  462. class="w-4 h-4"
  463. >
  464. <path
  465. stroke-linecap="round"
  466. stroke-linejoin="round"
  467. d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
  468. />
  469. </svg>
  470. </button>
  471. </div>
  472. </button>
  473. {/each}
  474. </div>
  475. <div class=" text-gray-500 text-xs mt-1 mb-2">
  476. ⓘ {$i18n.t("Use '#' in the prompt input to load and select your documents.")}
  477. </div>
  478. <div class=" flex justify-end w-full mb-2">
  479. <div class="flex space-x-2">
  480. <input
  481. id="documents-import-input"
  482. bind:this={documentsImportInputElement}
  483. bind:files={importFiles}
  484. type="file"
  485. accept=".json"
  486. hidden
  487. on:change={() => {
  488. console.log(importFiles);
  489. const reader = new FileReader();
  490. reader.onload = async (event) => {
  491. const savedDocs = JSON.parse(event.target.result);
  492. console.log(savedDocs);
  493. for (const doc of savedDocs) {
  494. await createNewDoc(
  495. localStorage.token,
  496. doc.collection_name,
  497. doc.filename,
  498. doc.name,
  499. doc.title
  500. ).catch((error) => {
  501. toast.error(error);
  502. return null;
  503. });
  504. }
  505. await documents.set(await getDocs(localStorage.token));
  506. };
  507. reader.readAsText(importFiles[0]);
  508. }}
  509. />
  510. <button
  511. class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
  512. on:click={() => {
  513. documentsImportInputElement.click();
  514. }}
  515. >
  516. <div class=" self-center mr-2 font-medium line-clamp-1">
  517. {$i18n.t('Import Documents Mapping')}
  518. </div>
  519. <div class=" self-center">
  520. <svg
  521. xmlns="http://www.w3.org/2000/svg"
  522. viewBox="0 0 16 16"
  523. fill="currentColor"
  524. class="w-4 h-4"
  525. >
  526. <path
  527. fill-rule="evenodd"
  528. d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 9.5a.75.75 0 0 1-.75-.75V8.06l-.72.72a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-.72-.72v2.69a.75.75 0 0 1-.75.75Z"
  529. clip-rule="evenodd"
  530. />
  531. </svg>
  532. </div>
  533. </button>
  534. <button
  535. class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
  536. on:click={async () => {
  537. let blob = new Blob([JSON.stringify($documents)], {
  538. type: 'application/json'
  539. });
  540. saveAs(blob, `documents-mapping-export-${Date.now()}.json`);
  541. }}
  542. >
  543. <div class=" self-center mr-2 font-medium line-clamp-1">
  544. {$i18n.t('Export Documents Mapping')}
  545. </div>
  546. <div class=" self-center">
  547. <svg
  548. xmlns="http://www.w3.org/2000/svg"
  549. viewBox="0 0 16 16"
  550. fill="currentColor"
  551. class="w-4 h-4"
  552. >
  553. <path
  554. fill-rule="evenodd"
  555. d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
  556. clip-rule="evenodd"
  557. />
  558. </svg>
  559. </div>
  560. </button>
  561. </div>
  562. </div>