@bexis2/bexis2-core-ui 0.0.30 → 0.1.0
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 +41 -0
- package/dist/components/Table/Table.svelte +132 -94
- package/dist/components/Table/Table.svelte.d.ts +2 -0
- package/dist/components/Table/TableFilter.svelte +50 -5
- package/dist/components/Table/TablePagination.svelte +1 -1
- package/dist/components/Table/filter.js +43 -3
- package/dist/components/form/DropdownKvP.svelte +17 -2
- package/dist/components/form/DropdownKvP.svelte.d.ts +2 -0
- package/dist/components/form/NumberInput.svelte +2 -0
- package/dist/components/form/NumberInput.svelte.d.ts +1 -0
- package/dist/components/form/TextArea.svelte +2 -0
- package/dist/components/form/TextArea.svelte.d.ts +1 -0
- package/dist/components/form/TextInput.svelte +2 -0
- package/dist/components/form/TextInput.svelte.d.ts +1 -0
- package/dist/components/page/Alert.svelte +39 -0
- package/dist/components/page/Alert.svelte.d.ts +22 -0
- package/dist/components/spinner/Spinner.svelte +11 -1
- package/dist/components/spinner/Spinner.svelte.d.ts +9 -13
- package/dist/css/themes/theme-bexis2.css +3 -3
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -1
- package/dist/models/Enums.d.ts +5 -0
- package/dist/models/Enums.js +6 -0
- package/dist/models/Models.d.ts +18 -0
- package/package.json +1 -1
- package/src/lib/components/Table/Table.svelte +230 -184
- package/src/lib/components/Table/TableFilter.svelte +50 -5
- package/src/lib/components/Table/TablePagination.svelte +1 -1
- package/src/lib/components/Table/filter.ts +141 -94
- package/src/lib/components/form/DropdownKvP.svelte +17 -2
- package/src/lib/components/form/NumberInput.svelte +2 -0
- package/src/lib/components/form/TextArea.svelte +2 -0
- package/src/lib/components/form/TextInput.svelte +3 -0
- package/src/lib/components/page/Alert.svelte +46 -0
- package/src/lib/components/spinner/Spinner.svelte +14 -1
- package/src/lib/css/themes/theme-bexis2.css +3 -3
- package/src/lib/index.ts +9 -3
- package/src/lib/models/Enums.ts +6 -0
- package/src/lib/models/Models.ts +102 -78
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
title?: string | undefined;
|
|
5
|
+
message?: string | undefined;
|
|
6
|
+
cssClass?: string | undefined;
|
|
7
|
+
deleteBtn?: boolean | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
default: {};
|
|
14
|
+
actions: {};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type AlertProps = typeof __propDef.props;
|
|
18
|
+
export type AlertEvents = typeof __propDef.events;
|
|
19
|
+
export type AlertSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Alert extends SvelteComponentTyped<AlertProps, AlertEvents, AlertSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
<script>import { Position } from "../../models/Enums";
|
|
2
|
+
export let textCss = "text-secundary-500";
|
|
3
|
+
export let label = "";
|
|
4
|
+
export let position = Position.start;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="flex justify-{position} items-{position} h-full w-full gap-5 pt-2">
|
|
1
8
|
<div
|
|
2
|
-
class="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]
|
|
9
|
+
class="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite] {textCss}"
|
|
3
10
|
role="status"
|
|
4
11
|
>
|
|
5
12
|
<span
|
|
@@ -7,3 +14,6 @@
|
|
|
7
14
|
>Loading...</span
|
|
8
15
|
>
|
|
9
16
|
</div>
|
|
17
|
+
<span>{label}</span>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} SpinnerProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} SpinnerEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} SpinnerSlots */
|
|
4
|
-
export default class Spinner extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: never;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type SpinnerProps = typeof __propDef.props;
|
|
11
|
-
export type SpinnerEvents = typeof __propDef.events;
|
|
12
|
-
export type SpinnerSlots = typeof __propDef.slots;
|
|
13
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { Position } from "../../models/Enums";
|
|
14
3
|
declare const __propDef: {
|
|
15
4
|
props: {
|
|
16
|
-
|
|
5
|
+
textCss?: string | undefined;
|
|
6
|
+
label?: string | undefined;
|
|
7
|
+
position?: Position | undefined;
|
|
17
8
|
};
|
|
18
9
|
events: {
|
|
19
10
|
[evt: string]: CustomEvent<any>;
|
|
20
11
|
};
|
|
21
12
|
slots: {};
|
|
22
13
|
};
|
|
14
|
+
export type SpinnerProps = typeof __propDef.props;
|
|
15
|
+
export type SpinnerEvents = typeof __propDef.events;
|
|
16
|
+
export type SpinnerSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Spinner extends SvelteComponentTyped<SpinnerProps, SpinnerEvents, SpinnerSlots> {
|
|
18
|
+
}
|
|
23
19
|
export {};
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
--theme-rounded-container: 4px;
|
|
9
9
|
--theme-border-base: 1px;
|
|
10
10
|
/* =~= Theme On-X Colors =~= */
|
|
11
|
-
--on-primary:
|
|
12
|
-
--on-secondary:
|
|
11
|
+
--on-primary: 255 255 255;
|
|
12
|
+
--on-secondary: 255 255 255;
|
|
13
13
|
--on-tertiary: 0 0 0;
|
|
14
|
-
--on-success:
|
|
14
|
+
--on-success: 255 255 255;
|
|
15
15
|
--on-warning: 255 255 255;
|
|
16
16
|
--on-error: 255 255 255;
|
|
17
17
|
--on-surface: 0 0 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import FileInfo from './components/file/FileInfo.svelte';
|
|
|
5
5
|
import FileUploader from './components/file/FileUploader.svelte';
|
|
6
6
|
import Spinner from './components/spinner/Spinner.svelte';
|
|
7
7
|
import Page from './components/page/Page.svelte';
|
|
8
|
+
import Alert from './components/page/Alert.svelte';
|
|
8
9
|
import Checkbox from './components/form/Checkbox.svelte';
|
|
9
10
|
import CheckboxKVPList from './components/form/CheckboxKvPList.svelte';
|
|
10
11
|
import CheckboxList from './components/form/CheckboxList.svelte';
|
|
@@ -20,9 +21,10 @@ import { columnFilter, searchFilter } from './components/Table/filter';
|
|
|
20
21
|
import type { TableConfig, Columns, Column } from './models/Models';
|
|
21
22
|
export { Checkbox, CheckboxKVPList, CheckboxList, DateInput, DropdownKVP, MultiSelect, NumberInput, TextArea, TextInput };
|
|
22
23
|
export { FileInfo, FileIcon, FileUploader };
|
|
23
|
-
export { ListView, TableView, Spinner, Page };
|
|
24
|
+
export { ListView, TableView, Spinner, Page, Alert };
|
|
24
25
|
export { Api } from './services/Api.js';
|
|
25
26
|
export { host, username, password, setApiConfig } from './stores/apistore.js';
|
|
26
|
-
export type { user, Input, FileUploaderModel, Link } from './models/Models.js';
|
|
27
|
+
export type { user, Input, FileUploaderModel, Link, ListItem, KvP } from './models/Models.js';
|
|
28
|
+
export { Position } from './models/Enums';
|
|
27
29
|
export { Table, TableFilter, columnFilter, searchFilter };
|
|
28
30
|
export type { TableConfig, Columns, Column };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import FileUploader from './components/file/FileUploader.svelte';
|
|
|
7
7
|
//page
|
|
8
8
|
import Spinner from './components/spinner/Spinner.svelte';
|
|
9
9
|
import Page from './components/page/Page.svelte';
|
|
10
|
+
import Alert from './components/page/Alert.svelte';
|
|
10
11
|
// input
|
|
11
12
|
import Checkbox from './components/form/Checkbox.svelte';
|
|
12
13
|
import CheckboxKVPList from './components/form/CheckboxKvPList.svelte';
|
|
@@ -25,9 +26,11 @@ export { Checkbox, CheckboxKVPList, CheckboxList, DateInput, DropdownKVP, MultiS
|
|
|
25
26
|
//File
|
|
26
27
|
export { FileInfo, FileIcon, FileUploader };
|
|
27
28
|
//others
|
|
28
|
-
export { ListView, TableView, Spinner, Page };
|
|
29
|
+
export { ListView, TableView, Spinner, Page, Alert };
|
|
29
30
|
//Api
|
|
30
31
|
export { Api } from './services/Api.js';
|
|
31
32
|
export { host, username, password, setApiConfig } from './stores/apistore.js';
|
|
33
|
+
//enum
|
|
34
|
+
export { Position } from './models/Enums';
|
|
32
35
|
// Table
|
|
33
36
|
export { Table, TableFilter, columnFilter, searchFilter };
|
package/dist/models/Models.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface Input {
|
|
|
12
12
|
invalid: boolean;
|
|
13
13
|
valid: boolean;
|
|
14
14
|
required: boolean;
|
|
15
|
+
placeholder: string;
|
|
15
16
|
}
|
|
16
17
|
export interface FileInfo {
|
|
17
18
|
name: string;
|
|
@@ -44,9 +45,17 @@ export interface FileObj {
|
|
|
44
45
|
type: string;
|
|
45
46
|
webkitRelativePath: string;
|
|
46
47
|
}
|
|
48
|
+
export interface ColumnInstructions {
|
|
49
|
+
toStringFn?: (value: any) => string;
|
|
50
|
+
toSortableValueFn?: (value: any) => string | number;
|
|
51
|
+
toFilterableValueFn?: (value: any) => string | number | Date;
|
|
52
|
+
}
|
|
47
53
|
export interface Column {
|
|
48
54
|
header?: string;
|
|
49
55
|
exclude?: boolean;
|
|
56
|
+
instructions?: ColumnInstructions;
|
|
57
|
+
disableFiltering?: boolean;
|
|
58
|
+
disableSorting?: boolean;
|
|
50
59
|
colFilterFn?: ColumnFilterFn;
|
|
51
60
|
colFilterComponent?: typeof SvelteComponent;
|
|
52
61
|
}
|
|
@@ -61,3 +70,12 @@ export interface TableConfig<T> {
|
|
|
61
70
|
defaultPageSize?: number;
|
|
62
71
|
optionsComponent?: typeof SvelteComponent;
|
|
63
72
|
}
|
|
73
|
+
export interface KvP {
|
|
74
|
+
id: number;
|
|
75
|
+
text: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ListItem {
|
|
78
|
+
id: number;
|
|
79
|
+
text: string;
|
|
80
|
+
group: string;
|
|
81
|
+
}
|
package/package.json
CHANGED
|
@@ -1,184 +1,230 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
plugins: {
|
|
75
|
-
sort: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
<
|
|
164
|
-
{#each $
|
|
165
|
-
<Subscribe
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
</
|
|
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
|
+
|
|
12
|
+
import TableFilter from './TableFilter.svelte';
|
|
13
|
+
import TablePagination from './TablePagination.svelte';
|
|
14
|
+
import { columnFilter, searchFilter } from './filter';
|
|
15
|
+
import type { TableConfig } from '$lib/models/Models';
|
|
16
|
+
|
|
17
|
+
export let config: TableConfig<any>;
|
|
18
|
+
let {
|
|
19
|
+
id: tableId,
|
|
20
|
+
data,
|
|
21
|
+
columns,
|
|
22
|
+
optionsComponent,
|
|
23
|
+
defaultPageSize = 10,
|
|
24
|
+
pageSizes = [5, 10, 15, 20]
|
|
25
|
+
} = config;
|
|
26
|
+
|
|
27
|
+
type AccessorType = keyof (typeof $data)[0];
|
|
28
|
+
|
|
29
|
+
const dispatch = createEventDispatcher();
|
|
30
|
+
const actionDispatcher = (obj) => dispatch('action', obj);
|
|
31
|
+
|
|
32
|
+
const table = createTable(data, {
|
|
33
|
+
colFilter: addColumnFilters(),
|
|
34
|
+
tableFilter: addTableFilter({
|
|
35
|
+
fn: searchFilter
|
|
36
|
+
}),
|
|
37
|
+
sort: addSortBy({ disableMultiSort: true }),
|
|
38
|
+
page: addPagination({ initialPageSize: defaultPageSize }),
|
|
39
|
+
expand: addExpandedRows()
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const accessors: AccessorType[] =
|
|
43
|
+
$data.length > 0 ? (Object.keys($data[0]) as AccessorType[]) : [];
|
|
44
|
+
|
|
45
|
+
const tableColumns = [
|
|
46
|
+
...accessors
|
|
47
|
+
.filter((accessor) => {
|
|
48
|
+
const key = accessor as string;
|
|
49
|
+
if (columns !== undefined && key in columns && columns[key].exclude === true) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
})
|
|
54
|
+
.map((accessor) => {
|
|
55
|
+
const key = accessor as string;
|
|
56
|
+
if (columns !== undefined && key in columns) {
|
|
57
|
+
const {
|
|
58
|
+
header,
|
|
59
|
+
colFilterFn,
|
|
60
|
+
colFilterComponent,
|
|
61
|
+
instructions,
|
|
62
|
+
disableFiltering = false,
|
|
63
|
+
disableSorting = false
|
|
64
|
+
} = columns[key];
|
|
65
|
+
|
|
66
|
+
const { toSortableValueFn, toFilterableValueFn, toStringFn } = instructions ?? {};
|
|
67
|
+
|
|
68
|
+
return table.column({
|
|
69
|
+
header: header ?? key,
|
|
70
|
+
accessor: accessor,
|
|
71
|
+
cell: ({ value }) => {
|
|
72
|
+
return toStringFn ? toStringFn(value) : value;
|
|
73
|
+
},
|
|
74
|
+
plugins: {
|
|
75
|
+
sort: {
|
|
76
|
+
disable: disableSorting,
|
|
77
|
+
invert: true,
|
|
78
|
+
getSortValue: (row) => {
|
|
79
|
+
return toSortableValueFn ? toSortableValueFn(row) : row;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
colFilter: !disableFiltering
|
|
83
|
+
? {
|
|
84
|
+
fn: ({ filterValue, value }) => {
|
|
85
|
+
const val = toFilterableValueFn ? toFilterableValueFn(value) : value;
|
|
86
|
+
|
|
87
|
+
return colFilterFn
|
|
88
|
+
? colFilterFn({ filterValue, value: val })
|
|
89
|
+
: columnFilter({ filterValue, value: val });
|
|
90
|
+
},
|
|
91
|
+
render: ({ filterValue, values, id }) => {
|
|
92
|
+
return createRender(colFilterComponent ?? TableFilter, {
|
|
93
|
+
filterValue,
|
|
94
|
+
id,
|
|
95
|
+
tableId,
|
|
96
|
+
values
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
: undefined,
|
|
101
|
+
tableFilter: {
|
|
102
|
+
getFilterValue: (row) => {
|
|
103
|
+
return toStringFn ? toStringFn(row) : row;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
return table.column({
|
|
110
|
+
header: key,
|
|
111
|
+
accessor: accessor,
|
|
112
|
+
plugins: {
|
|
113
|
+
sort: {
|
|
114
|
+
invert: true
|
|
115
|
+
},
|
|
116
|
+
colFilter: {
|
|
117
|
+
fn: columnFilter,
|
|
118
|
+
render: ({ filterValue, values, id }) =>
|
|
119
|
+
createRender(TableFilter, {
|
|
120
|
+
filterValue,
|
|
121
|
+
id,
|
|
122
|
+
tableId,
|
|
123
|
+
values
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
if (optionsComponent !== undefined) {
|
|
133
|
+
tableColumns.push(
|
|
134
|
+
table.display({
|
|
135
|
+
id: 'options',
|
|
136
|
+
header: '',
|
|
137
|
+
cell: ({ row }, _) => {
|
|
138
|
+
return createRender(optionsComponent!, {
|
|
139
|
+
row: row.isData() ? row.original : null,
|
|
140
|
+
dispatchFn: actionDispatcher
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}) as any
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const createdTableColumns = table.createColumns(tableColumns);
|
|
148
|
+
|
|
149
|
+
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } =
|
|
150
|
+
table.createViewModel(createdTableColumns);
|
|
151
|
+
const { filterValue } = pluginStates.tableFilter;
|
|
152
|
+
</script>
|
|
153
|
+
|
|
154
|
+
<div class="grid gap-2">
|
|
155
|
+
<div class="table-container">
|
|
156
|
+
<input
|
|
157
|
+
class="input p-2 mb-2 border border-primary-500"
|
|
158
|
+
type="text"
|
|
159
|
+
bind:value={$filterValue}
|
|
160
|
+
placeholder="Search rows..."
|
|
161
|
+
/>
|
|
162
|
+
<table {...$tableAttrs} class="table table-compact bg-tertiary-200">
|
|
163
|
+
<thead>
|
|
164
|
+
{#each $headerRows as headerRow (headerRow.id)}
|
|
165
|
+
<Subscribe
|
|
166
|
+
rowAttrs={headerRow.attrs()}
|
|
167
|
+
let:rowAttrs
|
|
168
|
+
rowProps={headerRow.props()}
|
|
169
|
+
let:rowProps
|
|
170
|
+
>
|
|
171
|
+
<tr {...rowAttrs} class="bg-primary-300">
|
|
172
|
+
{#each headerRow.cells as cell (cell.id)}
|
|
173
|
+
<Subscribe attrs={cell.attrs()} props={cell.props()} let:props let:attrs>
|
|
174
|
+
<th scope="col" class="!p-2" {...attrs}>
|
|
175
|
+
<div class="flex w-full justify-between items-center">
|
|
176
|
+
<div class="flex gap-1">
|
|
177
|
+
<span
|
|
178
|
+
class:underline={props.sort.order}
|
|
179
|
+
class:normal-case={cell.id !== cell.label}
|
|
180
|
+
on:click={props.sort.toggle}
|
|
181
|
+
on:keydown={props.sort.toggle}
|
|
182
|
+
>
|
|
183
|
+
{cell.render()}
|
|
184
|
+
</span>
|
|
185
|
+
<div class="w-2">
|
|
186
|
+
{#if props.sort.order === 'asc'}
|
|
187
|
+
▾
|
|
188
|
+
{:else if props.sort.order === 'desc'}
|
|
189
|
+
▴
|
|
190
|
+
{/if}
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
{#if cell.isData()}
|
|
194
|
+
{#if props.colFilter?.render}
|
|
195
|
+
<div>
|
|
196
|
+
<Render of={props.colFilter.render} />
|
|
197
|
+
</div>
|
|
198
|
+
{/if}
|
|
199
|
+
{/if}
|
|
200
|
+
</div>
|
|
201
|
+
</th>
|
|
202
|
+
</Subscribe>
|
|
203
|
+
{/each}
|
|
204
|
+
</tr>
|
|
205
|
+
</Subscribe>
|
|
206
|
+
{/each}
|
|
207
|
+
</thead>
|
|
208
|
+
|
|
209
|
+
<tbody class="" {...$tableBodyAttrs}>
|
|
210
|
+
{#each $pageRows as row (row.id)}
|
|
211
|
+
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
|
212
|
+
<tr {...rowAttrs}>
|
|
213
|
+
{#each row.cells as cell (cell?.id)}
|
|
214
|
+
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
215
|
+
<td {...attrs} class="!p-2">
|
|
216
|
+
<div class="flex items-center w-full h-full table-cell-fit">
|
|
217
|
+
<Render of={cell.render()} />
|
|
218
|
+
</div>
|
|
219
|
+
</td>
|
|
220
|
+
</Subscribe>
|
|
221
|
+
{/each}
|
|
222
|
+
</tr>
|
|
223
|
+
</Subscribe>
|
|
224
|
+
{/each}
|
|
225
|
+
</tbody>
|
|
226
|
+
</table>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<TablePagination pageConfig={pluginStates.page} {pageSizes} />
|
|
230
|
+
</div>
|