From 53f3452f3242bbded4ed4141ea3d8f7fb38809ec Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Mon, 23 Dec 2024 16:02:47 +0100 Subject: [PATCH] Lib: Allow table value formatting function to return promise --- src/lib/components/Table.svelte | 6 ++++-- src/lib/components/Table.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/components/Table.svelte b/src/lib/components/Table.svelte index 0b31530..532097b 100644 --- a/src/lib/components/Table.svelte +++ b/src/lib/components/Table.svelte @@ -20,7 +20,7 @@ {#each columns as col} - {col.label} + {col.label} {/each} @@ -34,7 +34,9 @@ > {#each columns as col} {#if col.valuefun} - {@html col.valuefun(row[col.data_value_name])} + + {#await col.valuefun(row[col.data_value_name]) then value}{@html value}{/await} + {:else} {row[col.data_value_name]} {/if} diff --git a/src/lib/components/Table.ts b/src/lib/components/Table.ts index 9733df4..7037f7f 100644 --- a/src/lib/components/Table.ts +++ b/src/lib/components/Table.ts @@ -6,5 +6,5 @@ export interface TableColumn { label: string; /** Any function to further customize the displayed value. May return HTML. */ - valuefun?: (value: any) => string; + valuefun?: (value: any) => Promise; }