@lavalogic/scoria 0.11.5 → 0.11.6
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.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import Action from '../../../../Action.svelte';
|
|
5
5
|
import Portal from '../../../../Portal.svelte';
|
|
6
6
|
import { ToastContext } from '../../../../../Contexts/ToastContext.svelte.js';
|
|
7
|
-
import { refWrapper } from '../../../../../Helpers/Helpers.svelte.js';
|
|
7
|
+
import { asyncMap, refWrapper } from '../../../../../Helpers/Helpers.svelte.js';
|
|
8
8
|
import { Colour, ColourSet } from '../../../../../scss/colours.js';
|
|
9
9
|
import { Size } from '../../../../../Types/Internal/Size.js';
|
|
10
10
|
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
@@ -17,14 +17,13 @@
|
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
19
|
<script lang="ts" generics="T extends object">
|
|
20
|
-
import { getContext, tick, untrack } from 'svelte';
|
|
21
|
-
import TableAction, { type ActionsTableCell } from './TableAction.svelte';
|
|
22
20
|
import type { ActionsDef } from '../../../Types/Columns/Definitions/Actions/ActionsDef.svelte.js';
|
|
23
21
|
import type { TableActionButton } from '../../../Types/Columns/TableActionButton.js';
|
|
24
|
-
import type { TableCell } from '../../../Types/Columns/TableCell.js';
|
|
25
22
|
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
26
23
|
import { MultiFocusEdge } from '../../../Types/Focus/MultiFocusEdge.js';
|
|
27
24
|
import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
25
|
+
import { getContext, tick, untrack } from 'svelte';
|
|
26
|
+
import TableAction, { type ActionsTableCell } from './TableAction.svelte';
|
|
28
27
|
|
|
29
28
|
const { cell }: ActionsCellProps<T> = $props();
|
|
30
29
|
|
|
@@ -165,15 +164,23 @@
|
|
|
165
164
|
/>
|
|
166
165
|
</div>
|
|
167
166
|
{#if thisPopupIsVisibile}
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
{@const awaitedActions = asyncMap<TableActionButton<T>, [TableActionButton<T>, string]>(
|
|
168
|
+
actions,
|
|
169
|
+
async (item) => {
|
|
170
|
+
return [item, await item.getLabel(cell.row.original, cell.row.visibleIndex)];
|
|
171
|
+
}
|
|
172
|
+
)}
|
|
173
|
+
{#await awaitedActions then actions}
|
|
174
|
+
<Portal>
|
|
175
|
+
<div bind:this={popupRef} class="popup" style="--y: {y}px; --x: {x}px;">
|
|
176
|
+
<div class="action-container">
|
|
177
|
+
{#each actions as [action, label] (label)}
|
|
178
|
+
<TableAction {action} {cell} />
|
|
179
|
+
{/each}
|
|
180
|
+
</div>
|
|
174
181
|
</div>
|
|
175
|
-
</
|
|
176
|
-
|
|
182
|
+
</Portal>
|
|
183
|
+
{/await}
|
|
177
184
|
{/if}
|
|
178
185
|
</td>
|
|
179
186
|
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
ContextMenuContext,
|
|
6
6
|
type IContextMenuOption
|
|
7
7
|
} from '../../Contexts/ContextMenuContext.svelte.js';
|
|
8
|
-
import {
|
|
8
|
+
import { refWrapper } from '../../Helpers/Helpers.svelte.js';
|
|
9
|
+
import { getContext, onMount, setContext, tick, untrack } from 'svelte';
|
|
9
10
|
import LoadingOverlay from '../LoadingOverlay.svelte';
|
|
11
|
+
import { shownPopup } from './Body/Rows/Columns/ActionsCell.svelte';
|
|
12
|
+
import TableBody, { type HeightData } from './Body/TableBody.svelte';
|
|
13
|
+
import TableHead from './Headers/TableHead.svelte';
|
|
14
|
+
import TableFooter from './Misc/TableFooter.svelte';
|
|
15
|
+
import TableHorizontalBar from './Misc/TableHorizontalBar.svelte';
|
|
16
|
+
import TableSidebar from './Misc/TableSidebar.svelte';
|
|
10
17
|
import { TableContext } from './Types/Context/TableContext.svelte.js';
|
|
11
18
|
import { PaginationType } from './Types/Pagination/PaginationType.js';
|
|
12
19
|
import { ToolbarPosition } from './Types/Toolbar/ToolbarPosition.js';
|
|
13
|
-
import { refWrapper } from '../../Helpers/Helpers.svelte.js';
|
|
14
|
-
import TableHorizontalBar from './Misc/TableHorizontalBar.svelte';
|
|
15
|
-
import TableSidebar from './Misc/TableSidebar.svelte';
|
|
16
|
-
import TableFooter from './Misc/TableFooter.svelte';
|
|
17
|
-
import TableHead from './Headers/TableHead.svelte';
|
|
18
|
-
import TableBody, { type HeightData } from './Body/TableBody.svelte';
|
|
19
|
-
import { shownPopup } from './Body/Rows/Columns/ActionsCell.svelte';
|
|
20
20
|
|
|
21
21
|
declare global {
|
|
22
22
|
interface HTMLElementEventMap {
|
|
@@ -247,20 +247,6 @@
|
|
|
247
247
|
}
|
|
248
248
|
});
|
|
249
249
|
|
|
250
|
-
$effect(() => {
|
|
251
|
-
if (tableContext.dataRepo?.data) {
|
|
252
|
-
untrack(() => {
|
|
253
|
-
if (
|
|
254
|
-
tableContext.paginationRepo?.paginationState.pageIndex != undefined &&
|
|
255
|
-
tableContext.paginationRepo?.paginationState.pageSize != undefined
|
|
256
|
-
) {
|
|
257
|
-
tableContext.updateSelectedItems();
|
|
258
|
-
tableContext.resetHighlightedRows();
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
|
|
264
250
|
const leftTotalSize = $derived(tableContext.table.getLeftTotalSize());
|
|
265
251
|
const centreTotalSize = $derived(tableContext.table.getCenterTotalSize());
|
|
266
252
|
const rightTotalSize = $derived(tableContext.table.getRightTotalSize());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { browser, dev } from '$app/environment';
|
|
2
2
|
import { asyncAll, asyncFilterIndices, asyncSleep, getCanvasContext, getErrorMessage } from '../../../../Helpers/Helpers.svelte.js';
|
|
3
|
-
import { tick } from 'svelte';
|
|
3
|
+
import { tick, untrack } from 'svelte';
|
|
4
4
|
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
5
5
|
import { ColumnType } from '../Columns/ColumnType.js';
|
|
6
6
|
import { AccessorDef } from '../Columns/Definitions/Accessors/AccessorDef.svelte.js';
|
|
@@ -67,16 +67,27 @@ export class TableContext {
|
|
|
67
67
|
this._dataRepo = $state(dataRepo);
|
|
68
68
|
// this.dataRepo.forceRefresh = this.forceVisibilityUpdate;
|
|
69
69
|
const [_currentPageData, _originalRowIndices] = $derived.by(() => {
|
|
70
|
-
const
|
|
70
|
+
const cpd = dataRepo.paginationType == PaginationType.Local
|
|
71
71
|
? this.sortedData.slice(dataRepo.pageStartIndex, dataRepo.pageEndIndexExclusive)
|
|
72
72
|
: (this.sortedData ?? []);
|
|
73
|
-
const
|
|
74
|
-
return [
|
|
73
|
+
const ori = new Map((dataRepo.data ?? []).map((item, index) => [item, index]));
|
|
74
|
+
return [cpd, ori];
|
|
75
75
|
});
|
|
76
76
|
$effect(() => {
|
|
77
77
|
this._currentPageData = _currentPageData;
|
|
78
78
|
this._originalRowIndices = _originalRowIndices;
|
|
79
79
|
});
|
|
80
|
+
$effect(() => {
|
|
81
|
+
if (_currentPageData) {
|
|
82
|
+
untrack(() => {
|
|
83
|
+
if (this.paginationRepo?.paginationState.pageIndex != undefined &&
|
|
84
|
+
this.paginationRepo?.paginationState.pageSize != undefined) {
|
|
85
|
+
this.updateSelectedItems();
|
|
86
|
+
this.resetHighlightedRows();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
80
91
|
if (defaultColumnDefs.remoteFilters) {
|
|
81
92
|
this.remoteFilters = defaultColumnDefs.remoteFilters;
|
|
82
93
|
}
|
|
@@ -859,7 +870,7 @@ export class TableContext {
|
|
|
859
870
|
const item = this.sortedData[index];
|
|
860
871
|
// HACK: Please find why this is happening and fix it properly
|
|
861
872
|
if (!item) {
|
|
862
|
-
console.warn(`skipping update because there is a data mismatch, page start index: ${pageStartIndex}, current index ${index}, page end index (
|
|
873
|
+
console.warn(`skipping update because there is a data mismatch, page start index: ${pageStartIndex}, current index ${index}, page end index (exclusive) ${pageEndIndexExclusive}`, $state.snapshot(this.sortedData));
|
|
863
874
|
return;
|
|
864
875
|
}
|
|
865
876
|
if (await selectableMethod(item, index)) {
|
|
@@ -872,7 +883,7 @@ export class TableContext {
|
|
|
872
883
|
const item = this.sortedData[index];
|
|
873
884
|
// HACK: Please find why this is happening and fix it properly
|
|
874
885
|
if (!item) {
|
|
875
|
-
console.warn(`skipping update because there is a data mismatch, page start index: ${pageStartIndex}, current index ${index}, page end index (
|
|
886
|
+
console.warn(`skipping update because there is a data mismatch, page start index: ${pageStartIndex}, current index ${index}, page end index (exclusive) ${pageEndIndexExclusive}`, $state.snapshot(this.sortedData));
|
|
876
887
|
return;
|
|
877
888
|
}
|
|
878
889
|
updateSelectedItem(item);
|