@bexis2/bexis2-core-ui 0.2.10 → 0.2.12
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/README.md +263 -207
- package/dist/components/Table/Table.svelte +85 -85
- package/dist/components/Table/TableFilter.svelte +109 -109
- package/dist/components/Table/TablePagination.svelte +38 -38
- package/dist/components/file/FileUploader.svelte +34 -34
- package/dist/components/form/Checkbox.svelte.d.ts +1 -1
- package/dist/components/form/DropdownKvP.svelte +5 -11
- package/dist/components/form/InputContainer.svelte +20 -19
- package/dist/components/form/MultiSelect.svelte +163 -178
- package/dist/components/form/TextArea.svelte +13 -13
- package/dist/components/form/TextInput.svelte +0 -2
- package/dist/components/page/Alert.svelte +28 -30
- package/dist/components/page/BackToTop.svelte +30 -30
- package/dist/components/page/Docs.svelte +22 -19
- package/dist/components/page/Docs.svelte.d.ts +1 -1
- package/dist/components/page/ErrorMessage.svelte +9 -0
- package/dist/components/page/ErrorMessage.svelte.d.ts +16 -0
- package/dist/components/page/Footer.svelte +5 -5
- package/dist/components/page/Header.svelte +5 -4
- package/dist/components/page/HelpPopUp.svelte +31 -25
- package/dist/components/page/HelpPopUp.svelte.d.ts +5 -12
- package/dist/components/page/Page.svelte +56 -66
- package/dist/components/page/Page.svelte.d.ts +2 -2
- package/dist/components/page/PageCaller.js +19 -21
- package/dist/components/page/Spinner.svelte +12 -13
- package/dist/components/page/Spinner.svelte.d.ts +1 -1
- package/dist/components/page/breadcrumb/Breadcrumb.svelte +19 -23
- package/dist/components/page/menu/Menu.svelte +25 -25
- package/dist/components/page/menu/MenuBar.svelte +7 -14
- package/dist/components/page/menu/MenuBar.svelte.d.ts +2 -2
- package/dist/components/page/menu/MenuDataCaller.js +10 -11
- package/dist/components/page/menu/MenuItem.svelte +9 -13
- package/dist/components/page/menu/MenuItem.svelte.d.ts +2 -1
- package/dist/components/page/menu/MenuSublist.svelte +18 -17
- package/dist/components/page/menu/MenuSublist.svelte.d.ts +2 -2
- package/dist/components/page/menu/SettingsBar.svelte +9 -14
- package/dist/components/page/menu/SettingsBar.svelte.d.ts +2 -2
- package/dist/css/core.ui.postcss +10 -7
- package/dist/css/themes/theme-bexis2.css +12 -13
- package/dist/index.d.ts +2 -3
- package/dist/index.js +5 -4
- package/dist/models/Models.js +0 -1
- package/dist/models/Page.d.ts +31 -0
- package/dist/services/BaseCaller.js +16 -21
- package/dist/stores/pageStores.d.ts +4 -4
- package/dist/stores/pageStores.js +27 -27
- package/package.json +2 -2
- package/src/lib/components/Table/Table.svelte +246 -246
- package/src/lib/components/Table/TableFilter.svelte +222 -222
- package/src/lib/components/Table/TablePagination.svelte +61 -61
- package/src/lib/components/Table/filter.ts +141 -141
- package/src/lib/components/file/FileUploader.svelte +184 -184
- package/src/lib/components/form/Checkbox.svelte +1 -1
- package/src/lib/components/form/DateInput.svelte +0 -1
- package/src/lib/components/form/DropdownKvP.svelte +5 -11
- package/src/lib/components/form/InputContainer.svelte +36 -44
- package/src/lib/components/form/MultiSelect.svelte +163 -178
- package/src/lib/components/form/NumberInput.svelte +3 -5
- package/src/lib/components/form/TextArea.svelte +26 -27
- package/src/lib/components/form/TextInput.svelte +2 -5
- package/src/lib/components/page/Alert.svelte +41 -45
- package/src/lib/components/page/BackToTop.svelte +30 -30
- package/src/lib/components/page/Docs.svelte +46 -44
- package/src/lib/components/page/ErrorMessage.svelte +10 -0
- package/src/lib/components/page/Footer.svelte +18 -22
- package/src/lib/components/page/Header.svelte +18 -21
- package/src/lib/components/page/HelpPopUp.svelte +72 -66
- package/src/lib/components/page/Page.svelte +96 -108
- package/src/lib/components/page/PageCaller.js +19 -21
- package/src/lib/components/page/Spinner.svelte +14 -16
- package/src/lib/components/page/breadcrumb/Breadcrumb.svelte +31 -43
- package/src/lib/components/page/menu/Menu.svelte +40 -47
- package/src/lib/components/page/menu/MenuBar.svelte +20 -31
- package/src/lib/components/page/menu/MenuDataCaller.js +10 -11
- package/src/lib/components/page/menu/MenuItem.svelte +27 -33
- package/src/lib/components/page/menu/MenuSublist.svelte +43 -48
- package/src/lib/components/page/menu/SettingsBar.svelte +31 -40
- package/src/lib/css/core.ui.postcss +10 -7
- package/src/lib/css/themes/theme-bexis2.css +12 -13
- package/src/lib/index.ts +75 -76
- package/src/lib/models/Enums.ts +10 -11
- package/src/lib/models/Models.ts +113 -113
- package/src/lib/models/Page.ts +40 -41
- package/src/lib/services/BaseCaller.js +16 -21
- package/src/lib/stores/apiStores.ts +31 -32
- package/src/lib/stores/pageStores.ts +121 -126
|
@@ -1,246 +1,246 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher } from 'svelte';
|
|
3
|
-
import { createTable, Subscribe, Render, createRender } from 'svelte-headless-table';
|
|
4
|
-
import {
|
|
5
|
-
addSortBy,
|
|
6
|
-
addPagination,
|
|
7
|
-
addExpandedRows,
|
|
8
|
-
addColumnFilters,
|
|
9
|
-
addTableFilter
|
|
10
|
-
} from 'svelte-headless-table/plugins';
|
|
11
|
-
import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom';
|
|
12
|
-
import { storePopup } from '@skeletonlabs/skeleton';
|
|
13
|
-
|
|
14
|
-
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
|
|
15
|
-
|
|
16
|
-
import TableFilter from './TableFilter.svelte';
|
|
17
|
-
import TablePagination from './TablePagination.svelte';
|
|
18
|
-
import { columnFilter, searchFilter } from './filter';
|
|
19
|
-
import type { TableConfig } from '$lib/models/Models';
|
|
20
|
-
|
|
21
|
-
export let config: TableConfig<any>;
|
|
22
|
-
let {
|
|
23
|
-
id: tableId,
|
|
24
|
-
data,
|
|
25
|
-
columns,
|
|
26
|
-
optionsComponent,
|
|
27
|
-
defaultPageSize = 10,
|
|
28
|
-
pageSizes = [5, 10, 15, 20]
|
|
29
|
-
} = config;
|
|
30
|
-
|
|
31
|
-
type AccessorType = keyof (typeof $data)[number];
|
|
32
|
-
|
|
33
|
-
const dispatch = createEventDispatcher();
|
|
34
|
-
const actionDispatcher = (obj) => dispatch('action', obj);
|
|
35
|
-
|
|
36
|
-
const table = createTable(data, {
|
|
37
|
-
colFilter: addColumnFilters(),
|
|
38
|
-
tableFilter: addTableFilter({
|
|
39
|
-
fn: searchFilter
|
|
40
|
-
}),
|
|
41
|
-
sort: addSortBy({ disableMultiSort: true }),
|
|
42
|
-
page: addPagination({ initialPageSize: defaultPageSize }),
|
|
43
|
-
expand: addExpandedRows()
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const accessors: AccessorType[] =
|
|
47
|
-
$data.length > 0 ? (Object.keys($data[0]) as AccessorType[]) : [];
|
|
48
|
-
|
|
49
|
-
const tableColumns = [
|
|
50
|
-
...accessors
|
|
51
|
-
.filter((accessor) => {
|
|
52
|
-
const key = accessor as string;
|
|
53
|
-
if (columns !== undefined && key in columns && columns[key].exclude === true) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
return true;
|
|
57
|
-
})
|
|
58
|
-
.map((accessor) => {
|
|
59
|
-
const key = accessor as string;
|
|
60
|
-
if (columns !== undefined && key in columns) {
|
|
61
|
-
const {
|
|
62
|
-
header,
|
|
63
|
-
colFilterFn,
|
|
64
|
-
colFilterComponent,
|
|
65
|
-
instructions,
|
|
66
|
-
disableFiltering = false,
|
|
67
|
-
disableSorting = false
|
|
68
|
-
} = columns[key];
|
|
69
|
-
|
|
70
|
-
const { toSortableValueFn, toFilterableValueFn, toStringFn, renderComponent } =
|
|
71
|
-
instructions ?? {};
|
|
72
|
-
|
|
73
|
-
return table.column({
|
|
74
|
-
header: header ?? key,
|
|
75
|
-
accessor: accessor,
|
|
76
|
-
cell: ({ value, row }) => {
|
|
77
|
-
return renderComponent
|
|
78
|
-
? createRender(renderComponent, { value, row })
|
|
79
|
-
: toStringFn
|
|
80
|
-
? toStringFn(value)
|
|
81
|
-
: value;
|
|
82
|
-
},
|
|
83
|
-
plugins: {
|
|
84
|
-
sort: {
|
|
85
|
-
disable: disableSorting,
|
|
86
|
-
invert: true,
|
|
87
|
-
getSortValue: (row) => {
|
|
88
|
-
return toSortableValueFn ? toSortableValueFn(row) : row;
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
colFilter: !disableFiltering
|
|
92
|
-
? {
|
|
93
|
-
fn: ({ filterValue, value }) => {
|
|
94
|
-
const val = toFilterableValueFn ? toFilterableValueFn(value) : value;
|
|
95
|
-
|
|
96
|
-
return colFilterFn
|
|
97
|
-
? colFilterFn({ filterValue, value: val })
|
|
98
|
-
: columnFilter({ filterValue, value: val });
|
|
99
|
-
},
|
|
100
|
-
render: ({ filterValue, values, id }) => {
|
|
101
|
-
return createRender(colFilterComponent ?? TableFilter, {
|
|
102
|
-
filterValue,
|
|
103
|
-
id,
|
|
104
|
-
tableId,
|
|
105
|
-
values,
|
|
106
|
-
toFilterableValueFn
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
: undefined,
|
|
111
|
-
tableFilter: {
|
|
112
|
-
getFilterValue: (row) => {
|
|
113
|
-
return toStringFn ? toStringFn(row) : row;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
} else {
|
|
119
|
-
return table.column({
|
|
120
|
-
header: key,
|
|
121
|
-
accessor: accessor,
|
|
122
|
-
plugins: {
|
|
123
|
-
sort: {
|
|
124
|
-
invert: true
|
|
125
|
-
},
|
|
126
|
-
colFilter: {
|
|
127
|
-
fn: columnFilter,
|
|
128
|
-
render: ({ filterValue, values, id }) =>
|
|
129
|
-
createRender(TableFilter, {
|
|
130
|
-
filterValue,
|
|
131
|
-
id,
|
|
132
|
-
tableId,
|
|
133
|
-
values
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
];
|
|
141
|
-
|
|
142
|
-
if (optionsComponent !== undefined) {
|
|
143
|
-
tableColumns.push(
|
|
144
|
-
table.display({
|
|
145
|
-
id: 'options',
|
|
146
|
-
header: '',
|
|
147
|
-
cell: ({ row }, _) => {
|
|
148
|
-
return createRender(optionsComponent!, {
|
|
149
|
-
row: row.isData() ? row.original : null,
|
|
150
|
-
dispatchFn: actionDispatcher
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}) as any
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const createdTableColumns = table.createColumns(tableColumns);
|
|
158
|
-
|
|
159
|
-
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } =
|
|
160
|
-
table.createViewModel(createdTableColumns);
|
|
161
|
-
const { filterValue } = pluginStates.tableFilter;
|
|
162
|
-
</script>
|
|
163
|
-
|
|
164
|
-
<div class="grid gap-2">
|
|
165
|
-
<div class="table-container">
|
|
166
|
-
{#if $data.length > 0}
|
|
167
|
-
<input
|
|
168
|
-
class="input p-2 mb-2 border border-primary-500"
|
|
169
|
-
type="text"
|
|
170
|
-
bind:value={$filterValue}
|
|
171
|
-
placeholder="Search rows..."
|
|
172
|
-
/>
|
|
173
|
-
{/if}
|
|
174
|
-
<table {...$tableAttrs} class="table table-compact bg-tertiary-200">
|
|
175
|
-
<thead>
|
|
176
|
-
{#each $headerRows as headerRow (headerRow.id)}
|
|
177
|
-
<Subscribe
|
|
178
|
-
rowAttrs={headerRow.attrs()}
|
|
179
|
-
let:rowAttrs
|
|
180
|
-
rowProps={headerRow.props()}
|
|
181
|
-
let:rowProps
|
|
182
|
-
>
|
|
183
|
-
<tr {...rowAttrs} class="bg-primary-300">
|
|
184
|
-
{#each headerRow.cells as cell (cell.id)}
|
|
185
|
-
<Subscribe attrs={cell.attrs()} props={cell.props()} let:props let:attrs>
|
|
186
|
-
<th scope="col" class="!p-2 w-min" {...attrs}>
|
|
187
|
-
<div class="flex w-full justify-between items-center">
|
|
188
|
-
<div class="flex gap-1">
|
|
189
|
-
<span
|
|
190
|
-
class:underline={props.sort.order}
|
|
191
|
-
class:normal-case={cell.id !== cell.label}
|
|
192
|
-
class:cursor-pointer={!props.sort.disabled}
|
|
193
|
-
on:click={props.sort.toggle}
|
|
194
|
-
on:keydown={props.sort.toggle}
|
|
195
|
-
>
|
|
196
|
-
{cell.render()}
|
|
197
|
-
</span>
|
|
198
|
-
<div class="w-2">
|
|
199
|
-
{#if props.sort.order === 'asc'}
|
|
200
|
-
▾
|
|
201
|
-
{:else if props.sort.order === 'desc'}
|
|
202
|
-
▴
|
|
203
|
-
{/if}
|
|
204
|
-
</div>
|
|
205
|
-
</div>
|
|
206
|
-
{#if cell.isData()}
|
|
207
|
-
{#if props.colFilter?.render}
|
|
208
|
-
<div>
|
|
209
|
-
<Render of={props.colFilter.render} />
|
|
210
|
-
</div>
|
|
211
|
-
{/if}
|
|
212
|
-
{/if}
|
|
213
|
-
</div>
|
|
214
|
-
</th>
|
|
215
|
-
</Subscribe>
|
|
216
|
-
{/each}
|
|
217
|
-
</tr>
|
|
218
|
-
</Subscribe>
|
|
219
|
-
{:else}
|
|
220
|
-
<p class="items-center justify-center flex w-full p-10 italic">Nothing to show here.</p>
|
|
221
|
-
{/each}
|
|
222
|
-
</thead>
|
|
223
|
-
|
|
224
|
-
<tbody class="" {...$tableBodyAttrs}>
|
|
225
|
-
{#each $pageRows as row (row.id)}
|
|
226
|
-
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
|
227
|
-
<tr {...rowAttrs}>
|
|
228
|
-
{#each row.cells as cell (cell?.id)}
|
|
229
|
-
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
230
|
-
<td {...attrs} class="!p-2 w-min">
|
|
231
|
-
<div class="flex items-center w-full h-full table-cell-fit">
|
|
232
|
-
<Render of={cell.render()} />
|
|
233
|
-
</div>
|
|
234
|
-
</td>
|
|
235
|
-
</Subscribe>
|
|
236
|
-
{/each}
|
|
237
|
-
</tr>
|
|
238
|
-
</Subscribe>
|
|
239
|
-
{/each}
|
|
240
|
-
</tbody>
|
|
241
|
-
</table>
|
|
242
|
-
</div>
|
|
243
|
-
{#if $data.length > 0}
|
|
244
|
-
<TablePagination pageConfig={pluginStates.page} {pageSizes} />
|
|
245
|
-
{/if}
|
|
246
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from 'svelte';
|
|
3
|
+
import { createTable, Subscribe, Render, createRender } from 'svelte-headless-table';
|
|
4
|
+
import {
|
|
5
|
+
addSortBy,
|
|
6
|
+
addPagination,
|
|
7
|
+
addExpandedRows,
|
|
8
|
+
addColumnFilters,
|
|
9
|
+
addTableFilter
|
|
10
|
+
} from 'svelte-headless-table/plugins';
|
|
11
|
+
import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom';
|
|
12
|
+
import { storePopup } from '@skeletonlabs/skeleton';
|
|
13
|
+
|
|
14
|
+
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
|
|
15
|
+
|
|
16
|
+
import TableFilter from './TableFilter.svelte';
|
|
17
|
+
import TablePagination from './TablePagination.svelte';
|
|
18
|
+
import { columnFilter, searchFilter } from './filter';
|
|
19
|
+
import type { TableConfig } from '$lib/models/Models';
|
|
20
|
+
|
|
21
|
+
export let config: TableConfig<any>;
|
|
22
|
+
let {
|
|
23
|
+
id: tableId,
|
|
24
|
+
data,
|
|
25
|
+
columns,
|
|
26
|
+
optionsComponent,
|
|
27
|
+
defaultPageSize = 10,
|
|
28
|
+
pageSizes = [5, 10, 15, 20]
|
|
29
|
+
} = config;
|
|
30
|
+
|
|
31
|
+
type AccessorType = keyof (typeof $data)[number];
|
|
32
|
+
|
|
33
|
+
const dispatch = createEventDispatcher();
|
|
34
|
+
const actionDispatcher = (obj) => dispatch('action', obj);
|
|
35
|
+
|
|
36
|
+
const table = createTable(data, {
|
|
37
|
+
colFilter: addColumnFilters(),
|
|
38
|
+
tableFilter: addTableFilter({
|
|
39
|
+
fn: searchFilter
|
|
40
|
+
}),
|
|
41
|
+
sort: addSortBy({ disableMultiSort: true }),
|
|
42
|
+
page: addPagination({ initialPageSize: defaultPageSize }),
|
|
43
|
+
expand: addExpandedRows()
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const accessors: AccessorType[] =
|
|
47
|
+
$data.length > 0 ? (Object.keys($data[0]) as AccessorType[]) : [];
|
|
48
|
+
|
|
49
|
+
const tableColumns = [
|
|
50
|
+
...accessors
|
|
51
|
+
.filter((accessor) => {
|
|
52
|
+
const key = accessor as string;
|
|
53
|
+
if (columns !== undefined && key in columns && columns[key].exclude === true) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
})
|
|
58
|
+
.map((accessor) => {
|
|
59
|
+
const key = accessor as string;
|
|
60
|
+
if (columns !== undefined && key in columns) {
|
|
61
|
+
const {
|
|
62
|
+
header,
|
|
63
|
+
colFilterFn,
|
|
64
|
+
colFilterComponent,
|
|
65
|
+
instructions,
|
|
66
|
+
disableFiltering = false,
|
|
67
|
+
disableSorting = false
|
|
68
|
+
} = columns[key];
|
|
69
|
+
|
|
70
|
+
const { toSortableValueFn, toFilterableValueFn, toStringFn, renderComponent } =
|
|
71
|
+
instructions ?? {};
|
|
72
|
+
|
|
73
|
+
return table.column({
|
|
74
|
+
header: header ?? key,
|
|
75
|
+
accessor: accessor,
|
|
76
|
+
cell: ({ value, row }) => {
|
|
77
|
+
return renderComponent
|
|
78
|
+
? createRender(renderComponent, { value, row })
|
|
79
|
+
: toStringFn
|
|
80
|
+
? toStringFn(value)
|
|
81
|
+
: value;
|
|
82
|
+
},
|
|
83
|
+
plugins: {
|
|
84
|
+
sort: {
|
|
85
|
+
disable: disableSorting,
|
|
86
|
+
invert: true,
|
|
87
|
+
getSortValue: (row) => {
|
|
88
|
+
return toSortableValueFn ? toSortableValueFn(row) : row;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
colFilter: !disableFiltering
|
|
92
|
+
? {
|
|
93
|
+
fn: ({ filterValue, value }) => {
|
|
94
|
+
const val = toFilterableValueFn ? toFilterableValueFn(value) : value;
|
|
95
|
+
|
|
96
|
+
return colFilterFn
|
|
97
|
+
? colFilterFn({ filterValue, value: val })
|
|
98
|
+
: columnFilter({ filterValue, value: val });
|
|
99
|
+
},
|
|
100
|
+
render: ({ filterValue, values, id }) => {
|
|
101
|
+
return createRender(colFilterComponent ?? TableFilter, {
|
|
102
|
+
filterValue,
|
|
103
|
+
id,
|
|
104
|
+
tableId,
|
|
105
|
+
values,
|
|
106
|
+
toFilterableValueFn
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
: undefined,
|
|
111
|
+
tableFilter: {
|
|
112
|
+
getFilterValue: (row) => {
|
|
113
|
+
return toStringFn ? toStringFn(row) : row;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
return table.column({
|
|
120
|
+
header: key,
|
|
121
|
+
accessor: accessor,
|
|
122
|
+
plugins: {
|
|
123
|
+
sort: {
|
|
124
|
+
invert: true
|
|
125
|
+
},
|
|
126
|
+
colFilter: {
|
|
127
|
+
fn: columnFilter,
|
|
128
|
+
render: ({ filterValue, values, id }) =>
|
|
129
|
+
createRender(TableFilter, {
|
|
130
|
+
filterValue,
|
|
131
|
+
id,
|
|
132
|
+
tableId,
|
|
133
|
+
values
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
if (optionsComponent !== undefined) {
|
|
143
|
+
tableColumns.push(
|
|
144
|
+
table.display({
|
|
145
|
+
id: 'options',
|
|
146
|
+
header: '',
|
|
147
|
+
cell: ({ row }, _) => {
|
|
148
|
+
return createRender(optionsComponent!, {
|
|
149
|
+
row: row.isData() ? row.original : null,
|
|
150
|
+
dispatchFn: actionDispatcher
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}) as any
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const createdTableColumns = table.createColumns(tableColumns);
|
|
158
|
+
|
|
159
|
+
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } =
|
|
160
|
+
table.createViewModel(createdTableColumns);
|
|
161
|
+
const { filterValue } = pluginStates.tableFilter;
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<div class="grid gap-2">
|
|
165
|
+
<div class="table-container">
|
|
166
|
+
{#if $data.length > 0}
|
|
167
|
+
<input
|
|
168
|
+
class="input p-2 mb-2 border border-primary-500"
|
|
169
|
+
type="text"
|
|
170
|
+
bind:value={$filterValue}
|
|
171
|
+
placeholder="Search rows..."
|
|
172
|
+
/>
|
|
173
|
+
{/if}
|
|
174
|
+
<table {...$tableAttrs} class="table table-compact bg-tertiary-200">
|
|
175
|
+
<thead>
|
|
176
|
+
{#each $headerRows as headerRow (headerRow.id)}
|
|
177
|
+
<Subscribe
|
|
178
|
+
rowAttrs={headerRow.attrs()}
|
|
179
|
+
let:rowAttrs
|
|
180
|
+
rowProps={headerRow.props()}
|
|
181
|
+
let:rowProps
|
|
182
|
+
>
|
|
183
|
+
<tr {...rowAttrs} class="bg-primary-300">
|
|
184
|
+
{#each headerRow.cells as cell (cell.id)}
|
|
185
|
+
<Subscribe attrs={cell.attrs()} props={cell.props()} let:props let:attrs>
|
|
186
|
+
<th scope="col" class="!p-2 w-min" {...attrs}>
|
|
187
|
+
<div class="flex w-full justify-between items-center">
|
|
188
|
+
<div class="flex gap-1">
|
|
189
|
+
<span
|
|
190
|
+
class:underline={props.sort.order}
|
|
191
|
+
class:normal-case={cell.id !== cell.label}
|
|
192
|
+
class:cursor-pointer={!props.sort.disabled}
|
|
193
|
+
on:click={props.sort.toggle}
|
|
194
|
+
on:keydown={props.sort.toggle}
|
|
195
|
+
>
|
|
196
|
+
{cell.render()}
|
|
197
|
+
</span>
|
|
198
|
+
<div class="w-2">
|
|
199
|
+
{#if props.sort.order === 'asc'}
|
|
200
|
+
▾
|
|
201
|
+
{:else if props.sort.order === 'desc'}
|
|
202
|
+
▴
|
|
203
|
+
{/if}
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
{#if cell.isData()}
|
|
207
|
+
{#if props.colFilter?.render}
|
|
208
|
+
<div>
|
|
209
|
+
<Render of={props.colFilter.render} />
|
|
210
|
+
</div>
|
|
211
|
+
{/if}
|
|
212
|
+
{/if}
|
|
213
|
+
</div>
|
|
214
|
+
</th>
|
|
215
|
+
</Subscribe>
|
|
216
|
+
{/each}
|
|
217
|
+
</tr>
|
|
218
|
+
</Subscribe>
|
|
219
|
+
{:else}
|
|
220
|
+
<p class="items-center justify-center flex w-full p-10 italic">Nothing to show here.</p>
|
|
221
|
+
{/each}
|
|
222
|
+
</thead>
|
|
223
|
+
|
|
224
|
+
<tbody class="" {...$tableBodyAttrs}>
|
|
225
|
+
{#each $pageRows as row (row.id)}
|
|
226
|
+
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
|
227
|
+
<tr {...rowAttrs}>
|
|
228
|
+
{#each row.cells as cell (cell?.id)}
|
|
229
|
+
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
230
|
+
<td {...attrs} class="!p-2 w-min">
|
|
231
|
+
<div class="flex items-center w-full h-full table-cell-fit">
|
|
232
|
+
<Render of={cell.render()} />
|
|
233
|
+
</div>
|
|
234
|
+
</td>
|
|
235
|
+
</Subscribe>
|
|
236
|
+
{/each}
|
|
237
|
+
</tr>
|
|
238
|
+
</Subscribe>
|
|
239
|
+
{/each}
|
|
240
|
+
</tbody>
|
|
241
|
+
</table>
|
|
242
|
+
</div>
|
|
243
|
+
{#if $data.length > 0}
|
|
244
|
+
<TablePagination pageConfig={pluginStates.page} {pageSizes} />
|
|
245
|
+
{/if}
|
|
246
|
+
</div>
|