@bexis2/bexis2-core-ui 0.2.31 → 0.3.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 +9 -1
- package/dist/TableView.svelte +1 -1
- package/dist/components/CodeEditor/CodeEditor.svelte +2 -1
- package/dist/components/File/FileIcon.svelte +45 -45
- package/dist/components/File/FileInfo.svelte +13 -13
- package/dist/components/ListView.svelte +5 -5
- package/dist/components/Table/Table.svelte +87 -25
- package/dist/components/Table/TableFilter.svelte +1 -1
- package/dist/components/form/Checkbox.svelte +13 -13
- package/dist/components/form/CheckboxKvPList.svelte +16 -16
- package/dist/components/form/CheckboxList.svelte +10 -10
- package/dist/components/form/DateInput.svelte +14 -14
- package/dist/components/form/DropdownKvP.svelte +54 -54
- package/dist/components/form/DropdownKvP.svelte.d.ts +2 -2
- package/dist/components/form/MultiSelect.svelte +5 -6
- package/dist/components/form/MultiSelect.svelte.d.ts +2 -2
- package/dist/components/form/NumberInput.svelte +15 -15
- package/dist/components/form/TextArea.svelte +14 -14
- package/dist/components/form/TextInput.svelte +15 -15
- package/dist/components/page/Alert.svelte +28 -28
- package/dist/components/page/BackToTop.svelte +30 -30
- package/dist/components/page/Docs.svelte +22 -22
- package/dist/components/page/ErrorMessage.svelte +8 -8
- package/dist/components/page/Footer.svelte +5 -5
- package/dist/components/page/Header.svelte +5 -5
- package/dist/components/page/HelpPopUp.svelte +30 -30
- package/dist/components/page/Notification.svelte +39 -1
- package/dist/components/page/Page.svelte +1 -2
- package/dist/components/page/PageCaller.js +19 -19
- package/dist/components/page/Spinner.svelte +14 -14
- package/dist/components/page/breadcrumb/Breadcrumb.svelte +6 -2
- package/dist/components/page/menu/MenuDataCaller.js +10 -10
- package/dist/css/core.ui.postcss +17 -17
- package/dist/css/themes/theme-bexis2.css +96 -96
- package/dist/css/themes/theme-crimson.css +101 -101
- package/dist/css/themes/theme-gold-nouveau.css +140 -140
- package/dist/css/themes/theme-hamlindigo.css +112 -112
- package/dist/css/themes/theme-modern.css +127 -127
- package/dist/css/themes/theme-rocket.css +119 -119
- package/dist/css/themes/theme-sahara.css +128 -128
- package/dist/css/themes/theme-seafoam.css +122 -122
- package/dist/css/themes/theme-seasonal.css +115 -115
- package/dist/css/themes/theme-skeleton.css +118 -118
- package/dist/css/themes/theme-vintage.css +125 -125
- package/dist/models/Models.d.ts +3 -0
- package/dist/services/BaseCaller.js +16 -16
- package/dist/stores/apiStores.js +2 -0
- package/dist/stores/pageStores.d.ts +1 -4
- package/dist/stores/pageStores.js +3 -41
- package/dist/themes/theme-bexis2.d.ts +2 -0
- package/dist/themes/theme-bexis2.js +99 -0
- package/package.json +4 -2
- package/src/lib/TableView.svelte +1 -1
- package/src/lib/components/CodeEditor/CodeEditor.svelte +2 -1
- package/src/lib/components/ListView.svelte +11 -11
- package/src/lib/components/Table/Table.svelte +107 -26
- package/src/lib/components/Table/TableFilter.svelte +2 -1
- package/src/lib/components/Table/filter.ts +141 -141
- package/src/lib/components/{File → file}/FileIcon.svelte +45 -45
- package/src/lib/components/{File → file}/FileInfo.svelte +13 -13
- package/src/lib/components/{File → file}/FileUploader.svelte +3 -4
- package/src/lib/components/form/Checkbox.svelte +24 -24
- package/src/lib/components/form/CheckboxKvPList.svelte +29 -29
- package/src/lib/components/form/CheckboxList.svelte +21 -21
- package/src/lib/components/form/DateInput.svelte +27 -27
- package/src/lib/components/form/DropdownKvP.svelte +54 -54
- package/src/lib/components/form/MultiSelect.svelte +5 -6
- package/src/lib/components/form/NumberInput.svelte +30 -30
- package/src/lib/components/form/TextArea.svelte +28 -28
- package/src/lib/components/form/TextInput.svelte +28 -28
- package/src/lib/components/page/Alert.svelte +41 -41
- package/src/lib/components/page/BackToTop.svelte +30 -30
- package/src/lib/components/page/Docs.svelte +46 -46
- package/src/lib/components/page/ErrorMessage.svelte +10 -10
- package/src/lib/components/page/Footer.svelte +18 -18
- package/src/lib/components/page/Header.svelte +18 -18
- package/src/lib/components/page/HelpPopUp.svelte +72 -72
- package/src/lib/components/page/Notification.svelte +56 -1
- package/src/lib/components/page/Page.svelte +3 -4
- package/src/lib/components/page/PageCaller.js +19 -19
- package/src/lib/components/page/Spinner.svelte +20 -20
- package/src/lib/components/page/breadcrumb/Breadcrumb.svelte +8 -6
- package/src/lib/components/page/menu/MenuDataCaller.js +10 -10
- package/src/lib/css/core.ui.postcss +17 -17
- package/src/lib/css/themes/theme-bexis2.css +96 -96
- package/src/lib/css/themes/theme-crimson.css +101 -101
- package/src/lib/css/themes/theme-gold-nouveau.css +140 -140
- package/src/lib/css/themes/theme-hamlindigo.css +112 -112
- package/src/lib/css/themes/theme-modern.css +127 -127
- package/src/lib/css/themes/theme-rocket.css +119 -119
- package/src/lib/css/themes/theme-sahara.css +128 -128
- package/src/lib/css/themes/theme-seafoam.css +122 -122
- package/src/lib/css/themes/theme-seasonal.css +115 -115
- package/src/lib/css/themes/theme-skeleton.css +118 -118
- package/src/lib/css/themes/theme-vintage.css +125 -125
- package/src/lib/models/Models.ts +9 -6
- package/src/lib/models/Page.ts +40 -40
- package/src/lib/services/Api.ts +55 -55
- package/src/lib/services/BaseCaller.js +16 -16
- package/src/lib/stores/apiStores.ts +34 -31
- package/src/lib/stores/pageStores.ts +11 -53
- package/src/lib/themes/theme-bexis2.ts +103 -0
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
id: tableId,
|
|
25
25
|
data,
|
|
26
26
|
columns,
|
|
27
|
+
resizable = 'none',
|
|
27
28
|
height = null,
|
|
28
29
|
optionsComponent,
|
|
29
30
|
defaultPageSize = 10,
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
});
|
|
49
50
|
|
|
50
51
|
const allCols: { [key: string]: any } = {};
|
|
51
|
-
|
|
52
|
+
|
|
52
53
|
$data.forEach((item) => {
|
|
53
54
|
Object.keys(item).forEach((key) => {
|
|
54
55
|
if (!allCols[key]) {
|
|
@@ -133,7 +134,7 @@
|
|
|
133
134
|
header: key,
|
|
134
135
|
accessor: accessor,
|
|
135
136
|
cell: ({ value }) => {
|
|
136
|
-
return
|
|
137
|
+
return value ? value : '';
|
|
137
138
|
},
|
|
138
139
|
plugins: {
|
|
139
140
|
sort: {
|
|
@@ -158,7 +159,7 @@
|
|
|
158
159
|
if (optionsComponent !== undefined) {
|
|
159
160
|
tableColumns.push(
|
|
160
161
|
table.display({
|
|
161
|
-
id: '
|
|
162
|
+
id: 'optionsColumn',
|
|
162
163
|
header: '',
|
|
163
164
|
cell: ({ row }, _) => {
|
|
164
165
|
return createRender(optionsComponent!, {
|
|
@@ -175,13 +176,72 @@
|
|
|
175
176
|
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } =
|
|
176
177
|
table.createViewModel(createdTableColumns);
|
|
177
178
|
const { filterValue } = pluginStates.tableFilter;
|
|
179
|
+
|
|
180
|
+
const minWidth = (id: string) => {
|
|
181
|
+
if (columns && id in columns) {
|
|
182
|
+
return columns[id].minWidth ?? 0;
|
|
183
|
+
}
|
|
184
|
+
return 0;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const fixedWidth = (id: string) => {
|
|
188
|
+
if (columns && id in columns) {
|
|
189
|
+
return columns[id].fixedWidth ?? 0;
|
|
190
|
+
}
|
|
191
|
+
return 0;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const cellStyle = (id: string) => {
|
|
195
|
+
const minW = minWidth(id);
|
|
196
|
+
const fixedW = fixedWidth(id);
|
|
197
|
+
const styles: string[] = [];
|
|
198
|
+
|
|
199
|
+
minW && styles.push(`min-width: ${minW}px`);
|
|
200
|
+
fixedW && styles.push(`width: ${fixedW}px`);
|
|
201
|
+
|
|
202
|
+
return styles.join(';');
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const resetResize = () => {
|
|
206
|
+
if (resizable === 'columns' || resizable === 'both') {
|
|
207
|
+
$headerRows.forEach((row) => {
|
|
208
|
+
row.cells.forEach((cell) => {
|
|
209
|
+
const minW = minWidth(cell.id);
|
|
210
|
+
const fixedW = fixedWidth(cell.id);
|
|
211
|
+
|
|
212
|
+
fixedW &&
|
|
213
|
+
document
|
|
214
|
+
.getElementById(`th-${tableId}-${cell.id}`)
|
|
215
|
+
?.style.setProperty('width', `${fixedW}px`);
|
|
216
|
+
minW &&
|
|
217
|
+
document
|
|
218
|
+
.getElementById(`th-${tableId}-${cell.id}`)
|
|
219
|
+
?.style.setProperty('min-width', `${minW}px`);
|
|
220
|
+
|
|
221
|
+
!minW &&
|
|
222
|
+
!fixedW &&
|
|
223
|
+
document.getElementById(`th-${tableId}-${cell.id}`)?.style.setProperty('width', 'auto');
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (resizable === 'rows' || resizable === 'both') {
|
|
229
|
+
$pageRows.forEach((row) => {
|
|
230
|
+
row.cells.forEach((cell) => {
|
|
231
|
+
document
|
|
232
|
+
.getElementById(`${tableId}-${cell.id}-${row.id}`)
|
|
233
|
+
?.style.setProperty('height', 'auto');
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
};
|
|
178
238
|
</script>
|
|
179
239
|
|
|
180
240
|
<div class="grid gap-2 overflow-auto" class:w-fit={!fitToScreen} class:w-full={fitToScreen}>
|
|
181
241
|
<div class="table-container">
|
|
182
242
|
{#if $data.length > 0}
|
|
183
243
|
<input
|
|
184
|
-
class="input p-2
|
|
244
|
+
class="input p-2 border border-primary-500"
|
|
185
245
|
type="text"
|
|
186
246
|
bind:value={$filterValue}
|
|
187
247
|
placeholder="Search rows..."
|
|
@@ -189,24 +249,37 @@
|
|
|
189
249
|
/>
|
|
190
250
|
{/if}
|
|
191
251
|
|
|
192
|
-
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
252
|
+
<div class="flex justify-between items-center py-2 w-full">
|
|
253
|
+
<div>
|
|
254
|
+
{#if toggle}
|
|
255
|
+
<SlideToggle
|
|
256
|
+
name="slider-label"
|
|
257
|
+
active="bg-primary-500"
|
|
258
|
+
size="sm"
|
|
259
|
+
checked={fitToScreen}
|
|
260
|
+
id="{tableId}-toggle"
|
|
261
|
+
on:change={() => (fitToScreen = !fitToScreen)}>Fit to screen</SlideToggle
|
|
262
|
+
>
|
|
263
|
+
{/if}
|
|
264
|
+
</div>
|
|
265
|
+
<div>
|
|
266
|
+
{#if resizable !== 'none'}
|
|
267
|
+
<button
|
|
268
|
+
type="button"
|
|
269
|
+
class="btn btn-sm variant-filled-primary rounded-full order-last"
|
|
270
|
+
on:click|preventDefault={resetResize}>Reset sizing</button
|
|
271
|
+
>
|
|
272
|
+
{/if}
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
202
275
|
|
|
203
276
|
<div class="overflow-auto" style="height: {height}px">
|
|
204
277
|
<table
|
|
205
278
|
{...$tableAttrs}
|
|
206
|
-
class="table table-compact bg-tertiary-
|
|
279
|
+
class="table table-auto table-compact bg-tertiary-500/30 overflow-clip"
|
|
207
280
|
id="{tableId}-table"
|
|
208
281
|
>
|
|
209
|
-
<thead class={height != null ? `sticky top-0` : ''}>
|
|
282
|
+
<thead class=" {height != null ? `sticky top-0` : ''}">
|
|
210
283
|
{#each $headerRows as headerRow (headerRow.id)}
|
|
211
284
|
<Subscribe
|
|
212
285
|
rowAttrs={headerRow.attrs()}
|
|
@@ -214,11 +287,19 @@
|
|
|
214
287
|
rowProps={headerRow.props()}
|
|
215
288
|
let:rowProps
|
|
216
289
|
>
|
|
217
|
-
<tr {...rowAttrs} class="bg-primary-300">
|
|
290
|
+
<tr {...rowAttrs} class="bg-primary-300 items-stretch">
|
|
218
291
|
{#each headerRow.cells as cell (cell.id)}
|
|
219
292
|
<Subscribe attrs={cell.attrs()} props={cell.props()} let:props let:attrs>
|
|
220
|
-
<th
|
|
221
|
-
|
|
293
|
+
<th
|
|
294
|
+
scope="col"
|
|
295
|
+
class="!p-2 overflow-auto"
|
|
296
|
+
class:resize-x={(resizable === 'columns' || resizable === 'both') &&
|
|
297
|
+
!fixedWidth(cell.id)}
|
|
298
|
+
{...attrs}
|
|
299
|
+
id="th-{tableId}-{cell.id}"
|
|
300
|
+
style={cellStyle(cell.id)}
|
|
301
|
+
>
|
|
302
|
+
<div class="flex justify-between items-center">
|
|
222
303
|
<div class="flex gap-1 whitespace-pre-wrap">
|
|
223
304
|
<span
|
|
224
305
|
class:underline={props.sort.order}
|
|
@@ -258,18 +339,18 @@
|
|
|
258
339
|
<tbody class="overflow-auto" {...$tableBodyAttrs}>
|
|
259
340
|
{#each $pageRows as row (row.id)}
|
|
260
341
|
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
|
261
|
-
<tr {...rowAttrs} id="{tableId}-row-{row.id}">
|
|
262
|
-
{#each row.cells as cell (cell?.id)}
|
|
342
|
+
<tr {...rowAttrs} id="{tableId}-row-{row.id}" class="">
|
|
343
|
+
{#each row.cells as cell, index (cell?.id)}
|
|
263
344
|
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
264
345
|
<td
|
|
265
346
|
{...attrs}
|
|
266
|
-
class="!p-2
|
|
347
|
+
class="!p-2 overflow-auto {index === 0 &&
|
|
348
|
+
(resizable === 'rows' || resizable === 'both')
|
|
349
|
+
? 'resize-y'
|
|
350
|
+
: ''}"
|
|
267
351
|
id="{tableId}-{cell.id}-{row.id}"
|
|
268
352
|
>
|
|
269
|
-
<div
|
|
270
|
-
class="flex items-center h-max overflow-x-auto resize-none hover:resize"
|
|
271
|
-
class:max-w-md={!fitToScreen}
|
|
272
|
-
>
|
|
353
|
+
<div class="flex items-center h-max overflow-x-auto">
|
|
273
354
|
<Render of={cell.render()} />
|
|
274
355
|
</div>
|
|
275
356
|
</td>
|
|
@@ -105,12 +105,13 @@
|
|
|
105
105
|
placement: 'bottom-start'
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
let type: string = '';
|
|
108
|
+
let type: string = 'string';
|
|
109
109
|
let isDate = false;
|
|
110
110
|
|
|
111
111
|
$values.forEach((item) => {
|
|
112
112
|
if (item) {
|
|
113
113
|
type = typeof (toFilterableValueFn ? toFilterableValueFn(item) : item);
|
|
114
|
+
|
|
114
115
|
if (type === 'object') {
|
|
115
116
|
if (item instanceof Date) {
|
|
116
117
|
isDate = true;
|
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
import type { ColumnFilterFn } from 'svelte-headless-table/lib/plugins';
|
|
2
|
-
import type { TableFilterFn } from 'svelte-headless-table/lib/plugins/addTableFilter';
|
|
3
|
-
|
|
4
|
-
const textFilter = (filterOption, filterValue, value) => {
|
|
5
|
-
switch (filterOption) {
|
|
6
|
-
case 'isequal':
|
|
7
|
-
return value.toLowerCase() === filterValue.toLowerCase();
|
|
8
|
-
case 'isnotequal':
|
|
9
|
-
return value.toLowerCase() !== filterValue.toLowerCase();
|
|
10
|
-
case 'starts':
|
|
11
|
-
return value.toLowerCase().startsWith(filterValue.toLowerCase());
|
|
12
|
-
case 'ends':
|
|
13
|
-
return value.toLowerCase().endsWith(filterValue.toLowerCase());
|
|
14
|
-
case 'contains':
|
|
15
|
-
return value.toLowerCase().includes(filterValue.toLowerCase());
|
|
16
|
-
case 'notcontains':
|
|
17
|
-
return !value.toLowerCase().includes(filterValue.toLowerCase());
|
|
18
|
-
default:
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const numberFilter = (filterOption, filterValue, value) => {
|
|
24
|
-
switch (filterOption) {
|
|
25
|
-
case 'isequal':
|
|
26
|
-
return value === filterValue;
|
|
27
|
-
case 'isnotequal':
|
|
28
|
-
return value !== filterValue;
|
|
29
|
-
case 'isgreater':
|
|
30
|
-
return value > filterValue;
|
|
31
|
-
case 'isless':
|
|
32
|
-
return value < filterValue;
|
|
33
|
-
case 'isgreaterorequal':
|
|
34
|
-
return value >= filterValue;
|
|
35
|
-
case 'islessorequal':
|
|
36
|
-
return value <= filterValue;
|
|
37
|
-
default:
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const dateFilter = (filterOption, filterValue, value) => {
|
|
43
|
-
const filter = new Date(filterValue);
|
|
44
|
-
|
|
45
|
-
switch (filterOption) {
|
|
46
|
-
case 'ison':
|
|
47
|
-
return value === filter;
|
|
48
|
-
case 'isstartingfrom':
|
|
49
|
-
return value >= filter;
|
|
50
|
-
case 'isafter':
|
|
51
|
-
return value > filter;
|
|
52
|
-
case 'isuntil':
|
|
53
|
-
return value <= filter;
|
|
54
|
-
case 'isbefore':
|
|
55
|
-
return value < filter;
|
|
56
|
-
case 'isnoton':
|
|
57
|
-
return value !== filter;
|
|
58
|
-
default:
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const numericFilter: ColumnFilterFn = ({ filterValue, value }) => {
|
|
64
|
-
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
65
|
-
if (firstFilterValue == null && secondFilterValue == null) {
|
|
66
|
-
return true;
|
|
67
|
-
} else if (
|
|
68
|
-
(firstFilterOption == null || firstFilterValue == null) &&
|
|
69
|
-
secondFilterOption != null &&
|
|
70
|
-
secondFilterValue != null
|
|
71
|
-
) {
|
|
72
|
-
return numberFilter(secondFilterOption, secondFilterValue, value);
|
|
73
|
-
} else if (
|
|
74
|
-
(secondFilterOption == null || secondFilterValue == null) &&
|
|
75
|
-
firstFilterOption != null &&
|
|
76
|
-
firstFilterValue != null
|
|
77
|
-
) {
|
|
78
|
-
return numberFilter(firstFilterOption, firstFilterValue, value);
|
|
79
|
-
}
|
|
80
|
-
return (
|
|
81
|
-
numberFilter(firstFilterOption, firstFilterValue, value) &&
|
|
82
|
-
numberFilter(secondFilterOption, secondFilterValue, value)
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const stringFilter: ColumnFilterFn = ({ filterValue, value }) => {
|
|
87
|
-
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
88
|
-
if (!firstFilterValue?.length && !secondFilterValue?.length) {
|
|
89
|
-
return true;
|
|
90
|
-
} else if (
|
|
91
|
-
(!firstFilterOption || !firstFilterValue) &&
|
|
92
|
-
secondFilterOption &&
|
|
93
|
-
secondFilterValue?.length
|
|
94
|
-
) {
|
|
95
|
-
return textFilter(secondFilterOption, secondFilterValue, value);
|
|
96
|
-
} else if (
|
|
97
|
-
(!secondFilterOption || !secondFilterValue?.length) &&
|
|
98
|
-
firstFilterOption &&
|
|
99
|
-
firstFilterValue?.length
|
|
100
|
-
) {
|
|
101
|
-
return textFilter(firstFilterOption, firstFilterValue, value);
|
|
102
|
-
}
|
|
103
|
-
return (
|
|
104
|
-
textFilter(firstFilterOption, firstFilterValue, value) &&
|
|
105
|
-
textFilter(secondFilterOption, secondFilterValue, value)
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const dateTypeFilter: ColumnFilterFn = ({ filterValue, value }) => {
|
|
110
|
-
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
111
|
-
if (!firstFilterValue && !secondFilterValue) {
|
|
112
|
-
return true;
|
|
113
|
-
} else if ((!firstFilterOption || !firstFilterValue) && secondFilterOption && secondFilterValue) {
|
|
114
|
-
return dateFilter(secondFilterOption, secondFilterValue, value);
|
|
115
|
-
} else if ((!secondFilterOption || !secondFilterValue) && firstFilterOption && firstFilterValue) {
|
|
116
|
-
return dateFilter(firstFilterOption, firstFilterValue, value);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
dateFilter(firstFilterOption, firstFilterValue, value) &&
|
|
121
|
-
dateFilter(secondFilterOption, secondFilterValue, value)
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const columnFilter: ColumnFilterFn = ({ filterValue, value }) => {
|
|
126
|
-
if (typeof value === 'string') {
|
|
127
|
-
return stringFilter({ filterValue, value });
|
|
128
|
-
} else if (typeof value === 'number') {
|
|
129
|
-
return numericFilter({ filterValue, value });
|
|
130
|
-
} else if (typeof value === 'object' && value instanceof Date) {
|
|
131
|
-
return dateTypeFilter({ filterValue, value });
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export const searchFilter: TableFilterFn = ({ filterValue, value }) => {
|
|
137
|
-
if (value.toLowerCase().includes(filterValue.toLowerCase())) {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
return false;
|
|
141
|
-
};
|
|
1
|
+
import type { ColumnFilterFn } from 'svelte-headless-table/lib/plugins';
|
|
2
|
+
import type { TableFilterFn } from 'svelte-headless-table/lib/plugins/addTableFilter';
|
|
3
|
+
|
|
4
|
+
const textFilter = (filterOption, filterValue, value) => {
|
|
5
|
+
switch (filterOption) {
|
|
6
|
+
case 'isequal':
|
|
7
|
+
return value.toLowerCase() === filterValue.toLowerCase();
|
|
8
|
+
case 'isnotequal':
|
|
9
|
+
return value.toLowerCase() !== filterValue.toLowerCase();
|
|
10
|
+
case 'starts':
|
|
11
|
+
return value.toLowerCase().startsWith(filterValue.toLowerCase());
|
|
12
|
+
case 'ends':
|
|
13
|
+
return value.toLowerCase().endsWith(filterValue.toLowerCase());
|
|
14
|
+
case 'contains':
|
|
15
|
+
return value.toLowerCase().includes(filterValue.toLowerCase());
|
|
16
|
+
case 'notcontains':
|
|
17
|
+
return !value.toLowerCase().includes(filterValue.toLowerCase());
|
|
18
|
+
default:
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const numberFilter = (filterOption, filterValue, value) => {
|
|
24
|
+
switch (filterOption) {
|
|
25
|
+
case 'isequal':
|
|
26
|
+
return value === filterValue;
|
|
27
|
+
case 'isnotequal':
|
|
28
|
+
return value !== filterValue;
|
|
29
|
+
case 'isgreater':
|
|
30
|
+
return value > filterValue;
|
|
31
|
+
case 'isless':
|
|
32
|
+
return value < filterValue;
|
|
33
|
+
case 'isgreaterorequal':
|
|
34
|
+
return value >= filterValue;
|
|
35
|
+
case 'islessorequal':
|
|
36
|
+
return value <= filterValue;
|
|
37
|
+
default:
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const dateFilter = (filterOption, filterValue, value) => {
|
|
43
|
+
const filter = new Date(filterValue);
|
|
44
|
+
|
|
45
|
+
switch (filterOption) {
|
|
46
|
+
case 'ison':
|
|
47
|
+
return value === filter;
|
|
48
|
+
case 'isstartingfrom':
|
|
49
|
+
return value >= filter;
|
|
50
|
+
case 'isafter':
|
|
51
|
+
return value > filter;
|
|
52
|
+
case 'isuntil':
|
|
53
|
+
return value <= filter;
|
|
54
|
+
case 'isbefore':
|
|
55
|
+
return value < filter;
|
|
56
|
+
case 'isnoton':
|
|
57
|
+
return value !== filter;
|
|
58
|
+
default:
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const numericFilter: ColumnFilterFn = ({ filterValue, value }) => {
|
|
64
|
+
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
65
|
+
if (firstFilterValue == null && secondFilterValue == null) {
|
|
66
|
+
return true;
|
|
67
|
+
} else if (
|
|
68
|
+
(firstFilterOption == null || firstFilterValue == null) &&
|
|
69
|
+
secondFilterOption != null &&
|
|
70
|
+
secondFilterValue != null
|
|
71
|
+
) {
|
|
72
|
+
return numberFilter(secondFilterOption, secondFilterValue, value);
|
|
73
|
+
} else if (
|
|
74
|
+
(secondFilterOption == null || secondFilterValue == null) &&
|
|
75
|
+
firstFilterOption != null &&
|
|
76
|
+
firstFilterValue != null
|
|
77
|
+
) {
|
|
78
|
+
return numberFilter(firstFilterOption, firstFilterValue, value);
|
|
79
|
+
}
|
|
80
|
+
return (
|
|
81
|
+
numberFilter(firstFilterOption, firstFilterValue, value) &&
|
|
82
|
+
numberFilter(secondFilterOption, secondFilterValue, value)
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const stringFilter: ColumnFilterFn = ({ filterValue, value }) => {
|
|
87
|
+
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
88
|
+
if (!firstFilterValue?.length && !secondFilterValue?.length) {
|
|
89
|
+
return true;
|
|
90
|
+
} else if (
|
|
91
|
+
(!firstFilterOption || !firstFilterValue) &&
|
|
92
|
+
secondFilterOption &&
|
|
93
|
+
secondFilterValue?.length
|
|
94
|
+
) {
|
|
95
|
+
return textFilter(secondFilterOption, secondFilterValue, value);
|
|
96
|
+
} else if (
|
|
97
|
+
(!secondFilterOption || !secondFilterValue?.length) &&
|
|
98
|
+
firstFilterOption &&
|
|
99
|
+
firstFilterValue?.length
|
|
100
|
+
) {
|
|
101
|
+
return textFilter(firstFilterOption, firstFilterValue, value);
|
|
102
|
+
}
|
|
103
|
+
return (
|
|
104
|
+
textFilter(firstFilterOption, firstFilterValue, value) &&
|
|
105
|
+
textFilter(secondFilterOption, secondFilterValue, value)
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const dateTypeFilter: ColumnFilterFn = ({ filterValue, value }) => {
|
|
110
|
+
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
111
|
+
if (!firstFilterValue && !secondFilterValue) {
|
|
112
|
+
return true;
|
|
113
|
+
} else if ((!firstFilterOption || !firstFilterValue) && secondFilterOption && secondFilterValue) {
|
|
114
|
+
return dateFilter(secondFilterOption, secondFilterValue, value);
|
|
115
|
+
} else if ((!secondFilterOption || !secondFilterValue) && firstFilterOption && firstFilterValue) {
|
|
116
|
+
return dateFilter(firstFilterOption, firstFilterValue, value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
dateFilter(firstFilterOption, firstFilterValue, value) &&
|
|
121
|
+
dateFilter(secondFilterOption, secondFilterValue, value)
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const columnFilter: ColumnFilterFn = ({ filterValue, value }) => {
|
|
126
|
+
if (typeof value === 'string') {
|
|
127
|
+
return stringFilter({ filterValue, value });
|
|
128
|
+
} else if (typeof value === 'number') {
|
|
129
|
+
return numericFilter({ filterValue, value });
|
|
130
|
+
} else if (typeof value === 'object' && value instanceof Date) {
|
|
131
|
+
return dateTypeFilter({ filterValue, value });
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const searchFilter: TableFilterFn = ({ filterValue, value }) => {
|
|
137
|
+
if (value.toLowerCase().includes(filterValue.toLowerCase())) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
};
|
|
@@ -1,45 +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}
|
|
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}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import FileIcon from './FileIcon.svelte';
|
|
3
|
-
|
|
4
|
-
export let name = '';
|
|
5
|
-
export let type = '';
|
|
6
|
-
// export let description;
|
|
7
|
-
export let size = '';
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<div style="font-size:{size}">
|
|
11
|
-
<FileIcon {type} />
|
|
12
|
-
{name}
|
|
13
|
-
</div>
|
|
1
|
+
<script>
|
|
2
|
+
import FileIcon from './FileIcon.svelte';
|
|
3
|
+
|
|
4
|
+
export let name = '';
|
|
5
|
+
export let type = '';
|
|
6
|
+
// export let description;
|
|
7
|
+
export let size = '';
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div style="font-size:{size}">
|
|
11
|
+
<FileIcon {type} />
|
|
12
|
+
{name}
|
|
13
|
+
</div>
|
|
@@ -148,11 +148,10 @@
|
|
|
148
148
|
|
|
149
149
|
let message = files.accepted.length + ' is/are uploaded';
|
|
150
150
|
|
|
151
|
-
let fileList:string[] = [];
|
|
152
|
-
files.accepted.forEach(f => fileList.push(f.name))
|
|
151
|
+
let fileList: string[] = [];
|
|
152
|
+
files.accepted.forEach((f) => fileList.push(f.name));
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
dispatch('success', { text: message , files: fileList});
|
|
154
|
+
dispatch('success', { text: message, files: fileList });
|
|
156
155
|
|
|
157
156
|
files.accepted = [];
|
|
158
157
|
}
|