@lavalogic/scoria 0.16.2 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Components/Table/Body/Rows/TableRow.svelte +30 -29
- package/dist/Components/Table/Body/Rows/TableRow.svelte.d.ts +2 -10
- package/dist/Components/Table/Body/TableBody.svelte +32 -21
- package/dist/Components/Table/Body/TableBody.svelte.d.ts +2 -10
- package/dist/Components/Table/Body/TableBodyProps.d.ts +0 -2
- package/dist/Components/Table/Table.svelte +107 -67
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +2 -2
- package/dist/Components/Table/Types/Columns/DefsWrapper.d.ts +2 -2
- package/dist/Components/Table/Types/Context/TableContext.svelte.js +31 -31
- package/package.json +1 -1
|
@@ -94,35 +94,36 @@
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
let
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
$effect(() => {
|
|
106
|
-
void trRef;
|
|
107
|
-
return untrack(() => {
|
|
108
|
-
if (trRef) {
|
|
109
|
-
const observer = new ResizeObserver((entries) => {
|
|
110
|
-
if (customHeight) {
|
|
111
|
-
_trHeight = 0;
|
|
112
|
-
} else {
|
|
113
|
-
_trHeight = entries[0].borderBoxSize[0].blockSize;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
observer.observe(trRef);
|
|
97
|
+
//FIXME the below threw errors before. Please investigate
|
|
98
|
+
// let trRef: HTMLTableRowElement | undefined = $state();
|
|
99
|
+
// let _trHeight = $state(0);
|
|
100
|
+
// export const trHeight = {
|
|
101
|
+
// get value() {
|
|
102
|
+
// return _trHeight;
|
|
103
|
+
// },
|
|
104
|
+
// };
|
|
117
105
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
106
|
+
// $effect(() => {
|
|
107
|
+
// void trRef;
|
|
108
|
+
// return untrack(() => {
|
|
109
|
+
// if (trRef) {
|
|
110
|
+
// const observer = new ResizeObserver((entries) => {
|
|
111
|
+
// if (customHeight) {
|
|
112
|
+
// _trHeight = 0;
|
|
113
|
+
// } else {
|
|
114
|
+
// _trHeight = entries[0].borderBoxSize[0].blockSize;
|
|
115
|
+
// }
|
|
116
|
+
// });
|
|
117
|
+
// observer.observe(trRef);
|
|
118
|
+
|
|
119
|
+
// const currentTrRef = trRef;
|
|
120
|
+
// return () => {
|
|
121
|
+
// observer.unobserve(currentTrRef);
|
|
122
|
+
// };
|
|
123
|
+
// }
|
|
124
|
+
// return () => {};
|
|
125
|
+
// });
|
|
126
|
+
// });
|
|
126
127
|
|
|
127
128
|
// let innerTrRef: HTMLTableRowElement | undefined = $state();
|
|
128
129
|
// let _innerTrHeight = $state(0);
|
|
@@ -151,8 +152,8 @@ onMouseLeave={onMouseLeave} -->
|
|
|
151
152
|
class:alt={tableContext.alternateRowColours && odd}
|
|
152
153
|
class:highlighted
|
|
153
154
|
style={customHeight ? `height: ${customHeight}px !important;` : null}
|
|
154
|
-
bind:this={trRef}
|
|
155
155
|
>
|
|
156
|
+
<!-- bind:this={trRef} -->
|
|
156
157
|
{#if showHighlightButton}
|
|
157
158
|
<ColumnHighlight
|
|
158
159
|
rowIndex={rowIndex ??
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { TableRowProps } from './TableRowProps.js';
|
|
2
2
|
declare function $$render<T extends object>(): {
|
|
3
3
|
props: TableRowProps<T>;
|
|
4
|
-
exports: {
|
|
5
|
-
trHeight: {
|
|
6
|
-
readonly value: number;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
4
|
+
exports: {};
|
|
9
5
|
bindings: "";
|
|
10
6
|
slots: {};
|
|
11
7
|
events: {};
|
|
@@ -15,11 +11,7 @@ declare class __sveltets_Render<T extends object> {
|
|
|
15
11
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
16
12
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
17
13
|
bindings(): "";
|
|
18
|
-
exports(): {
|
|
19
|
-
trHeight: {
|
|
20
|
-
readonly value: number;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
14
|
+
exports(): {};
|
|
23
15
|
}
|
|
24
16
|
interface $$IsomorphicComponent {
|
|
25
17
|
new <T extends object>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
<svelte:options runes />
|
|
2
2
|
|
|
3
|
-
<script
|
|
4
|
-
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object"
|
|
6
|
+
>
|
|
5
7
|
import { getContext } from 'svelte';
|
|
6
8
|
import { TableContext } from '../Types/Context/TableContext.svelte.js';
|
|
7
9
|
import QuickSearchCell from './QuickSearchCell.svelte';
|
|
8
10
|
import TableRow from './Rows/TableRow.svelte';
|
|
9
11
|
import type { TableBodyProps } from './TableBodyProps.js';
|
|
10
12
|
|
|
11
|
-
let {
|
|
13
|
+
let {
|
|
14
|
+
side,
|
|
15
|
+
// heights,
|
|
16
|
+
columns,
|
|
17
|
+
includeHighlight,
|
|
18
|
+
}: TableBodyProps<T> = $props();
|
|
12
19
|
|
|
13
20
|
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
14
21
|
|
|
15
|
-
type HasHeight = {
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
const rows: Array<TableRow<T>> = $state([]);
|
|
19
|
-
const _rowHeights = $derived(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
-
export const rowHeights = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
22
|
+
// type HasHeight = {
|
|
23
|
+
// trHeight: RefWrapper<number>;
|
|
24
|
+
// };
|
|
25
|
+
// const rows: Array<TableRow<T>> = $state([]);
|
|
26
|
+
// const _rowHeights = $derived(
|
|
27
|
+
// // HACK terrible type casting due to svelte type gen not being liked by eslint
|
|
28
|
+
// rows.map((it) => (it as HasHeight | undefined)?.trHeight.value ?? 0)
|
|
29
|
+
// );
|
|
30
|
+
// export const rowHeights = {
|
|
31
|
+
// get value() {
|
|
32
|
+
// return _rowHeights;
|
|
33
|
+
// }
|
|
34
|
+
// };
|
|
28
35
|
</script>
|
|
29
36
|
|
|
30
37
|
<tbody>
|
|
@@ -34,24 +41,28 @@
|
|
|
34
41
|
<td class="highlight-dud"><!-- accomodating for row marking --></td>
|
|
35
42
|
{/if}
|
|
36
43
|
{#each columns as column (column.id)}
|
|
37
|
-
<QuickSearchCell
|
|
44
|
+
<QuickSearchCell
|
|
45
|
+
{column}
|
|
46
|
+
customFilters={tableContext.remoteFilters}
|
|
47
|
+
/>
|
|
38
48
|
{/each}
|
|
39
49
|
</tr>
|
|
40
50
|
{/if}
|
|
41
51
|
<svelte:boundary>
|
|
42
52
|
{#await tableContext.paginationRowModel then prm}
|
|
43
53
|
{#each prm.rows as row, index (row)}
|
|
44
|
-
{@const customHeight = heights[index]?.applyTo.includes(side)
|
|
54
|
+
<!-- {@const customHeight = heights[index]?.applyTo.includes(side)
|
|
45
55
|
? heights[index].maxHeight
|
|
46
|
-
: undefined}
|
|
56
|
+
: undefined} -->
|
|
57
|
+
<!-- {customHeight} -->
|
|
47
58
|
<TableRow
|
|
59
|
+
customHeight={undefined}
|
|
48
60
|
{includeHighlight}
|
|
49
|
-
{customHeight}
|
|
50
61
|
{row}
|
|
51
62
|
{side}
|
|
52
63
|
odd={index % 2 == 1}
|
|
53
|
-
bind:this={rows[index]}
|
|
54
64
|
/>
|
|
65
|
+
<!-- bind:this={rows[index]} -->
|
|
55
66
|
{/each}
|
|
56
67
|
{/await}
|
|
57
68
|
</svelte:boundary>
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { TableBodyProps } from './TableBodyProps.js';
|
|
2
2
|
declare function $$render<T extends object>(): {
|
|
3
3
|
props: TableBodyProps<T>;
|
|
4
|
-
exports: {
|
|
5
|
-
rowHeights: {
|
|
6
|
-
readonly value: number[];
|
|
7
|
-
};
|
|
8
|
-
};
|
|
4
|
+
exports: {};
|
|
9
5
|
bindings: "";
|
|
10
6
|
slots: {};
|
|
11
7
|
events: {};
|
|
@@ -15,11 +11,7 @@ declare class __sveltets_Render<T extends object> {
|
|
|
15
11
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
16
12
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
17
13
|
bindings(): "";
|
|
18
|
-
exports(): {
|
|
19
|
-
rowHeights: {
|
|
20
|
-
readonly value: number[];
|
|
21
|
-
};
|
|
22
|
-
};
|
|
14
|
+
exports(): {};
|
|
23
15
|
}
|
|
24
16
|
interface $$IsomorphicComponent {
|
|
25
17
|
new <T extends object>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Column } from '../Types/Columns/Column.js';
|
|
2
|
-
import type { HeightData } from './HeightData.js';
|
|
3
2
|
export interface TableBodyProps<T extends object> {
|
|
4
3
|
side: 'left' | 'centre' | 'right';
|
|
5
|
-
heights: Array<HeightData<T>>;
|
|
6
4
|
columns: Array<Column<T>>;
|
|
7
5
|
includeHighlight: boolean;
|
|
8
6
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<svelte:options runes />
|
|
2
2
|
|
|
3
|
-
<script
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
module
|
|
6
|
+
>
|
|
4
7
|
import {
|
|
5
8
|
ContextMenuContext,
|
|
6
|
-
type IContextMenuOption
|
|
9
|
+
type IContextMenuOption,
|
|
7
10
|
} from '../../Contexts/ContextMenuContext.svelte';
|
|
8
11
|
import { devCatch, refWrapper } from '../../Helpers/Helpers.svelte';
|
|
9
12
|
import type { RefWrapper } from '../../Types/Internal/RefWrapper.js';
|
|
10
13
|
import { getContext, onMount, setContext, tick, untrack } from 'svelte';
|
|
11
14
|
import LoadingOverlay from '../LoadingOverlay.svelte';
|
|
12
|
-
import type { HeightData } from './Body/HeightData.js';
|
|
13
15
|
import { shownPopup } from './Body/Rows/Columns/ActionsCell.svelte';
|
|
14
16
|
import TableBody from './Body/TableBody.svelte';
|
|
15
17
|
import TableHead from './Headers/TableHead.svelte';
|
|
@@ -39,7 +41,10 @@
|
|
|
39
41
|
const openedQuickFilterSelect = refWrapper(null);
|
|
40
42
|
</script>
|
|
41
43
|
|
|
42
|
-
<script
|
|
44
|
+
<script
|
|
45
|
+
lang="ts"
|
|
46
|
+
generics="T extends object,IdType extends Primitive"
|
|
47
|
+
>
|
|
43
48
|
const { nested = false, tableContext }: TableProps<T, IdType> = $props();
|
|
44
49
|
|
|
45
50
|
// NOTE: known limitation. This is passed as a wrapper, and they should never require reassignment. It is deeply reactive
|
|
@@ -78,7 +83,7 @@
|
|
|
78
83
|
element?.scrollIntoView({
|
|
79
84
|
behavior: 'instant',
|
|
80
85
|
block: 'nearest',
|
|
81
|
-
inline: 'nearest'
|
|
86
|
+
inline: 'nearest',
|
|
82
87
|
});
|
|
83
88
|
}
|
|
84
89
|
});
|
|
@@ -94,7 +99,7 @@
|
|
|
94
99
|
cell?.scrollIntoView({
|
|
95
100
|
behavior: 'instant',
|
|
96
101
|
block: 'nearest',
|
|
97
|
-
inline: 'nearest'
|
|
102
|
+
inline: 'nearest',
|
|
98
103
|
});
|
|
99
104
|
}
|
|
100
105
|
});
|
|
@@ -137,7 +142,7 @@
|
|
|
137
142
|
tableContext.moveFocus({
|
|
138
143
|
column: columnIndex,
|
|
139
144
|
row,
|
|
140
|
-
id: columnId
|
|
145
|
+
id: columnId,
|
|
141
146
|
});
|
|
142
147
|
}
|
|
143
148
|
}
|
|
@@ -153,8 +158,8 @@
|
|
|
153
158
|
callback: () => {
|
|
154
159
|
tableContext.copyDataToClipboard().catch(devCatch);
|
|
155
160
|
},
|
|
156
|
-
text: 'Copy Selection'
|
|
157
|
-
}
|
|
161
|
+
text: 'Copy Selection',
|
|
162
|
+
},
|
|
158
163
|
];
|
|
159
164
|
|
|
160
165
|
if (tableContext.hasHighlightedItems) {
|
|
@@ -162,7 +167,7 @@
|
|
|
162
167
|
callback: () => {
|
|
163
168
|
tableContext.copyHighlightedRowsToClipboard().catch(devCatch);
|
|
164
169
|
},
|
|
165
|
-
text: 'Copy Highlighted Rows'
|
|
170
|
+
text: 'Copy Highlighted Rows',
|
|
166
171
|
});
|
|
167
172
|
}
|
|
168
173
|
|
|
@@ -284,46 +289,46 @@
|
|
|
284
289
|
}
|
|
285
290
|
});
|
|
286
291
|
|
|
287
|
-
type SvelteTableElement = {
|
|
288
|
-
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
let leftTable: SvelteTableElement | undefined = $state();
|
|
292
|
-
let centreTable: SvelteTableElement | undefined = $state();
|
|
293
|
-
let rightTable: SvelteTableElement | undefined = $state();
|
|
294
|
-
|
|
295
|
-
const totalRowSizes: Array<HeightData<T>> = $derived.by(() => {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
});
|
|
292
|
+
// type SvelteTableElement = {
|
|
293
|
+
// rowHeights: RefWrapper<Array<number>>;
|
|
294
|
+
// };
|
|
295
|
+
|
|
296
|
+
// let leftTable: SvelteTableElement | undefined = $state();
|
|
297
|
+
// let centreTable: SvelteTableElement | undefined = $state();
|
|
298
|
+
// let rightTable: SvelteTableElement | undefined = $state();
|
|
299
|
+
|
|
300
|
+
// const totalRowSizes: Array<HeightData<T>> = $derived.by(() => {
|
|
301
|
+
// if (!leftTable || !centreTable || !rightTable) {
|
|
302
|
+
// return [];
|
|
303
|
+
// }
|
|
304
|
+
// const centre = centreTable.rowHeights.value;
|
|
305
|
+
// const right = rightTable.rowHeights.value;
|
|
306
|
+
|
|
307
|
+
// return leftTable.rowHeights.value.map((_leftHeight, index) => {
|
|
308
|
+
// const leftHeight = _leftHeight || 0;
|
|
309
|
+
// const centreHeight = centre[index] || 0;
|
|
310
|
+
// const rightHeight = right[index] || 0;
|
|
311
|
+
|
|
312
|
+
// const maxHeight = Math.max(leftHeight, centreHeight, rightHeight);
|
|
313
|
+
// const applyTo: HeightData<T>['applyTo'] = [];
|
|
314
|
+
|
|
315
|
+
// if (leftHeight < maxHeight) {
|
|
316
|
+
// applyTo.push('left');
|
|
317
|
+
// }
|
|
318
|
+
// if (centreHeight < maxHeight) {
|
|
319
|
+
// applyTo.push('centre');
|
|
320
|
+
// }
|
|
321
|
+
// if (rightHeight < maxHeight) {
|
|
322
|
+
// applyTo.push('right');
|
|
323
|
+
// }
|
|
324
|
+
|
|
325
|
+
// return {
|
|
326
|
+
// index,
|
|
327
|
+
// applyTo,
|
|
328
|
+
// maxHeight
|
|
329
|
+
// };
|
|
330
|
+
// });
|
|
331
|
+
// });
|
|
327
332
|
</script>
|
|
328
333
|
|
|
329
334
|
<svelte:window
|
|
@@ -356,12 +361,21 @@
|
|
|
356
361
|
/>
|
|
357
362
|
|
|
358
363
|
<svelte:boundary>
|
|
359
|
-
<div
|
|
364
|
+
<div
|
|
365
|
+
class="grid"
|
|
366
|
+
class:nested
|
|
367
|
+
>
|
|
360
368
|
{#if tableContext.dataRepo.isLoading}
|
|
361
|
-
<LoadingOverlay
|
|
369
|
+
<LoadingOverlay
|
|
370
|
+
absolute
|
|
371
|
+
borderRadius="4px"
|
|
372
|
+
/>
|
|
362
373
|
{/if}
|
|
363
374
|
|
|
364
|
-
<div
|
|
375
|
+
<div
|
|
376
|
+
class="horizontal-bar"
|
|
377
|
+
class:border={tableContext.toolbarPosition === ToolbarPosition.Top}
|
|
378
|
+
>
|
|
365
379
|
{#if tableContext.toolbarPosition === ToolbarPosition.Top}
|
|
366
380
|
<TableHorizontalBar />
|
|
367
381
|
{/if}
|
|
@@ -405,45 +419,71 @@
|
|
|
405
419
|
class:quick-filtering={tableContext.showQuickFiltering}
|
|
406
420
|
onkeydown={tableContext.handleTdKeydown}
|
|
407
421
|
>
|
|
408
|
-
<div
|
|
409
|
-
|
|
422
|
+
<div
|
|
423
|
+
class="flex_table"
|
|
424
|
+
bind:this={ref}
|
|
425
|
+
class:nested
|
|
426
|
+
>
|
|
427
|
+
<div
|
|
428
|
+
bind:this={unfocusRef}
|
|
429
|
+
class="table-wrapper"
|
|
430
|
+
oncontextmenu={openContextMenu}
|
|
431
|
+
>
|
|
410
432
|
<!-- {#if leftTotalSize > 0} -->
|
|
411
|
-
<table
|
|
412
|
-
|
|
433
|
+
<table
|
|
434
|
+
class="datatable__table left"
|
|
435
|
+
style="min-width: {leftTotalSize}px"
|
|
436
|
+
>
|
|
437
|
+
<TableHead
|
|
438
|
+
showHighlight={leftTotalSize > 0}
|
|
439
|
+
side="left"
|
|
440
|
+
/>
|
|
413
441
|
<TableBody
|
|
414
442
|
includeHighlight={appropriateSide == 'left'}
|
|
415
443
|
columns={leftColumns}
|
|
416
|
-
heights={totalRowSizes}
|
|
417
444
|
side="left"
|
|
418
|
-
bind:this={leftTable}
|
|
419
445
|
/>
|
|
446
|
+
<!-- heights={totalRowSizes} -->
|
|
447
|
+
<!-- bind:this={leftTable} -->
|
|
420
448
|
</table>
|
|
421
449
|
<!-- {/if} -->
|
|
422
450
|
|
|
423
451
|
<!-- {#if centreTotalSize > 0} -->
|
|
424
452
|
|
|
425
|
-
<table
|
|
426
|
-
|
|
453
|
+
<table
|
|
454
|
+
class="datatable__table centre"
|
|
455
|
+
style="min-width: {centreTotalSize}px"
|
|
456
|
+
>
|
|
457
|
+
<TableHead
|
|
458
|
+
showHighlight={leftTotalSize == 0}
|
|
459
|
+
side="centre"
|
|
460
|
+
/>
|
|
427
461
|
<TableBody
|
|
428
462
|
includeHighlight={appropriateSide == 'centre'}
|
|
429
463
|
columns={centreColumns}
|
|
430
|
-
heights={totalRowSizes}
|
|
431
464
|
side="centre"
|
|
432
|
-
bind:this={centreTable}
|
|
433
465
|
/>
|
|
466
|
+
<!-- heights={totalRowSizes}
|
|
467
|
+
bind:this={centreTable} -->
|
|
434
468
|
</table>
|
|
435
469
|
<!-- {/if} -->
|
|
436
470
|
|
|
437
471
|
<!-- {#if rightTotalSize > 0} -->
|
|
438
|
-
<table
|
|
439
|
-
|
|
472
|
+
<table
|
|
473
|
+
class="datatable__table right"
|
|
474
|
+
style="min-width: {rightTotalSize}px"
|
|
475
|
+
>
|
|
476
|
+
<TableHead
|
|
477
|
+
showHighlight={false}
|
|
478
|
+
side="right"
|
|
479
|
+
/>
|
|
440
480
|
<TableBody
|
|
441
481
|
includeHighlight={appropriateSide == 'right'}
|
|
442
482
|
columns={rightColumns}
|
|
443
|
-
heights={totalRowSizes}
|
|
444
483
|
side="right"
|
|
445
|
-
bind:this={rightTable}
|
|
446
484
|
/>
|
|
485
|
+
<!-- heights={totalRowSizes}
|
|
486
|
+
bind:this={rightTable} -->
|
|
447
487
|
</table>
|
|
448
488
|
<!-- {/if} -->
|
|
449
489
|
</div>
|
|
@@ -8,12 +8,12 @@ export interface ExpandDefProps<T extends object, R extends object, InnterIdType
|
|
|
8
8
|
headerIcon: IconProps['name'];
|
|
9
9
|
innerTableName: string;
|
|
10
10
|
innerTableOptions: TableInitOptions<R, InnterIdType>;
|
|
11
|
-
accessorFn: (item: T, index: number) =>
|
|
11
|
+
accessorFn: (item: T, index: number) => ReadonlyArray<R> | Promise<ReadonlyArray<R>>;
|
|
12
12
|
}
|
|
13
13
|
export declare class ExpandDef<T extends object, R extends object, InnterIdType extends Primitive = Primitive, in FilterValueType = unknown, out OptionsValueType = unknown> extends ColumnDef<T, FilterValueType, OptionsValueType> {
|
|
14
14
|
readonly columnType: "Expand";
|
|
15
15
|
constructor(props: ExpandDefProps<T, R, InnterIdType, FilterValueType, OptionsValueType>);
|
|
16
|
-
readonly accessorFn: (item: T, index: number) =>
|
|
16
|
+
readonly accessorFn: (item: T, index: number) => ReadonlyArray<R> | Promise<ReadonlyArray<R>>;
|
|
17
17
|
readonly filterFn: undefined;
|
|
18
18
|
readonly innerTableName: string;
|
|
19
19
|
readonly getInnerColumnDefs: (item: T, index: number) => DefsWrapper<R>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CustomRemoteFilters } from '../Filtering/CustomRemoteFilters.js';
|
|
2
2
|
import type { ColumnDef } from './Definitions/ColumnDef.svelte.js';
|
|
3
|
-
export interface DefsWrapper<T extends object> {
|
|
4
|
-
defs: Array<ColumnDef<T,
|
|
3
|
+
export interface DefsWrapper<T extends object, in FilterValueType = unknown> {
|
|
4
|
+
defs: Array<ColumnDef<T, FilterValueType>>;
|
|
5
5
|
remoteFilters?: CustomRemoteFilters<unknown>;
|
|
6
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { browser, dev } from '$app/environment';
|
|
2
|
-
import { asyncAll, asyncFilterIndices, asyncForEach, asyncMap, asyncSleep, devCatch, getCanvasContext, getErrorMessage } from '../../../../Helpers/Helpers.svelte.js';
|
|
2
|
+
import { asyncAll, asyncFilterIndices, asyncForEach, asyncMap, asyncSleep, devCatch, getCanvasContext, getErrorMessage, } from '../../../../Helpers/Helpers.svelte.js';
|
|
3
3
|
import { tick, untrack } from 'svelte';
|
|
4
4
|
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
5
5
|
import { ColumnType } from '../Columns/ColumnType.js';
|
|
@@ -23,7 +23,7 @@ const uncopyableColumns = new Set([
|
|
|
23
23
|
ColumnType.Expand,
|
|
24
24
|
ColumnType.Actions,
|
|
25
25
|
ColumnType.FilterOnly,
|
|
26
|
-
ColumnType.Custom
|
|
26
|
+
ColumnType.Custom,
|
|
27
27
|
]);
|
|
28
28
|
export class TableContext {
|
|
29
29
|
defaultColumnDefs;
|
|
@@ -106,7 +106,7 @@ export class TableContext {
|
|
|
106
106
|
columnDefs: this.columnDefs,
|
|
107
107
|
sortingState: [],
|
|
108
108
|
visibilityState,
|
|
109
|
-
columnPinningState: {}
|
|
109
|
+
columnPinningState: {},
|
|
110
110
|
};
|
|
111
111
|
this.selectedPreset = defaultPreset;
|
|
112
112
|
this.columnVisibility = visibilityState;
|
|
@@ -665,7 +665,7 @@ export class TableContext {
|
|
|
665
665
|
return {
|
|
666
666
|
rows,
|
|
667
667
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
668
|
-
rowsById: new Map(rows.map((it, index) => [index.toString(), it])) //FIXME should this be by sorted id or by original id?
|
|
668
|
+
rowsById: new Map(rows.map((it, index) => [index.toString(), it])), //FIXME should this be by sorted id or by original id?
|
|
669
669
|
};
|
|
670
670
|
});
|
|
671
671
|
currentPageData = $derived.by(async () => {
|
|
@@ -709,7 +709,7 @@ export class TableContext {
|
|
|
709
709
|
id: index.toString(),
|
|
710
710
|
getLeftVisibleCells: () => leftVisibleCells,
|
|
711
711
|
getRightVisibleCells: () => rightVisibleCells,
|
|
712
|
-
getCenterVisibleCells: () => centerVisibleCells
|
|
712
|
+
getCenterVisibleCells: () => centerVisibleCells,
|
|
713
713
|
};
|
|
714
714
|
const makeRow = (def) => {
|
|
715
715
|
const isSorted = $derived.by(() => {
|
|
@@ -731,7 +731,7 @@ export class TableContext {
|
|
|
731
731
|
getIsSorted: () => isSorted,
|
|
732
732
|
getIsVisible: () => isVisible,
|
|
733
733
|
getToggleSortingHandler: () => def.allowSorting ? this.getToggleSortingHandler(def) : undefined,
|
|
734
|
-
id: def.id
|
|
734
|
+
id: def.id,
|
|
735
735
|
},
|
|
736
736
|
id: `${index}_${def.id}`,
|
|
737
737
|
row: row,
|
|
@@ -741,7 +741,7 @@ export class TableContext {
|
|
|
741
741
|
return gotValue;
|
|
742
742
|
}
|
|
743
743
|
return item[def.id];
|
|
744
|
-
}
|
|
744
|
+
},
|
|
745
745
|
};
|
|
746
746
|
};
|
|
747
747
|
const makeCellFromId = (columnId) => {
|
|
@@ -763,7 +763,7 @@ export class TableContext {
|
|
|
763
763
|
return {
|
|
764
764
|
rows,
|
|
765
765
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
766
|
-
rowsById: new Map(rows.map((it, index) => [index.toString(), it])) //FIXME should this be by sorted id or by original id?
|
|
766
|
+
rowsById: new Map(rows.map((it, index) => [index.toString(), it])), //FIXME should this be by sorted id or by original id?
|
|
767
767
|
};
|
|
768
768
|
});
|
|
769
769
|
// #endregion
|
|
@@ -1272,7 +1272,7 @@ export class TableContext {
|
|
|
1272
1272
|
}
|
|
1273
1273
|
return this._performRowCopy(await this.getFocusElementData());
|
|
1274
1274
|
};
|
|
1275
|
-
_performRowCopy = async ({ items, indicesByItem, focusedElementData, affectedColumns }) => {
|
|
1275
|
+
_performRowCopy = async ({ items, indicesByItem, focusedElementData, affectedColumns, }) => {
|
|
1276
1276
|
const focusedColumnIds = affectedColumns.map((it) => encapsulate(typeof it.header === 'string' ? it.header : it.id));
|
|
1277
1277
|
const value = await (async () => {
|
|
1278
1278
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
@@ -1674,8 +1674,8 @@ export class TableContext {
|
|
|
1674
1674
|
...preset,
|
|
1675
1675
|
columnPinningState: {
|
|
1676
1676
|
left: [...(preset.columnPinningState.left?.entries() ?? [])],
|
|
1677
|
-
right: [...(preset.columnPinningState.right?.entries() ?? [])]
|
|
1678
|
-
}
|
|
1677
|
+
right: [...(preset.columnPinningState.right?.entries() ?? [])],
|
|
1678
|
+
},
|
|
1679
1679
|
};
|
|
1680
1680
|
});
|
|
1681
1681
|
const stringified = JSON.stringify(jsonFriendly);
|
|
@@ -1707,7 +1707,7 @@ export class TableContext {
|
|
|
1707
1707
|
id: index.toString(),
|
|
1708
1708
|
getLeftVisibleCells: () => leftVisibleCells,
|
|
1709
1709
|
getRightVisibleCells: () => rightVisibleCells,
|
|
1710
|
-
getCenterVisibleCells: () => centerVisibleCells
|
|
1710
|
+
getCenterVisibleCells: () => centerVisibleCells,
|
|
1711
1711
|
};
|
|
1712
1712
|
const makeRow = (def) => {
|
|
1713
1713
|
const isVisible = $derived(this.columnVisibility[def.id] != false);
|
|
@@ -1729,7 +1729,7 @@ export class TableContext {
|
|
|
1729
1729
|
getIsSorted: () => isSorted,
|
|
1730
1730
|
getIsVisible: () => isVisible,
|
|
1731
1731
|
getToggleSortingHandler: () => def.allowSorting ? this.getToggleSortingHandler(def) : undefined,
|
|
1732
|
-
id: def.id
|
|
1732
|
+
id: def.id,
|
|
1733
1733
|
},
|
|
1734
1734
|
id: `${index}_${def.id}`,
|
|
1735
1735
|
row: row,
|
|
@@ -1739,7 +1739,7 @@ export class TableContext {
|
|
|
1739
1739
|
return gotValue;
|
|
1740
1740
|
}
|
|
1741
1741
|
return item[def.id];
|
|
1742
|
-
}
|
|
1742
|
+
},
|
|
1743
1743
|
};
|
|
1744
1744
|
};
|
|
1745
1745
|
const makeCellFromId = (columnId) => {
|
|
@@ -1776,7 +1776,7 @@ export class TableContext {
|
|
|
1776
1776
|
alternateRowColours,
|
|
1777
1777
|
changeColourOnHover,
|
|
1778
1778
|
copyWithHeaders,
|
|
1779
|
-
commaSeparatedCopy
|
|
1779
|
+
commaSeparatedCopy,
|
|
1780
1780
|
};
|
|
1781
1781
|
localStorage.setItem(`${this.userId}-${this.tableName}-settings`, JSON.stringify(settingsObject));
|
|
1782
1782
|
}
|
|
@@ -1793,7 +1793,7 @@ export class TableContext {
|
|
|
1793
1793
|
const endRowIndex = rows.findIndex((row) => row.visibleIndex === focusEnd.row);
|
|
1794
1794
|
this.focusEnd = {
|
|
1795
1795
|
...this.focusEnd,
|
|
1796
|
-
row: rows[Math.max(Math.min(endRowIndex + offset, rows.length - 1), 0)].visibleIndex
|
|
1796
|
+
row: rows[Math.max(Math.min(endRowIndex + offset, rows.length - 1), 0)].visibleIndex,
|
|
1797
1797
|
};
|
|
1798
1798
|
}
|
|
1799
1799
|
async _moveFocusRow(offset) {
|
|
@@ -1900,7 +1900,7 @@ export class TableContext {
|
|
|
1900
1900
|
items: selectedRows,
|
|
1901
1901
|
indicesByItem: indices,
|
|
1902
1902
|
focusedElementData: selectedCells,
|
|
1903
|
-
affectedColumns
|
|
1903
|
+
affectedColumns,
|
|
1904
1904
|
};
|
|
1905
1905
|
}
|
|
1906
1906
|
async getFocusElementData() {
|
|
@@ -1974,7 +1974,7 @@ export class TableContext {
|
|
|
1974
1974
|
items: selectedRows,
|
|
1975
1975
|
indicesByItem: indices,
|
|
1976
1976
|
focusedElementData: selectedCells,
|
|
1977
|
-
affectedColumns
|
|
1977
|
+
affectedColumns,
|
|
1978
1978
|
};
|
|
1979
1979
|
}
|
|
1980
1980
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
@@ -2191,7 +2191,7 @@ export class TableContext {
|
|
|
2191
2191
|
right: new Map(this.columnPinning.right &&
|
|
2192
2192
|
this.columnDefs
|
|
2193
2193
|
.filter((col) => this.columnPinning.right?.has(col.id))
|
|
2194
|
-
.map((col, index) => [col.id, index]))
|
|
2194
|
+
.map((col, index) => [col.id, index])),
|
|
2195
2195
|
}; // TODO
|
|
2196
2196
|
}
|
|
2197
2197
|
getToggleSortingHandler = (def) => () => {
|
|
@@ -2210,7 +2210,7 @@ export class TableContext {
|
|
|
2210
2210
|
else {
|
|
2211
2211
|
newState.push({
|
|
2212
2212
|
desc: false,
|
|
2213
|
-
id: def.id
|
|
2213
|
+
id: def.id,
|
|
2214
2214
|
});
|
|
2215
2215
|
}
|
|
2216
2216
|
return newState;
|
|
@@ -2234,7 +2234,7 @@ export class TableContext {
|
|
|
2234
2234
|
throw new Error('Could not find equivalent column def:', { cause: def });
|
|
2235
2235
|
}
|
|
2236
2236
|
return (preset.columnDefs[index] = realDef);
|
|
2237
|
-
})
|
|
2237
|
+
}),
|
|
2238
2238
|
};
|
|
2239
2239
|
});
|
|
2240
2240
|
}
|
|
@@ -2347,7 +2347,7 @@ function generateTableOptions(contextObj) {
|
|
|
2347
2347
|
getCanSort: () => def.allowSorting,
|
|
2348
2348
|
getToggleSortingHandler: () => def.allowSorting ? contextObj.getToggleSortingHandler(def) : undefined,
|
|
2349
2349
|
getIsSorted: () => isSorted,
|
|
2350
|
-
getIsVisible: () => isVisible
|
|
2350
|
+
getIsVisible: () => isVisible,
|
|
2351
2351
|
},
|
|
2352
2352
|
getResizeHandler: () => {
|
|
2353
2353
|
return (e) => {
|
|
@@ -2355,7 +2355,7 @@ function generateTableOptions(contextObj) {
|
|
|
2355
2355
|
};
|
|
2356
2356
|
},
|
|
2357
2357
|
isPlaceholder: false,
|
|
2358
|
-
getSize: () => def.width
|
|
2358
|
+
getSize: () => def.width,
|
|
2359
2359
|
};
|
|
2360
2360
|
};
|
|
2361
2361
|
const leftHeaderGroups = $derived.by(() => {
|
|
@@ -2372,8 +2372,8 @@ function generateTableOptions(contextObj) {
|
|
|
2372
2372
|
{
|
|
2373
2373
|
depth: 0,
|
|
2374
2374
|
id: 'left_0',
|
|
2375
|
-
headers
|
|
2376
|
-
}
|
|
2375
|
+
headers,
|
|
2376
|
+
},
|
|
2377
2377
|
];
|
|
2378
2378
|
});
|
|
2379
2379
|
const rightHeaderGroups = $derived.by(() => {
|
|
@@ -2384,8 +2384,8 @@ function generateTableOptions(contextObj) {
|
|
|
2384
2384
|
{
|
|
2385
2385
|
depth: 0,
|
|
2386
2386
|
id: 'right_0',
|
|
2387
|
-
headers
|
|
2388
|
-
}
|
|
2387
|
+
headers,
|
|
2388
|
+
},
|
|
2389
2389
|
];
|
|
2390
2390
|
});
|
|
2391
2391
|
const centerHeaderGroups = $derived.by(() => {
|
|
@@ -2399,8 +2399,8 @@ function generateTableOptions(contextObj) {
|
|
|
2399
2399
|
{
|
|
2400
2400
|
depth: 0,
|
|
2401
2401
|
id: 'center_0',
|
|
2402
|
-
headers
|
|
2403
|
-
}
|
|
2402
|
+
headers,
|
|
2403
|
+
},
|
|
2404
2404
|
];
|
|
2405
2405
|
});
|
|
2406
2406
|
const leftSizePx = $derived(leftHeaderGroups.reduce((total, grp) => total + grp.headers.reduce((total, header) => total + header.getSize(), 0), 0));
|
|
@@ -2455,7 +2455,7 @@ function generateTableOptions(contextObj) {
|
|
|
2455
2455
|
},
|
|
2456
2456
|
get onColumnFiltersChange() {
|
|
2457
2457
|
return contextObj.updateFilters;
|
|
2458
|
-
}
|
|
2458
|
+
},
|
|
2459
2459
|
// get pageCount() {
|
|
2460
2460
|
// return _pageCount;
|
|
2461
2461
|
// }
|
|
@@ -2570,7 +2570,7 @@ function adaptJSONPinningState(state) {
|
|
|
2570
2570
|
//HACK ignore previously broken pinning states
|
|
2571
2571
|
return {
|
|
2572
2572
|
left: new Map(Array.isArray(state.left) ? state.left : []),
|
|
2573
|
-
right: new Map(Array.isArray(state.right) ? state.right : [])
|
|
2573
|
+
right: new Map(Array.isArray(state.right) ? state.right : []),
|
|
2574
2574
|
};
|
|
2575
2575
|
}
|
|
2576
2576
|
// #endregion
|