@emamid/svelte-data-table 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DataTable.svelte +20 -1
- package/dist/DataTable.svelte.d.ts +2 -0
- package/package.json +1 -1
package/dist/DataTable.svelte
CHANGED
|
@@ -203,6 +203,19 @@ const rowClicked = (item) => {
|
|
|
203
203
|
item
|
|
204
204
|
});
|
|
205
205
|
};
|
|
206
|
+
let draggedItem = null;
|
|
207
|
+
const rowDragStart = (item) => {
|
|
208
|
+
draggedItem = item;
|
|
209
|
+
dispatch("rowDragStart", {
|
|
210
|
+
draggedItem
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
const rowDropped = (targetItem) => {
|
|
214
|
+
dispatch("rowDropped", {
|
|
215
|
+
draggedItem,
|
|
216
|
+
targetItem
|
|
217
|
+
});
|
|
218
|
+
};
|
|
206
219
|
</script>
|
|
207
220
|
|
|
208
221
|
<Table class={tableClass} {divClass} {striped} {hoverable} {noborder} {shadow} {color} {customColor}>
|
|
@@ -222,7 +235,13 @@ const rowClicked = (item) => {
|
|
|
222
235
|
<TableBody {tableBodyClass}>
|
|
223
236
|
{#each sortedItems as item}
|
|
224
237
|
{@const isRowFocused = !!focusedItemKey && focusedItemKey === getItemKey(item)}
|
|
225
|
-
<TableBodyRow
|
|
238
|
+
<TableBodyRow
|
|
239
|
+
class={getTRClass(item, isRowFocused)}
|
|
240
|
+
draggable={true}
|
|
241
|
+
on:click={() => rowClicked(item)}
|
|
242
|
+
on:dragstart={() => rowDragStart(item)}
|
|
243
|
+
on:drop={() => rowDropped(item)}
|
|
244
|
+
>
|
|
226
245
|
{#each internalColumns as column}
|
|
227
246
|
{@const isCellFocused =
|
|
228
247
|
isRowFocused && focusedColumnKeyID && focusedColumnKeyID === getColumnID(column)}
|