From 7bfa2b56873453d48d3e5929d25338b606086aab Mon Sep 17 00:00:00 2001 From: Rosano Date: Sun, 11 Apr 2021 13:30:07 -0300 Subject: [PATCH 1/2] Extract objectKey param --- DragDropList.svelte | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DragDropList.svelte b/DragDropList.svelte index 3612d99..30ebb55 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))}
{/each}
- \ No newline at end of file + From 3ad100f51753abfcf4e448d840c24a2c92190721 Mon Sep 17 00:00:00 2001 From: Rosano Date: Sun, 11 Apr 2021 13:35:28 -0300 Subject: [PATCH 2/2] Extract customView slot --- DragDropList.svelte | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/DragDropList.svelte b/DragDropList.svelte index 30ebb55..ea5ecf8 100644 --- a/DragDropList.svelte +++ b/DragDropList.svelte @@ -206,12 +206,16 @@
- {#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}