@emamid/svelte-data-table 0.0.22 → 1.0.1
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 +303 -239
- package/dist/DataTable.svelte.d.ts +30 -60
- package/dist/DataTableDataCell.svelte +157 -90
- package/dist/DataTableDataCell.svelte.d.ts +18 -27
- package/dist/DataTableHeaderCell.svelte +63 -21
- package/dist/DataTableHeaderCell.svelte.d.ts +9 -23
- package/dist/DataTableIcon.svelte +25 -0
- package/dist/DataTableIcon.svelte.d.ts +9 -0
- package/dist/DataTableRow.svelte +150 -80
- package/dist/DataTableRow.svelte.d.ts +26 -34
- package/dist/cells/Actions.d.ts +1 -1
- package/dist/cells/Actions.js +10 -11
- package/dist/cells/ActionsCell.svelte +56 -33
- package/dist/cells/ActionsCell.svelte.d.ts +9 -47
- package/dist/cells/ButtonCell.svelte +58 -16
- package/dist/cells/ButtonCell.svelte.d.ts +11 -20
- package/dist/cells/CheckboxCell.svelte +72 -19
- package/dist/cells/CheckboxCell.svelte.d.ts +11 -22
- package/dist/cells/InputCell.svelte +93 -48
- package/dist/cells/InputCell.svelte.d.ts +14 -25
- package/dist/cells/MultiSelectCell.svelte +85 -25
- package/dist/cells/MultiSelectCell.svelte.d.ts +15 -26
- package/dist/cells/NumberInputCell.svelte +90 -44
- package/dist/cells/NumberInputCell.svelte.d.ts +13 -24
- package/dist/cells/RadioCell.svelte +66 -0
- package/dist/cells/RadioCell.svelte.d.ts +12 -0
- package/dist/cells/RangeCell.svelte +66 -17
- package/dist/cells/RangeCell.svelte.d.ts +13 -22
- package/dist/cells/SelectCell.svelte +87 -25
- package/dist/cells/SelectCell.svelte.d.ts +15 -26
- package/dist/cells/SpinCell.svelte +91 -42
- package/dist/cells/SpinCell.svelte.d.ts +13 -28
- package/dist/cells/TabWrapper.svelte +23 -21
- package/dist/cells/TabWrapper.svelte.d.ts +10 -22
- package/dist/cells/index.d.ts +2 -4
- package/dist/cells/index.js +2 -4
- package/dist/common.d.ts +199 -53
- package/dist/common.js +30 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/themes/active.d.ts +4 -0
- package/dist/themes/active.js +12 -0
- package/dist/themes/daisyUI.d.ts +2 -0
- package/dist/themes/daisyUI.js +47 -0
- package/dist/themes/default.d.ts +2 -0
- package/dist/themes/default.js +57 -0
- package/dist/themes/iconify.d.ts +2 -0
- package/dist/themes/iconify.js +33 -0
- package/dist/themes/index.d.ts +4 -0
- package/dist/themes/index.js +4 -0
- package/package.json +28 -32
- package/dist/DataTable.doc.d.ts +0 -81
- package/dist/DataTable.doc.js +0 -81
- package/dist/cells/ActionsCell.doc.d.ts +0 -28
- package/dist/cells/ActionsCell.doc.js +0 -28
- package/dist/cells/ButtonCell.doc.d.ts +0 -9
- package/dist/cells/ButtonCell.doc.js +0 -9
- package/dist/cells/CheckboxCell.doc.d.ts +0 -6
- package/dist/cells/CheckboxCell.doc.js +0 -6
- package/dist/cells/InputCell.doc.d.ts +0 -6
- package/dist/cells/InputCell.doc.js +0 -6
- package/dist/cells/MultiSelectCell.doc.d.ts +0 -8
- package/dist/cells/MultiSelectCell.doc.js +0 -8
- package/dist/cells/NumberInputCell.doc.d.ts +0 -6
- package/dist/cells/NumberInputCell.doc.js +0 -6
- package/dist/cells/RangeCell.doc.d.ts +0 -7
- package/dist/cells/RangeCell.doc.js +0 -7
- package/dist/cells/RatingCell.doc.d.ts +0 -7
- package/dist/cells/RatingCell.doc.js +0 -7
- package/dist/cells/RatingCell.svelte +0 -13
- package/dist/cells/RatingCell.svelte.d.ts +0 -22
- package/dist/cells/SelectCell.doc.d.ts +0 -8
- package/dist/cells/SelectCell.doc.js +0 -8
- package/dist/cells/SpinCell.doc.d.ts +0 -13
- package/dist/cells/SpinCell.doc.js +0 -13
- package/dist/cells/TabWrapper.doc.d.ts +0 -5
- package/dist/cells/TabWrapper.doc.js +0 -5
- package/dist/cells/ToggleCell.doc.d.ts +0 -6
- package/dist/cells/ToggleCell.doc.js +0 -6
- package/dist/cells/ToggleCell.svelte +0 -21
- package/dist/cells/ToggleCell.svelte.d.ts +0 -23
package/dist/DataTableRow.svelte
CHANGED
|
@@ -1,78 +1,146 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import DataTableDataCell from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { activeTheme } from './themes/active';
|
|
3
|
+
import DataTableDataCell from './DataTableDataCell.svelte';
|
|
4
|
+
import {
|
|
5
|
+
evalRowDropBoolean,
|
|
6
|
+
evalRowBoolean,
|
|
7
|
+
getColumnID,
|
|
8
|
+
getDataTableContext,
|
|
9
|
+
joinPartClasses,
|
|
10
|
+
} from './common';
|
|
11
|
+
import type {
|
|
12
|
+
ActionEvent,
|
|
13
|
+
ColumnConfig,
|
|
14
|
+
DataCellChangedEvent,
|
|
15
|
+
DataCellDragEvent,
|
|
16
|
+
DataCellDropEvent,
|
|
17
|
+
DataCellEvent,
|
|
18
|
+
DataCellMouseEvent,
|
|
19
|
+
RowBoolean,
|
|
20
|
+
RowClassFunction,
|
|
21
|
+
RowDragEvent,
|
|
22
|
+
RowDropBoolean,
|
|
23
|
+
RowDropEvent,
|
|
24
|
+
RowEvent,
|
|
25
|
+
} from './common';
|
|
26
|
+
|
|
27
|
+
interface Props {
|
|
28
|
+
allowRowDrag: RowBoolean;
|
|
29
|
+
allowRowDrop: RowDropBoolean;
|
|
30
|
+
columns: ColumnConfig[];
|
|
31
|
+
focusedColumnKeyID: any;
|
|
32
|
+
isRowFocused: boolean;
|
|
33
|
+
item: any;
|
|
34
|
+
onaction?: (event: ActionEvent) => void;
|
|
35
|
+
onbutton?: (event: DataCellEvent) => void;
|
|
36
|
+
oncellchanged?: (event: DataCellChangedEvent) => void;
|
|
37
|
+
oncellclick?: (event: DataCellMouseEvent) => void;
|
|
38
|
+
oncelldragend?: (event: DataCellDragEvent) => void;
|
|
39
|
+
oncelldragstart?: (event: DataCellDragEvent) => void;
|
|
40
|
+
oncelldropped?: (event: DataCellDropEvent) => void;
|
|
41
|
+
ondragend?: (event: RowDragEvent) => void;
|
|
42
|
+
ondragstart?: (event: RowDragEvent) => void;
|
|
43
|
+
ondropped?: (event: RowDropEvent) => void;
|
|
44
|
+
onenterpressed?: (event: DataCellEvent) => void;
|
|
45
|
+
onnexttab?: (event: DataCellEvent) => void;
|
|
46
|
+
onprevtab?: (event: DataCellEvent) => void;
|
|
47
|
+
onrowclick?: (event: RowEvent) => void;
|
|
48
|
+
trClassGetter?: RowClassFunction;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let {
|
|
52
|
+
allowRowDrag,
|
|
53
|
+
allowRowDrop,
|
|
54
|
+
columns,
|
|
55
|
+
focusedColumnKeyID,
|
|
56
|
+
isRowFocused,
|
|
57
|
+
item,
|
|
58
|
+
onaction,
|
|
59
|
+
onbutton,
|
|
60
|
+
oncellchanged,
|
|
61
|
+
oncellclick,
|
|
62
|
+
oncelldragend,
|
|
63
|
+
oncelldragstart,
|
|
64
|
+
oncelldropped,
|
|
65
|
+
ondragend,
|
|
66
|
+
ondragstart,
|
|
67
|
+
ondropped,
|
|
68
|
+
onenterpressed,
|
|
69
|
+
onnexttab,
|
|
70
|
+
onprevtab,
|
|
71
|
+
onrowclick,
|
|
72
|
+
trClassGetter,
|
|
73
|
+
}: Props = $props();
|
|
74
|
+
|
|
75
|
+
const context = getDataTableContext();
|
|
76
|
+
const tableTheme = context.theme || {};
|
|
77
|
+
|
|
78
|
+
const rowClicked = () => onrowclick?.({ item });
|
|
79
|
+
|
|
80
|
+
const dragEnd = (event: DragEvent) => {
|
|
81
|
+
ondragend?.({
|
|
82
|
+
...event,
|
|
83
|
+
sourceItem: item,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const dragOver = (event: DragEvent) => {
|
|
88
|
+
const { draggedItem } = context;
|
|
89
|
+
const canDrop = evalRowDropBoolean(draggedItem, item, allowRowDrop);
|
|
90
|
+
if (canDrop) {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
if (event.dataTransfer) {
|
|
93
|
+
event.dataTransfer.dropEffect = 'move';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const dragStart = (dragEvent: DragEvent) => {
|
|
99
|
+
if (context.dragType) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
ondragstart?.({
|
|
103
|
+
...dragEvent,
|
|
104
|
+
sourceItem: item,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const drop = (event: DragEvent) => {
|
|
109
|
+
const { draggedItem } = context;
|
|
110
|
+
const canDrop = evalRowDropBoolean(draggedItem, item, allowRowDrop);
|
|
111
|
+
if (!canDrop) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
ondropped?.({
|
|
117
|
+
...event,
|
|
118
|
+
sourceItem: draggedItem,
|
|
119
|
+
targetItem: item,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const baseTRClass = $derived(joinPartClasses(
|
|
124
|
+
'row',
|
|
125
|
+
'tr', [
|
|
126
|
+
activeTheme,
|
|
127
|
+
tableTheme,
|
|
128
|
+
],
|
|
129
|
+
isRowFocused,
|
|
130
|
+
));
|
|
131
|
+
|
|
132
|
+
const trClass = $derived(trClassGetter ? trClassGetter(item, isRowFocused, baseTRClass) : baseTRClass);
|
|
67
133
|
</script>
|
|
68
134
|
|
|
69
|
-
<
|
|
70
|
-
class={
|
|
135
|
+
<tr
|
|
136
|
+
class={trClass}
|
|
71
137
|
draggable={evalRowBoolean(item, allowRowDrag)}
|
|
138
|
+
onclick={rowClicked}
|
|
139
|
+
ondragend={dragEnd}
|
|
140
|
+
ondragover={dragOver}
|
|
141
|
+
ondragstart={dragStart}
|
|
142
|
+
ondrop={drop}
|
|
72
143
|
>
|
|
73
|
-
{#if !!allowRowDrag || !!allowRowDrop}
|
|
74
|
-
<span style="display:none" bind:this={span}></span>
|
|
75
|
-
{/if}
|
|
76
144
|
{#each columns as column}
|
|
77
145
|
{@const isCellFocused =
|
|
78
146
|
isRowFocused && focusedColumnKeyID && focusedColumnKeyID === getColumnID(column)}
|
|
@@ -80,14 +148,16 @@ onDestroy(() => {
|
|
|
80
148
|
{column}
|
|
81
149
|
{isCellFocused}
|
|
82
150
|
{item}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
151
|
+
{onaction}
|
|
152
|
+
{onbutton}
|
|
153
|
+
{oncellchanged}
|
|
154
|
+
{oncelldragend}
|
|
155
|
+
{oncelldragstart}
|
|
156
|
+
{oncelldropped}
|
|
157
|
+
onclick={oncellclick}
|
|
158
|
+
{onenterpressed}
|
|
159
|
+
{onnexttab}
|
|
160
|
+
{onprevtab}
|
|
91
161
|
/>
|
|
92
162
|
{/each}
|
|
93
|
-
</
|
|
163
|
+
</tr>
|
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
rowDropped: CustomEvent<any>;
|
|
25
|
-
} & {
|
|
26
|
-
[evt: string]: CustomEvent<any>;
|
|
27
|
-
};
|
|
28
|
-
slots: {};
|
|
29
|
-
};
|
|
30
|
-
export type DataTableRowProps = typeof __propDef.props;
|
|
31
|
-
export type DataTableRowEvents = typeof __propDef.events;
|
|
32
|
-
export type DataTableRowSlots = typeof __propDef.slots;
|
|
33
|
-
export default class DataTableRow extends SvelteComponent<DataTableRowProps, DataTableRowEvents, DataTableRowSlots> {
|
|
1
|
+
import type { ActionEvent, ColumnConfig, DataCellChangedEvent, DataCellDragEvent, DataCellDropEvent, DataCellEvent, DataCellMouseEvent, RowBoolean, RowClassFunction, RowDragEvent, RowDropBoolean, RowDropEvent, RowEvent } from './common';
|
|
2
|
+
interface Props {
|
|
3
|
+
allowRowDrag: RowBoolean;
|
|
4
|
+
allowRowDrop: RowDropBoolean;
|
|
5
|
+
columns: ColumnConfig[];
|
|
6
|
+
focusedColumnKeyID: any;
|
|
7
|
+
isRowFocused: boolean;
|
|
8
|
+
item: any;
|
|
9
|
+
onaction?: (event: ActionEvent) => void;
|
|
10
|
+
onbutton?: (event: DataCellEvent) => void;
|
|
11
|
+
oncellchanged?: (event: DataCellChangedEvent) => void;
|
|
12
|
+
oncellclick?: (event: DataCellMouseEvent) => void;
|
|
13
|
+
oncelldragend?: (event: DataCellDragEvent) => void;
|
|
14
|
+
oncelldragstart?: (event: DataCellDragEvent) => void;
|
|
15
|
+
oncelldropped?: (event: DataCellDropEvent) => void;
|
|
16
|
+
ondragend?: (event: RowDragEvent) => void;
|
|
17
|
+
ondragstart?: (event: RowDragEvent) => void;
|
|
18
|
+
ondropped?: (event: RowDropEvent) => void;
|
|
19
|
+
onenterpressed?: (event: DataCellEvent) => void;
|
|
20
|
+
onnexttab?: (event: DataCellEvent) => void;
|
|
21
|
+
onprevtab?: (event: DataCellEvent) => void;
|
|
22
|
+
onrowclick?: (event: RowEvent) => void;
|
|
23
|
+
trClassGetter?: RowClassFunction;
|
|
34
24
|
}
|
|
35
|
-
|
|
25
|
+
declare const DataTableRow: import("svelte").Component<Props, {}, "">;
|
|
26
|
+
type DataTableRow = ReturnType<typeof DataTableRow>;
|
|
27
|
+
export default DataTableRow;
|
package/dist/cells/Actions.d.ts
CHANGED
package/dist/cells/Actions.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ArrowDownSolid, ArrowUpSolid, BellActiveOutline, BookmarkOutline, CogOutline, EditOutline, HeartSolid, InfoCircleOutline, ShareNodesOutline, TrashBinOutline, } from 'flowbite-svelte-icons';
|
|
2
1
|
/**
|
|
3
2
|
* @constant bookmarkAction
|
|
4
3
|
* @type {Action}
|
|
@@ -6,7 +5,7 @@ import { ArrowDownSolid, ArrowUpSolid, BellActiveOutline, BookmarkOutline, CogOu
|
|
|
6
5
|
* @property {ConstructorOfATypedSvelteComponent} icon - BookmarkOutline
|
|
7
6
|
*/
|
|
8
7
|
export const bookmarkAction = {
|
|
9
|
-
icon:
|
|
8
|
+
icon: '🔖',
|
|
10
9
|
name: 'bookmark',
|
|
11
10
|
};
|
|
12
11
|
/**
|
|
@@ -16,7 +15,7 @@ export const bookmarkAction = {
|
|
|
16
15
|
* @property {ConstructorOfATypedSvelteComponent} icon - TrashBinOutline
|
|
17
16
|
*/
|
|
18
17
|
export const deleteAction = {
|
|
19
|
-
icon:
|
|
18
|
+
icon: '🗑',
|
|
20
19
|
name: 'delete',
|
|
21
20
|
};
|
|
22
21
|
/**
|
|
@@ -26,7 +25,7 @@ export const deleteAction = {
|
|
|
26
25
|
* @property {ConstructorOfATypedSvelteComponent} icon - ArrowDownSolid
|
|
27
26
|
*/
|
|
28
27
|
export const downAction = {
|
|
29
|
-
icon:
|
|
28
|
+
icon: '▼',
|
|
30
29
|
name: 'down',
|
|
31
30
|
};
|
|
32
31
|
/**
|
|
@@ -36,7 +35,7 @@ export const downAction = {
|
|
|
36
35
|
* @property {ConstructorOfATypedSvelteComponent} icon - EditOutline
|
|
37
36
|
*/
|
|
38
37
|
export const editAction = {
|
|
39
|
-
icon:
|
|
38
|
+
icon: '✎',
|
|
40
39
|
name: 'edit',
|
|
41
40
|
};
|
|
42
41
|
/**
|
|
@@ -46,7 +45,7 @@ export const editAction = {
|
|
|
46
45
|
* @property {ConstructorOfATypedSvelteComponent} icon - HeartSolid
|
|
47
46
|
*/
|
|
48
47
|
export const favoriteAction = {
|
|
49
|
-
icon:
|
|
48
|
+
icon: '♥',
|
|
50
49
|
name: 'favorite',
|
|
51
50
|
};
|
|
52
51
|
/**
|
|
@@ -56,7 +55,7 @@ export const favoriteAction = {
|
|
|
56
55
|
* @property {ConstructorOfATypedSvelteComponent} icon - InfoCircleOutline
|
|
57
56
|
*/
|
|
58
57
|
export const infoAction = {
|
|
59
|
-
icon:
|
|
58
|
+
icon: 'ℹ',
|
|
60
59
|
name: 'info',
|
|
61
60
|
};
|
|
62
61
|
/**
|
|
@@ -66,7 +65,7 @@ export const infoAction = {
|
|
|
66
65
|
* @property {ConstructorOfATypedSvelteComponent} icon - BellActiveOutline
|
|
67
66
|
*/
|
|
68
67
|
export const notificationAction = {
|
|
69
|
-
icon:
|
|
68
|
+
icon: '🔔',
|
|
70
69
|
name: 'notification',
|
|
71
70
|
};
|
|
72
71
|
/**
|
|
@@ -76,7 +75,7 @@ export const notificationAction = {
|
|
|
76
75
|
* @property {ConstructorOfATypedSvelteComponent} icon - CogOutline
|
|
77
76
|
*/
|
|
78
77
|
export const settingsAction = {
|
|
79
|
-
icon:
|
|
78
|
+
icon: '⚙',
|
|
80
79
|
name: 'settings',
|
|
81
80
|
};
|
|
82
81
|
/**
|
|
@@ -86,7 +85,7 @@ export const settingsAction = {
|
|
|
86
85
|
* @property {ConstructorOfATypedSvelteComponent} icon - ShareNodesOutline
|
|
87
86
|
*/
|
|
88
87
|
export const shareAction = {
|
|
89
|
-
icon:
|
|
88
|
+
icon: '<',
|
|
90
89
|
name: 'share',
|
|
91
90
|
};
|
|
92
91
|
/**
|
|
@@ -96,6 +95,6 @@ export const shareAction = {
|
|
|
96
95
|
* @property {ConstructorOfATypedSvelteComponent} icon - UpArrowSolid
|
|
97
96
|
*/
|
|
98
97
|
export const upAction = {
|
|
99
|
-
icon:
|
|
98
|
+
icon: '▲',
|
|
100
99
|
name: 'up',
|
|
101
100
|
};
|
|
@@ -1,43 +1,66 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
getDataTableContext,
|
|
4
|
+
joinInputClasses,
|
|
5
|
+
} from '../common';
|
|
6
|
+
import type {
|
|
7
|
+
Action,
|
|
8
|
+
ActionEvent,
|
|
9
|
+
ColumnConfig,
|
|
10
|
+
} from '../common';
|
|
11
|
+
import { activeTheme } from '../themes/active';
|
|
12
|
+
|
|
13
|
+
import DataTableIcon from '../DataTableIcon.svelte';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
actions?: Action[];
|
|
17
|
+
column: ColumnConfig;
|
|
18
|
+
item: any;
|
|
19
|
+
onaction?: (event: ActionEvent) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
actions = [],
|
|
24
|
+
column,
|
|
25
|
+
item,
|
|
26
|
+
onaction,
|
|
27
|
+
}: Props = $props();
|
|
4
28
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
const tableTheme = getDataTableContext()?.theme || {};
|
|
30
|
+
|
|
31
|
+
const actionClicked = (action: Action) => {
|
|
32
|
+
onaction?.({
|
|
33
|
+
action,
|
|
34
|
+
column,
|
|
35
|
+
item,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getClass = (element: string, action: Action) => joinInputClasses(
|
|
40
|
+
'action',
|
|
41
|
+
element, [
|
|
42
|
+
activeTheme,
|
|
43
|
+
tableTheme,
|
|
44
|
+
column.theme,
|
|
45
|
+
{
|
|
46
|
+
inputs: {
|
|
47
|
+
action: action?.theme,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
)
|
|
21
52
|
</script>
|
|
22
53
|
|
|
23
54
|
{#each actions as action}
|
|
24
|
-
<
|
|
25
|
-
class={action
|
|
26
|
-
color={action.buttonColor || buttonColor}
|
|
55
|
+
<button
|
|
56
|
+
class={getClass('button', action)}
|
|
27
57
|
disabled={action.isDisabled?.(item, column, action)}
|
|
28
|
-
|
|
58
|
+
onclick={() => actionClicked(action)}
|
|
59
|
+
title={action.tooltip}
|
|
29
60
|
>
|
|
30
61
|
{#if action.icon}
|
|
31
|
-
<
|
|
32
|
-
{/if}
|
|
33
|
-
{#if action.iconify}
|
|
34
|
-
<Icon
|
|
35
|
-
{...action.iconify}
|
|
36
|
-
/>
|
|
62
|
+
<DataTableIcon classes={getClass('icon', action)} icon={action.icon}/>
|
|
37
63
|
{/if}
|
|
38
64
|
{#if action.caption}{action.caption}{/if}
|
|
39
|
-
</
|
|
40
|
-
{#if action.tooltip}
|
|
41
|
-
<Tooltip class="z-10">{action.tooltip}</Tooltip>
|
|
42
|
-
{/if}
|
|
65
|
+
</button>
|
|
43
66
|
{/each}
|
|
@@ -1,48 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
height?: string | number;
|
|
8
|
-
hFlip?: boolean;
|
|
9
|
-
icon: string;
|
|
10
|
-
inline?: boolean;
|
|
11
|
-
rotate?: number;
|
|
12
|
-
vFlip?: boolean;
|
|
13
|
-
width?: string | number;
|
|
14
|
-
};
|
|
15
|
-
export type ActionDisablementFunction = (item: any, column: ColumnConfig, action: Action) => boolean;
|
|
16
|
-
export interface Action {
|
|
17
|
-
buttonClass?: string;
|
|
18
|
-
buttonColor?: ButtonColor;
|
|
19
|
-
caption?: string;
|
|
20
|
-
name: string;
|
|
21
|
-
icon?: ConstructorOfATypedSvelteComponent;
|
|
22
|
-
iconClass?: string;
|
|
23
|
-
iconify?: IconifyProps;
|
|
24
|
-
isDisabled?: ActionDisablementFunction;
|
|
25
|
-
tooltip?: string;
|
|
1
|
+
import type { Action, ActionEvent, ColumnConfig } from '../common';
|
|
2
|
+
interface Props {
|
|
3
|
+
actions?: Action[];
|
|
4
|
+
column: ColumnConfig;
|
|
5
|
+
item: any;
|
|
6
|
+
onaction?: (event: ActionEvent) => void;
|
|
26
7
|
}
|
|
27
|
-
declare const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
buttonColor?: ButtonColor;
|
|
31
|
-
iconClass?: string | undefined;
|
|
32
|
-
column: ColumnConfig;
|
|
33
|
-
item: any;
|
|
34
|
-
actions?: Action[] | undefined;
|
|
35
|
-
};
|
|
36
|
-
events: {
|
|
37
|
-
action: CustomEvent<any>;
|
|
38
|
-
} & {
|
|
39
|
-
[evt: string]: CustomEvent<any>;
|
|
40
|
-
};
|
|
41
|
-
slots: {};
|
|
42
|
-
};
|
|
43
|
-
export type ActionsCellProps = typeof __propDef.props;
|
|
44
|
-
export type ActionsCellEvents = typeof __propDef.events;
|
|
45
|
-
export type ActionsCellSlots = typeof __propDef.slots;
|
|
46
|
-
export default class ActionsCell extends SvelteComponent<ActionsCellProps, ActionsCellEvents, ActionsCellSlots> {
|
|
47
|
-
}
|
|
48
|
-
export {};
|
|
8
|
+
declare const ActionsCell: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type ActionsCell = ReturnType<typeof ActionsCell>;
|
|
10
|
+
export default ActionsCell;
|
|
@@ -1,18 +1,60 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
getDataTableContext,
|
|
4
|
+
joinInputClasses,
|
|
5
|
+
} from '../common';
|
|
6
|
+
import type {
|
|
7
|
+
ColumnConfig,
|
|
8
|
+
DataCellEvent,
|
|
9
|
+
IconProp,
|
|
10
|
+
} from '../common';
|
|
11
|
+
import { activeTheme } from '../themes/active';
|
|
12
|
+
|
|
13
|
+
import DataTableIcon from '../DataTableIcon.svelte';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
caption?: string;
|
|
17
|
+
column: ColumnConfig;
|
|
18
|
+
item: any;
|
|
19
|
+
icon?: IconProp;
|
|
20
|
+
iconPosition?: 'left' | 'right';
|
|
21
|
+
onbutton?: (event: DataCellEvent) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
caption = '',
|
|
26
|
+
column,
|
|
27
|
+
item,
|
|
28
|
+
icon,
|
|
29
|
+
iconPosition = 'right',
|
|
30
|
+
onbutton,
|
|
31
|
+
}: Props = $props();
|
|
32
|
+
|
|
33
|
+
const tableTheme = getDataTableContext()?.theme || {};
|
|
34
|
+
|
|
35
|
+
const getClass = (element: string) => joinInputClasses(
|
|
36
|
+
'button',
|
|
37
|
+
element, [
|
|
38
|
+
activeTheme,
|
|
39
|
+
tableTheme,
|
|
40
|
+
column.theme,
|
|
41
|
+
],
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const buttonClass = $derived(getClass('button'));
|
|
45
|
+
const iconClass = $derived(getClass('icon'));
|
|
46
|
+
|
|
8
47
|
</script>
|
|
9
48
|
|
|
10
|
-
<
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{#if
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
{/if}
|
|
18
|
-
|
|
49
|
+
<button
|
|
50
|
+
class={buttonClass}
|
|
51
|
+
onclick={() => onbutton?.({ column, item })}
|
|
52
|
+
>
|
|
53
|
+
{#if icon && iconPosition === 'left'}
|
|
54
|
+
<DataTableIcon classes={iconClass} {icon}/>
|
|
55
|
+
{/if}
|
|
56
|
+
{#if caption}{caption}{/if}
|
|
57
|
+
{#if icon && iconPosition === 'right'}
|
|
58
|
+
<DataTableIcon classes={iconClass} {icon}/>
|
|
59
|
+
{/if}
|
|
60
|
+
</button>
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
iconPosition?: "left" | "right" | undefined;
|
|
10
|
-
};
|
|
11
|
-
events: {
|
|
12
|
-
[evt: string]: CustomEvent<any>;
|
|
13
|
-
};
|
|
14
|
-
slots: {};
|
|
15
|
-
};
|
|
16
|
-
export type ButtonCellProps = typeof __propDef.props;
|
|
17
|
-
export type ButtonCellEvents = typeof __propDef.events;
|
|
18
|
-
export type ButtonCellSlots = typeof __propDef.slots;
|
|
19
|
-
export default class ButtonCell extends SvelteComponent<ButtonCellProps, ButtonCellEvents, ButtonCellSlots> {
|
|
1
|
+
import type { ColumnConfig, DataCellEvent, IconProp } from '../common';
|
|
2
|
+
interface Props {
|
|
3
|
+
caption?: string;
|
|
4
|
+
column: ColumnConfig;
|
|
5
|
+
item: any;
|
|
6
|
+
icon?: IconProp;
|
|
7
|
+
iconPosition?: 'left' | 'right';
|
|
8
|
+
onbutton?: (event: DataCellEvent) => void;
|
|
20
9
|
}
|
|
21
|
-
|
|
10
|
+
declare const ButtonCell: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type ButtonCell = ReturnType<typeof ButtonCell>;
|
|
12
|
+
export default ButtonCell;
|