diff --git a/DragDropList.svelte b/DragDropList.svelte index 3612d99..ea5ecf8 100644 --- a/DragDropList.svelte +++ b/DragDropList.svelte @@ -3,6 +3,7 @@ export let data = []; export let removesItems = false; + export let objectKey = 'id'; let ghost; let grabbed; @@ -177,12 +178,12 @@ on:touchmove={function(ev) {ev.stopPropagation(); drag(ev.touches[0].clientY);}} on:mouseup={function(ev) {ev.stopPropagation(); release(ev);}} on:touchend={function(ev) {ev.stopPropagation(); release(ev.touches[0]);}}> - {#each data as datum, i (datum.id ? datum.id : JSON.stringify(datum))} + {#each data as datum, i (datum[objectKey] ? datum[objectKey] : JSON.stringify(datum))}
- {#if datum.html} - {@html datum.html} - {:else if datum.text} -

{datum.text}

+ {#if $$slots.customView} + {:else} -

{datum}

+ {#if datum.html} + {@html datum.html} + {:else if datum.text} +

{datum.text}

+ {:else} +

{datum}

+ {/if} {/if}
@@ -225,4 +230,4 @@
{/each} - \ No newline at end of file +