@emamid/svelte-data-table 0.0.17 → 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
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)}
|
|
@@ -5,5 +5,5 @@ export {};
|
|
|
5
5
|
* @property {string} [caption] - Text to be displayed inside the button.
|
|
6
6
|
* @property {ConstructorOfATypedSvelteComponent} [icon] - Icon to be displayed inside the button.
|
|
7
7
|
* @property {string} [iconClass] - CSS class of the icon to be displayed inside the button.
|
|
8
|
-
* @property {'left' | 'right'} [iconPosition] - Position of the icon, relative to the caption.
|
|
8
|
+
* @property {'left' | 'right'} [iconPosition] - Position of the icon, relative to the caption. Defaults to 'right'.
|
|
9
9
|
*/
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @property {string} [caption] - Text to be displayed inside the button.
|
|
6
6
|
* @property {ConstructorOfATypedSvelteComponent} [icon] - Icon to be displayed inside the button.
|
|
7
7
|
* @property {string} [iconClass] - CSS class of the icon to be displayed inside the button.
|
|
8
|
-
* @property {'left' | 'right'} [iconPosition] - Position of the icon, relative to the caption.
|
|
8
|
+
* @property {'left' | 'right'} [iconPosition] - Position of the icon, relative to the caption. Defaults to 'right'.
|
|
9
9
|
*/
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { Button } from "flowbite-svelte";
|
|
1
|
+
<script>import { Button } from "flowbite-svelte";
|
|
3
2
|
export let caption = "";
|
|
4
3
|
export let column;
|
|
5
4
|
export let item;
|
|
6
5
|
export let icon = null;
|
|
7
6
|
export let iconClass = "";
|
|
8
7
|
export let iconPosition = "right";
|
|
9
|
-
const dispatch = createEventDispatcher();
|
|
10
|
-
const buttonClicked = () => {
|
|
11
|
-
dispatch("click", {
|
|
12
|
-
column,
|
|
13
|
-
item
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
8
|
</script>
|
|
17
9
|
|
|
18
|
-
<Button
|
|
10
|
+
<Button>
|
|
19
11
|
{#if icon && iconPosition === 'left'}
|
|
20
12
|
<svelte:component this={icon} class={iconClass} />
|
|
21
13
|
{/if}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { ColumnConfig } from '../common.js';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
|
-
[x: string]: any;
|
|
6
4
|
caption?: string | undefined;
|
|
7
5
|
column: ColumnConfig;
|
|
8
6
|
item: any;
|
|
@@ -11,8 +9,6 @@ declare const __propDef: {
|
|
|
11
9
|
iconPosition?: "left" | "right" | undefined;
|
|
12
10
|
};
|
|
13
11
|
events: {
|
|
14
|
-
click: CustomEvent<any>;
|
|
15
|
-
} & {
|
|
16
12
|
[evt: string]: CustomEvent<any>;
|
|
17
13
|
};
|
|
18
14
|
slots: {};
|