getItemsPage(true)} /> {#snippet chip(label: string, value: string, onClear: () => void, dots: string[] = [])}
{label} {$i18n.t('is')}
{/snippet}
{#if loaded && items !== null && total !== null} { if (!importDocumentFiles || importDocumentFiles.length === 0) return; try { await inputFilesHandler(Array.from(importDocumentFiles)); toast.success($i18n.t('Imported notes successfully')); } catch (error) { toast.error(`${error}`); } finally { importDocumentFiles = null; notesImportInputElement.value = ''; } }} /> withListFocus(containerElement, selectedNote.id, deleteNoteHandler, searchInputElement)} >
{$i18n.t('This will delete')} {selectedNote.title}.
{#if $mobile && !pageTab}
{/if}
{$i18n.t('Show')}
{#each [[null, 'All'], ['created', 'Created by you'], ['shared', 'Shared with you']] as const as [value, label]} {/each} {#if [null, 'shared'].includes(viewOption)}
{$i18n.t('Access')}
{#each [[null, 'Write'], ['read_only', 'Read Only']] as const as [value, label]} {/each} {/if}
{#if tagOptions.length > 8}
{/if} {#each tagFilterOptions as tag (tag.id)} {:else}
{$i18n.t('No results')}
{/each}
{#if filterCount}
{/if}
{$i18n.t('Layout')}
{#each [[null, 'List', 'list'], ['grid', 'Grid', 'grid']] as const as [value, label, icon]} {/each}
{#each [['updated_at', 'Updated'], ['name', 'Title']] as const as [value, label]} {/each}
{#each [['asc', 'Ascending'], ['desc', 'Descending']] as const as [value, label]} {/each}
{#if filterCount}
{#if viewOption} {@render chip( $i18n.t('Show'), $i18n.t(viewOption === 'created' ? 'Created by you' : 'Shared with you'), () => setViewOption(null) )} {/if} {#if permission} {@render chip($i18n.t('Access'), $i18n.t('Read Only'), () => (permission = null))} {/if} {#if selectedTags.length} {@const picked = selectedTags.map( (id) => tagOptions.find((tag) => tag.id === id) ?? { id, name: id === UNTAGGED ? $i18n.t('Untagged') : id.replaceAll('_', ' ') } )} {@render chip( $i18n.t('Tags'), picked.length > 2 ? $i18n.t('{{count}} selected', { count: picked.length }) : picked.map((tag) => tag.name).join(', '), () => (selectedTags = []), picked .slice(0, 3) .map((tag) => tag.id === UNTAGGED ? 'border border-dashed border-base-400' : tagDot(tag) ) )} {/if}
{/if} {#if error} {/if} {#if items !== null && total !== null} {#if (items ?? []).length > 0} {@const groupedNotes = groupNotes(items)}
{#if displayOption === null}
{/if} {#each groupedNotes as [timeRange, notesList], idx (timeRange)}
{$i18n.t(timeRange)}
{#if displayOption === null}
    {#each notesList as note (note.id)} {@const snippet = query ? searchSnippet(note, query) : ''} { if (!confirm) return deleteNoteHandler(note.id); selectedNote = note; showDeleteConfirm = true; }} onAccess={(note.user_id === $user?.id && $user?.permissions?.sharing?.notes) || $user?.role === 'admin' ? () => accessModal.open(note.id) : null} /> {/each}
{:else if displayOption === 'grid'}
{#each notesList as note (note.id)}
setNoteDragData(e, note, noteUrl(note))} class="focus-ring flex min-w-0 flex-col items-center gap-1 rounded-xl px-1 pt-2 pb-1.5 text-center transition-colors duration-75 hover:bg-base-50/60 dark:hover:bg-base-0/4" aria-label={note.title} > {note.title} {dayjs(note.updated_at / 1000000) .locale($i18n.language) .fromNow()} {#if shiftKey} {:else} accessModal.open(note.id) : null} show={openNoteMenuId === note.id} folderId={note.folder_id} onMove={note.user_id === $user?.id ? (folderId) => moveNoteHandler(note, folderId) : null} onDownload={(type) => { selectedNote = note; downloadHandler(type); }} onCopyLink={async () => { const baseUrl = window.location.origin; const res = await copyToClipboard(`${baseUrl}/notes/${note.id}`); if (res) { toast.success($i18n.t('Copied link to clipboard')); } else { toast.error($i18n.t('Failed to copy link')); } }} onDelete={() => { selectedNote = note; showDeleteConfirm = true; }} isPinned={$pinnedNotes.some((n) => n.id === note.id)} onPin={async () => { await toggleNotePinnedStatusById(localStorage.token, note.id); pinnedNotes.set( await getPinnedNoteList(localStorage.token).catch(() => []) ); }} onChange={(state) => { openNoteMenuId = state ? note.id : null; }} > {/if}
{/each}
{/if} {/each} {#if !allItemsLoaded} { if (!itemsLoading) { loadMoreItems(); } }} >
{$i18n.t('Loading...')}
{/if}
{:else if itemsLoading}
{:else if !error} {@const filtered = Boolean(query || filterCount)}
{filtered ? $i18n.t('No notes found') : $i18n.t('No Notes')}
{filtered ? $i18n.t('Try a different search or remove a filter.') : $i18n.t('Create your first note from the + menu.')}
{#if filtered} {/if}
{/if} {:else}
{/if}
{:else}
{/if}