@bexis2/bexis2-core-ui 0.0.22 → 0.0.25
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 +14 -33
- package/dist/TableView.svelte +1 -1
- package/dist/components/ListView.svelte +5 -5
- package/dist/components/Table/Table.svelte +167 -0
- package/dist/components/Table/Table.svelte.d.ts +17 -0
- package/dist/components/Table/TableFilter.svelte +168 -0
- package/dist/components/Table/TableFilter.svelte.d.ts +21 -0
- package/dist/components/Table/TablePagination.svelte +60 -0
- package/dist/components/Table/TablePagination.svelte.d.ts +17 -0
- package/dist/components/Table/filter.d.ts +4 -0
- package/dist/components/Table/filter.js +83 -0
- package/dist/components/file/FileIcon.svelte +45 -0
- package/dist/components/file/FileInfo.svelte +13 -0
- package/dist/components/{File → file}/FileUploader.svelte +35 -38
- package/dist/components/form/Checkbox.svelte +21 -0
- package/dist/components/form/Checkbox.svelte.d.ts +24 -0
- package/dist/components/form/CheckboxKvPList.svelte +18 -0
- package/dist/components/form/CheckboxKvPList.svelte.d.ts +20 -0
- package/dist/components/form/CheckboxList.svelte +18 -0
- package/dist/components/form/CheckboxList.svelte.d.ts +20 -0
- package/dist/components/form/DateInput.svelte +21 -0
- package/dist/components/form/DateInput.svelte.d.ts +24 -0
- package/dist/components/form/DropdownKvP.svelte +44 -0
- package/dist/components/form/DropdownKvP.svelte.d.ts +43 -0
- package/dist/components/form/InputContainer.svelte +21 -0
- package/dist/components/form/InputContainer.svelte.d.ts +20 -0
- package/dist/components/form/MultiSelect.svelte +89 -0
- package/dist/components/form/MultiSelect.svelte.d.ts +41 -0
- package/dist/components/form/NumberInput.svelte +21 -0
- package/dist/components/form/NumberInput.svelte.d.ts +24 -0
- package/dist/components/form/TextArea.svelte +20 -0
- package/dist/components/form/TextArea.svelte.d.ts +24 -0
- package/dist/components/form/TextInput.svelte +21 -0
- package/dist/components/form/TextInput.svelte.d.ts +24 -0
- package/dist/components/spinner/Spinner.svelte +9 -0
- package/dist/css/core.ui.css +5 -2
- package/dist/css/themes/theme-bexis2.css +96 -98
- package/dist/css/themes/theme-crimson.css +3 -2
- package/dist/css/themes/theme-hamlindigo.css +3 -2
- package/dist/css/themes/theme-seafoam.css +3 -2
- package/dist/index.d.ts +16 -5
- package/dist/index.js +20 -5
- package/dist/models/Models.d.ts +28 -0
- package/dist/services/Api.js +12 -11
- package/dist/stores/apistore.js +13 -13
- package/package.json +101 -85
- package/src/lib/TableView.svelte +1 -1
- package/src/lib/components/ListView.svelte +11 -13
- package/src/lib/components/Table/Table.svelte +184 -0
- package/src/lib/components/Table/TableFilter.svelte +176 -0
- package/src/lib/components/Table/TablePagination.svelte +61 -0
- package/src/lib/components/Table/filter.ts +94 -0
- package/src/lib/components/file/FileIcon.svelte +45 -0
- package/src/lib/components/file/FileInfo.svelte +13 -0
- package/src/lib/components/file/FileUploader.svelte +184 -0
- package/src/lib/components/form/Checkbox.svelte +24 -0
- package/src/lib/components/form/CheckboxKvPList.svelte +21 -0
- package/src/lib/components/form/CheckboxList.svelte +21 -0
- package/src/lib/components/form/DateInput.svelte +24 -0
- package/src/lib/components/form/DropdownKvP.svelte +44 -0
- package/src/lib/components/form/InputContainer.svelte +22 -0
- package/src/lib/components/form/MultiSelect.svelte +89 -0
- package/src/lib/components/form/NumberInput.svelte +24 -0
- package/src/lib/components/form/TextArea.svelte +23 -0
- package/src/lib/components/form/TextInput.svelte +24 -0
- package/src/lib/components/spinner/Spinner.svelte +9 -0
- package/src/lib/css/core.ui.css +5 -2
- package/src/lib/css/themes/theme-bexis2.css +96 -98
- package/src/lib/css/themes/theme-crimson.css +3 -2
- package/src/lib/css/themes/theme-hamlindigo.css +3 -2
- package/src/lib/css/themes/theme-seafoam.css +3 -2
- package/src/lib/index.ts +40 -11
- package/src/lib/models/Models.ts +70 -39
- package/src/lib/services/Api.ts +55 -58
- package/src/lib/stores/apistore.ts +28 -32
- package/dist/components/File/FileIcon.svelte +0 -49
- package/dist/components/File/FileInfo.svelte +0 -14
- package/dist/components/Spinner/Spinner.svelte +0 -8
- package/src/lib/components/File/FileIcon.svelte +0 -49
- package/src/lib/components/File/FileInfo.svelte +0 -14
- package/src/lib/components/File/FileUploader.svelte +0 -217
- package/src/lib/components/Spinner/Spinner.svelte +0 -8
- /package/dist/components/{File → file}/FileIcon.svelte.d.ts +0 -0
- /package/dist/components/{File → file}/FileInfo.svelte.d.ts +0 -0
- /package/dist/components/{File → file}/FileUploader.svelte.d.ts +0 -0
- /package/dist/components/{Spinner → spinner}/Spinner.svelte.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,38 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# bexis-core-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## new in version 0.0.23
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Updates
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- update bexis 2 theme
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
# create a new project in the current directory
|
|
11
|
-
npm create svelte@latest
|
|
9
|
+
## Adds
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
npm run dev
|
|
23
|
-
|
|
24
|
-
# or start the server and open the app in a new browser tab
|
|
25
|
-
npm run dev -- --open
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Building
|
|
29
|
-
|
|
30
|
-
To create a production version of your app:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
npm run build
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
You can preview the production build with `npm run preview`.
|
|
37
|
-
|
|
38
|
-
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
|
11
|
+
- Checkbox
|
|
12
|
+
- CheckboxKVPList
|
|
13
|
+
- CheckboxList
|
|
14
|
+
- DateInput
|
|
15
|
+
- DropdownKVP
|
|
16
|
+
- MultiSelect
|
|
17
|
+
- NumberInput
|
|
18
|
+
- TextArea
|
|
19
|
+
- TextInput
|
package/dist/TableView.svelte
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<h1>table</h1>
|
|
1
|
+
<h1>table</h1>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>let result = { name: "david" };
|
|
2
|
-
</script>
|
|
3
|
-
|
|
4
|
-
<h1>MyList</h1>
|
|
5
|
-
{result.name}
|
|
6
|
-
<b>from bexis-lib</b>
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<h1>MyList</h1>
|
|
5
|
+
{result.name}
|
|
6
|
+
<b>from bexis-lib</b>
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<script>import { createTable, Subscribe, Render, createRender } from "svelte-headless-table";
|
|
2
|
+
import {
|
|
3
|
+
addSortBy,
|
|
4
|
+
addPagination,
|
|
5
|
+
addExpandedRows,
|
|
6
|
+
addColumnFilters,
|
|
7
|
+
addTableFilter
|
|
8
|
+
} from "svelte-headless-table/plugins";
|
|
9
|
+
import TableFilter from "./TableFilter.svelte";
|
|
10
|
+
import TablePagination from "./TablePagination.svelte";
|
|
11
|
+
import { columnFilter, searchFilter } from "./filter";
|
|
12
|
+
export let config;
|
|
13
|
+
let {
|
|
14
|
+
id: tableId,
|
|
15
|
+
data,
|
|
16
|
+
columns,
|
|
17
|
+
optionsComponent,
|
|
18
|
+
defaultPageSize = 10,
|
|
19
|
+
pageSizes = [5, 10, 15, 20]
|
|
20
|
+
} = config;
|
|
21
|
+
const table = createTable(data, {
|
|
22
|
+
colFilter: addColumnFilters(),
|
|
23
|
+
tableFilter: addTableFilter({
|
|
24
|
+
fn: searchFilter
|
|
25
|
+
}),
|
|
26
|
+
sort: addSortBy({ disableMultiSort: true }),
|
|
27
|
+
page: addPagination({ initialPageSize: defaultPageSize }),
|
|
28
|
+
expand: addExpandedRows()
|
|
29
|
+
});
|
|
30
|
+
const accessors = Object.keys($data[0]);
|
|
31
|
+
const tableColumns = [
|
|
32
|
+
...accessors.filter((accessor) => {
|
|
33
|
+
const key = accessor;
|
|
34
|
+
if (columns !== void 0 && key in columns && columns[key].exclude === true) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}).map((accessor) => {
|
|
39
|
+
const key = accessor;
|
|
40
|
+
if (columns !== void 0 && key in columns) {
|
|
41
|
+
const { header, colFilterFn, colFilterComponent } = columns[key];
|
|
42
|
+
return table.column({
|
|
43
|
+
header: header ?? key,
|
|
44
|
+
accessor,
|
|
45
|
+
plugins: {
|
|
46
|
+
sort: { invert: true },
|
|
47
|
+
colFilter: {
|
|
48
|
+
fn: colFilterFn ?? columnFilter,
|
|
49
|
+
render: ({ filterValue: filterValue2, values, id }) => createRender(colFilterComponent ?? TableFilter, {
|
|
50
|
+
filterValue: filterValue2,
|
|
51
|
+
values,
|
|
52
|
+
id,
|
|
53
|
+
tableId
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
return table.column({
|
|
60
|
+
header: key,
|
|
61
|
+
accessor,
|
|
62
|
+
plugins: {
|
|
63
|
+
sort: { invert: true },
|
|
64
|
+
colFilter: {
|
|
65
|
+
fn: columnFilter,
|
|
66
|
+
render: ({ filterValue: filterValue2, values, id }) => createRender(TableFilter, { filterValue: filterValue2, values, id, tableId })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
];
|
|
73
|
+
if (optionsComponent !== void 0) {
|
|
74
|
+
tableColumns.push(
|
|
75
|
+
table.display({
|
|
76
|
+
id: "options",
|
|
77
|
+
header: "",
|
|
78
|
+
cell: ({ row }, _) => {
|
|
79
|
+
return createRender(optionsComponent, {
|
|
80
|
+
row: row.isData() ? row.original : null
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const createdTableColumns = table.createColumns(tableColumns);
|
|
87
|
+
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } = table.createViewModel(createdTableColumns);
|
|
88
|
+
const { filterValue } = pluginStates.tableFilter;
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<div class="grid gap-2">
|
|
92
|
+
<div class="table-container">
|
|
93
|
+
<input
|
|
94
|
+
class="input p-2 mb-2 border border-primary-500"
|
|
95
|
+
type="text"
|
|
96
|
+
bind:value={$filterValue}
|
|
97
|
+
placeholder="Search rows..."
|
|
98
|
+
/>
|
|
99
|
+
<table {...$tableAttrs} class="table table-compact bg-tertiary-200">
|
|
100
|
+
<thead>
|
|
101
|
+
{#each $headerRows as headerRow (headerRow.id)}
|
|
102
|
+
<Subscribe
|
|
103
|
+
rowAttrs={headerRow.attrs()}
|
|
104
|
+
let:rowAttrs
|
|
105
|
+
rowProps={headerRow.props()}
|
|
106
|
+
let:rowProps
|
|
107
|
+
>
|
|
108
|
+
<tr {...rowAttrs} class="bg-primary-300">
|
|
109
|
+
{#each headerRow.cells as cell (cell.id)}
|
|
110
|
+
<Subscribe attrs={cell.attrs()} props={cell.props()} let:props let:attrs>
|
|
111
|
+
<th scope="col" class="!p-2" {...attrs}>
|
|
112
|
+
<div class="flex w-full justify-between items-center">
|
|
113
|
+
<div class="flex gap-1">
|
|
114
|
+
<span
|
|
115
|
+
class:underline={props.sort.order}
|
|
116
|
+
class:normal-case={cell.id !== cell.label}
|
|
117
|
+
on:click={props.sort.toggle}
|
|
118
|
+
on:keydown={props.sort.toggle}
|
|
119
|
+
>
|
|
120
|
+
{cell.render()}
|
|
121
|
+
</span>
|
|
122
|
+
<div class="w-2">
|
|
123
|
+
{#if props.sort.order === 'asc'}
|
|
124
|
+
▾
|
|
125
|
+
{:else if props.sort.order === 'desc'}
|
|
126
|
+
▴
|
|
127
|
+
{/if}
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
{#if cell.isData()}
|
|
131
|
+
{#if props.colFilter?.render}
|
|
132
|
+
<div>
|
|
133
|
+
<Render of={props.colFilter.render} />
|
|
134
|
+
</div>
|
|
135
|
+
{/if}
|
|
136
|
+
{/if}
|
|
137
|
+
</div>
|
|
138
|
+
</th>
|
|
139
|
+
</Subscribe>
|
|
140
|
+
{/each}
|
|
141
|
+
</tr>
|
|
142
|
+
</Subscribe>
|
|
143
|
+
{/each}
|
|
144
|
+
</thead>
|
|
145
|
+
|
|
146
|
+
<tbody class="" {...$tableBodyAttrs}>
|
|
147
|
+
{#each $pageRows as row (row.id)}
|
|
148
|
+
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
|
149
|
+
<tr {...rowAttrs}>
|
|
150
|
+
{#each row.cells as cell (cell?.id)}
|
|
151
|
+
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
152
|
+
<td {...attrs} class="!p-2">
|
|
153
|
+
<div class="flex items-center w-full h-full table-cell-fit">
|
|
154
|
+
<Render of={cell.render()} />
|
|
155
|
+
</div>
|
|
156
|
+
</td>
|
|
157
|
+
</Subscribe>
|
|
158
|
+
{/each}
|
|
159
|
+
</tr>
|
|
160
|
+
</Subscribe>
|
|
161
|
+
{/each}
|
|
162
|
+
</tbody>
|
|
163
|
+
</table>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<TablePagination pageConfig={pluginStates.page} {pageSizes} />
|
|
167
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { TableConfig } from '../../models/Models';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
config: TableConfig<any>;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type TableProps = typeof __propDef.props;
|
|
13
|
+
export type TableEvents = typeof __propDef.events;
|
|
14
|
+
export type TableSlots = typeof __propDef.slots;
|
|
15
|
+
export default class Table extends SvelteComponentTyped<TableProps, TableEvents, TableSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<script>import Fa from "svelte-fa/src/fa.svelte";
|
|
2
|
+
import { faFilter } from "@fortawesome/free-solid-svg-icons";
|
|
3
|
+
import { popup } from "@skeletonlabs/skeleton";
|
|
4
|
+
export let filterValue;
|
|
5
|
+
export let values;
|
|
6
|
+
export let id;
|
|
7
|
+
export let tableId;
|
|
8
|
+
let firstOption;
|
|
9
|
+
let firstValue;
|
|
10
|
+
let secondOption;
|
|
11
|
+
let secondValue;
|
|
12
|
+
let active = false;
|
|
13
|
+
const options = {
|
|
14
|
+
number: [
|
|
15
|
+
{
|
|
16
|
+
value: "isequal",
|
|
17
|
+
label: "Is equal to"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: "isgreaterorequal",
|
|
21
|
+
label: "Is greater than or equal to"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: "isgreater",
|
|
25
|
+
label: "Is greater than"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: "islessorequal",
|
|
29
|
+
label: "Is less than or equal to"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: "isless",
|
|
33
|
+
label: "Is less than"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: "isnotequal",
|
|
37
|
+
label: "Is not equal to"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
string: [
|
|
41
|
+
{
|
|
42
|
+
value: "isequal",
|
|
43
|
+
label: "Is equal to"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
value: "isnotequal",
|
|
47
|
+
label: "Is not equal to"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
value: "starts",
|
|
51
|
+
label: "Starts with"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
value: "contains",
|
|
55
|
+
label: "Contains"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: "notcontains",
|
|
59
|
+
label: "Does not contain"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: "ends",
|
|
63
|
+
label: "Ends with"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
const popupId = `${tableId}-${id}`;
|
|
68
|
+
const popupFeatured = {
|
|
69
|
+
event: "click",
|
|
70
|
+
target: popupId,
|
|
71
|
+
placement: "bottom-start"
|
|
72
|
+
};
|
|
73
|
+
const type = typeof $values[0];
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<form class="">
|
|
77
|
+
<button
|
|
78
|
+
class:variant-filled-primary={active}
|
|
79
|
+
class="btn w-max p-2"
|
|
80
|
+
type="button"
|
|
81
|
+
use:popup={popupFeatured}
|
|
82
|
+
>
|
|
83
|
+
<Fa icon={faFilter} size="12" />
|
|
84
|
+
</button>
|
|
85
|
+
|
|
86
|
+
<div data-popup={`${popupId}`}>
|
|
87
|
+
<div class="card p-3 absolute grid gap-2 shadow-lg z-10 w-min">
|
|
88
|
+
<button
|
|
89
|
+
class="btn variant-filled-primary btn-sm"
|
|
90
|
+
type="submit"
|
|
91
|
+
on:click={() => {
|
|
92
|
+
firstOption = 'isequal';
|
|
93
|
+
firstValue = undefined;
|
|
94
|
+
secondOption = 'isequal';
|
|
95
|
+
secondValue = undefined;
|
|
96
|
+
|
|
97
|
+
$filterValue = [firstOption, firstValue, secondOption, secondValue];
|
|
98
|
+
active = false;
|
|
99
|
+
}}>Clear Filter</button
|
|
100
|
+
>
|
|
101
|
+
|
|
102
|
+
<label for="" class="label normal-case text-sm">Show rows with value that</label>
|
|
103
|
+
<div class="grid gap-2 w-full">
|
|
104
|
+
<select
|
|
105
|
+
class="select border border-primary-500 text-sm p-1"
|
|
106
|
+
aria-label="Show rows with value that"
|
|
107
|
+
bind:value={firstOption}
|
|
108
|
+
on:click|stopPropagation
|
|
109
|
+
>
|
|
110
|
+
{#each options[type] as option (option)}
|
|
111
|
+
<option value={option.value}>{option.label}</option>
|
|
112
|
+
{/each}
|
|
113
|
+
</select>
|
|
114
|
+
{#if type === 'number'}
|
|
115
|
+
<input
|
|
116
|
+
type="number"
|
|
117
|
+
class="input p-1 border border-primary-500"
|
|
118
|
+
bind:value={firstValue}
|
|
119
|
+
on:click|stopPropagation
|
|
120
|
+
/>
|
|
121
|
+
{:else}
|
|
122
|
+
<input
|
|
123
|
+
type="text"
|
|
124
|
+
class="input p-1 border border-primary-500"
|
|
125
|
+
bind:value={firstValue}
|
|
126
|
+
on:click|stopPropagation
|
|
127
|
+
/>
|
|
128
|
+
{/if}
|
|
129
|
+
</div>
|
|
130
|
+
<label for="" class="label normal-case">And</label>
|
|
131
|
+
<div class="grid gap-2 w-max">
|
|
132
|
+
<select
|
|
133
|
+
class="select border border-primary-500 text-sm p-1"
|
|
134
|
+
aria-label="Show rows with value that"
|
|
135
|
+
bind:value={secondOption}
|
|
136
|
+
on:click|stopPropagation
|
|
137
|
+
>
|
|
138
|
+
{#each options[type] as option (option)}
|
|
139
|
+
<option value={option.value}>{option.label}</option>
|
|
140
|
+
{/each}
|
|
141
|
+
</select>
|
|
142
|
+
{#if type === 'number'}
|
|
143
|
+
<input
|
|
144
|
+
type="number"
|
|
145
|
+
class="input p-1 border border-primary-500"
|
|
146
|
+
bind:value={secondValue}
|
|
147
|
+
on:click|stopPropagation
|
|
148
|
+
/>
|
|
149
|
+
{:else}
|
|
150
|
+
<input
|
|
151
|
+
type="text"
|
|
152
|
+
class="input p-1 border border-primary-500"
|
|
153
|
+
bind:value={secondValue}
|
|
154
|
+
on:click|stopPropagation
|
|
155
|
+
/>
|
|
156
|
+
{/if}
|
|
157
|
+
</div>
|
|
158
|
+
<button
|
|
159
|
+
class="btn variant-filled-primary btn-sm"
|
|
160
|
+
type="submit"
|
|
161
|
+
on:click={() => {
|
|
162
|
+
active = firstValue?.toString().length > 0 || secondValue?.toString().length > 0;
|
|
163
|
+
$filterValue = [firstOption, firstValue, secondOption, secondValue];
|
|
164
|
+
}}>Submit</button
|
|
165
|
+
>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
</form>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
filterValue: any;
|
|
5
|
+
values: any;
|
|
6
|
+
id: any;
|
|
7
|
+
tableId: any;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
click: MouseEvent;
|
|
11
|
+
} & {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
};
|
|
16
|
+
export type TableFilterProps = typeof __propDef.props;
|
|
17
|
+
export type TableFilterEvents = typeof __propDef.events;
|
|
18
|
+
export type TableFilterSlots = typeof __propDef.slots;
|
|
19
|
+
export default class TableFilter extends SvelteComponentTyped<TableFilterProps, TableFilterEvents, TableFilterSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script>import Fa from "svelte-fa/src/fa.svelte";
|
|
2
|
+
import {
|
|
3
|
+
faAnglesRight,
|
|
4
|
+
faAngleRight,
|
|
5
|
+
faAnglesLeft,
|
|
6
|
+
faAngleLeft
|
|
7
|
+
} from "@fortawesome/free-solid-svg-icons";
|
|
8
|
+
export let pageConfig;
|
|
9
|
+
export let pageSizes;
|
|
10
|
+
const { pageIndex, pageCount, pageSize, hasNextPage, hasPreviousPage } = pageConfig;
|
|
11
|
+
const goToFirstPage = () => $pageIndex = 0;
|
|
12
|
+
const goToLastPage = () => $pageIndex = $pageCount - 1;
|
|
13
|
+
const goToNextPage = () => $pageIndex += 1;
|
|
14
|
+
const goToPreviousPage = () => $pageIndex -= 1;
|
|
15
|
+
$:
|
|
16
|
+
goToFirstPageDisabled = !$pageIndex;
|
|
17
|
+
$:
|
|
18
|
+
goToLastPageDisabled = $pageIndex == $pageCount - 1;
|
|
19
|
+
$:
|
|
20
|
+
goToNextPageDisabled = !$hasNextPage;
|
|
21
|
+
$:
|
|
22
|
+
goToPreviousPageDisabled = !$hasPreviousPage;
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<div class="flex justify-center gap-1">
|
|
26
|
+
<button
|
|
27
|
+
class="btn btn-sm variant-filled-primary"
|
|
28
|
+
on:click={goToFirstPage}
|
|
29
|
+
disabled={goToFirstPageDisabled}
|
|
30
|
+
>
|
|
31
|
+
<Fa icon={faAnglesLeft} /></button
|
|
32
|
+
>
|
|
33
|
+
<button
|
|
34
|
+
class="btn btn-sm variant-filled-primary"
|
|
35
|
+
on:click={goToPreviousPage}
|
|
36
|
+
disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
|
|
37
|
+
>
|
|
38
|
+
|
|
39
|
+
<select
|
|
40
|
+
name="pageSize"
|
|
41
|
+
id="pageSize"
|
|
42
|
+
class="select btn btn-sm variant-filled-primary w-min font-bold"
|
|
43
|
+
bind:value={$pageSize}
|
|
44
|
+
>
|
|
45
|
+
{#each pageSizes as size}
|
|
46
|
+
<option value={size}>{size}</option>
|
|
47
|
+
{/each}
|
|
48
|
+
</select>
|
|
49
|
+
|
|
50
|
+
<button
|
|
51
|
+
class="btn btn-sm variant-filled-primary"
|
|
52
|
+
on:click={goToNextPage}
|
|
53
|
+
disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
|
|
54
|
+
>
|
|
55
|
+
<button
|
|
56
|
+
class="btn btn-sm variant-filled-primary"
|
|
57
|
+
on:click={goToLastPage}
|
|
58
|
+
disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
|
|
59
|
+
>
|
|
60
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
pageConfig: any;
|
|
5
|
+
pageSizes: any;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type TablePaginationProps = typeof __propDef.props;
|
|
13
|
+
export type TablePaginationEvents = typeof __propDef.events;
|
|
14
|
+
export type TablePaginationSlots = typeof __propDef.slots;
|
|
15
|
+
export default class TablePagination extends SvelteComponentTyped<TablePaginationProps, TablePaginationEvents, TablePaginationSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const textFilter = (filterOption, filterValue, value) => {
|
|
2
|
+
switch (filterOption) {
|
|
3
|
+
case 'isequal':
|
|
4
|
+
return value.toLowerCase() === filterValue.toLowerCase();
|
|
5
|
+
case 'isnotequal':
|
|
6
|
+
return value.toLowerCase() !== filterValue.toLowerCase();
|
|
7
|
+
case 'starts':
|
|
8
|
+
return value.toLowerCase().startsWith(filterValue.toLowerCase());
|
|
9
|
+
case 'ends':
|
|
10
|
+
return value.toLowerCase().endsWith(filterValue.toLowerCase());
|
|
11
|
+
case 'contains':
|
|
12
|
+
return value.toLowerCase().includes(filterValue.toLowerCase());
|
|
13
|
+
case 'notcontains':
|
|
14
|
+
return !value.toLowerCase().includes(filterValue.toLowerCase());
|
|
15
|
+
default:
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const numberFilter = (filterOption, filterValue, value) => {
|
|
20
|
+
switch (filterOption) {
|
|
21
|
+
case 'isequal':
|
|
22
|
+
return value === filterValue;
|
|
23
|
+
case 'isnotequal':
|
|
24
|
+
return value !== filterValue;
|
|
25
|
+
case 'isgreater':
|
|
26
|
+
return value > filterValue;
|
|
27
|
+
case 'isless':
|
|
28
|
+
return value < filterValue;
|
|
29
|
+
case 'isgreaterorequal':
|
|
30
|
+
return value >= filterValue;
|
|
31
|
+
case 'islessorequal':
|
|
32
|
+
return value <= filterValue;
|
|
33
|
+
default:
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const numericFilter = ({ filterValue, value }) => {
|
|
38
|
+
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
39
|
+
if (!firstFilterValue && !secondFilterValue) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
else if ((!firstFilterOption || !firstFilterValue) && secondFilterOption && secondFilterValue) {
|
|
43
|
+
return numberFilter(secondFilterOption, secondFilterValue, value);
|
|
44
|
+
}
|
|
45
|
+
else if ((!secondFilterOption || !secondFilterValue) && firstFilterOption && firstFilterValue) {
|
|
46
|
+
return numberFilter(firstFilterOption, firstFilterValue, value);
|
|
47
|
+
}
|
|
48
|
+
return (numberFilter(firstFilterOption, firstFilterValue, value) &&
|
|
49
|
+
numberFilter(secondFilterOption, secondFilterValue, value));
|
|
50
|
+
};
|
|
51
|
+
const stringFilter = ({ filterValue, value }) => {
|
|
52
|
+
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
53
|
+
if (!firstFilterValue?.length && !secondFilterValue?.length) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
else if ((!firstFilterOption || !firstFilterValue) &&
|
|
57
|
+
secondFilterOption &&
|
|
58
|
+
secondFilterValue?.length) {
|
|
59
|
+
return textFilter(secondFilterOption, secondFilterValue, value);
|
|
60
|
+
}
|
|
61
|
+
else if ((!secondFilterOption || !secondFilterValue?.length) &&
|
|
62
|
+
firstFilterOption &&
|
|
63
|
+
firstFilterValue?.length) {
|
|
64
|
+
return textFilter(firstFilterOption, firstFilterValue, value);
|
|
65
|
+
}
|
|
66
|
+
return (textFilter(firstFilterOption, firstFilterValue, value) &&
|
|
67
|
+
textFilter(secondFilterOption, secondFilterValue, value));
|
|
68
|
+
};
|
|
69
|
+
export const columnFilter = ({ filterValue, value }) => {
|
|
70
|
+
if (typeof value === 'string') {
|
|
71
|
+
return stringFilter({ filterValue, value });
|
|
72
|
+
}
|
|
73
|
+
else if (typeof value === 'number') {
|
|
74
|
+
return numericFilter({ filterValue, value });
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
export const searchFilter = ({ filterValue, value }) => {
|
|
79
|
+
if (value.toLowerCase().includes(filterValue.toLowerCase())) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Fa from 'svelte-fa';
|
|
3
|
+
import { faFileAudio } from '@fortawesome/free-regular-svg-icons';
|
|
4
|
+
import { faFileVideo } from '@fortawesome/free-regular-svg-icons';
|
|
5
|
+
import { faFileWord } from '@fortawesome/free-regular-svg-icons';
|
|
6
|
+
import { faFilePdf } from '@fortawesome/free-regular-svg-icons';
|
|
7
|
+
import { faFileExcel } from '@fortawesome/free-regular-svg-icons';
|
|
8
|
+
import { faFileAlt } from '@fortawesome/free-regular-svg-icons';
|
|
9
|
+
import { faFileImage } from '@fortawesome/free-regular-svg-icons';
|
|
10
|
+
import { faFileArchive } from '@fortawesome/free-regular-svg-icons';
|
|
11
|
+
|
|
12
|
+
export let type = '';
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if type.includes('excel') || type.includes('spreadsheetml')}
|
|
16
|
+
<Fa icon={faFileExcel} />
|
|
17
|
+
{/if}
|
|
18
|
+
|
|
19
|
+
{#if type.includes('text')}
|
|
20
|
+
<Fa icon={faFileAlt} />
|
|
21
|
+
{/if}
|
|
22
|
+
|
|
23
|
+
{#if type.includes('image')}
|
|
24
|
+
<Fa icon={faFileImage} />
|
|
25
|
+
{/if}
|
|
26
|
+
|
|
27
|
+
{#if type.includes('audio')}
|
|
28
|
+
<Fa icon={faFileAudio} />
|
|
29
|
+
{/if}
|
|
30
|
+
|
|
31
|
+
{#if type.includes('video')}
|
|
32
|
+
<Fa icon={faFileVideo} />
|
|
33
|
+
{/if}
|
|
34
|
+
|
|
35
|
+
{#if type.includes('word')}
|
|
36
|
+
<Fa icon={faFileWord} />
|
|
37
|
+
{/if}
|
|
38
|
+
|
|
39
|
+
{#if type.includes('pdf')}
|
|
40
|
+
<Fa icon={faFilePdf} />
|
|
41
|
+
{/if}
|
|
42
|
+
|
|
43
|
+
{#if type.includes('zip')}
|
|
44
|
+
<Fa icon={faFileArchive} />
|
|
45
|
+
{/if}
|