{#if selection.length > 0} {pluralize(selection?.length ?? 1, 'item') + ' selected'} {/if}
{ return convertJsonToCsv( selection.length > 0 ? sortObjects(activeSorting, structuredObjects, true) .filter(({ _id }) => selection.includes(_id)) .map((obj) => colSelection.length == 0 ? obj.rowData : Object.fromEntries( Object.entries(obj.rowData).filter(([key, _]) => colSelection.includes(key) ) ) ) : colSelection.length == 0 ? sortObjects(activeSorting, objects, false) : sortObjects(activeSorting, objects, false).map((obj) => Object.fromEntries( Object.entries(obj).filter(([key, _]) => colSelection.includes(key)) ) ) ) }} customText={selection.length > 0 || colSelection.length > 0 ? 'Download selected as CSV' : undefined} /> { const actions = [ { displayName: 'Download JSON', icon: Download, action: () => { const json = JSON.stringify(objects, null, 2) const blob = new Blob([json], { type: 'text/json;charset=utf-8;' }) const url = URL.createObjectURL(blob) const link = document.createElement('a') link.setAttribute('href', url) link.setAttribute('download', 'data.json') link.style.visibility = 'hidden' document.body.appendChild(link) link.click() document.body.removeChild(link) } } ] if (selection.length > 0) { actions.push({ displayName: 'Clear selection', icon: Columns, action: () => { colSelection = [] selection = [] renderCount++ } }) } return actions }} >
{#key renderCount} {#if data.length == 0}
No data found
Try changing your search query
{:else} { currentPage += 1 }} on:previous={() => { currentPage -= 1 }} on:change={(event) => { currentPage = event.detail }} showNext={currentPage * perPage < objects.length} rowCount={data.length} > {#each headers ?? [] as key, index}
{key} {#if activeSorting?.column === key} {:else} {/if} handleColumnSelected(key)} />
{/each} {#each slicedData.filter((x) => x) as { _id, rowData }, index (index)} handleCheckboxChange(_id)} /> {#each headers as key, index} {@const value = rowData[key]} {#if Array.isArray(value) && value.length === 0}
{:else if Array.isArray(value) && typeof value?.[0] === 'string'}
{#each value as item, index} {item} {/each}
{:else if Array.isArray(value) && typeof value?.[0] === 'number'}
{#each value as val}
{JSON.stringify(val, null, 2)}
{/each}
{:else if Array.isArray(value)}
{#each value as val}
{JSON.stringify(val, null, 2)}
{/each}
{:else if typeof value === 'string' && isEmail(value)} {value} {:else if typeof value === 'string' && isLink(value)} {value} {:else} {@const txt = value == undefined || value == null ? '' : typeof value != 'string' ? JSON.stringify(value) : value}
{txt?.length > 100 ? txt.slice(0, 100) + '...' : txt}
{txt}
{/if} {/each} {/each} {/if} {/key}