@lavalogic/scoria 0.34.0 → 0.35.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 +58 -58
- package/dist/Components/AccordionGroup.svelte +42 -42
- package/dist/Components/AccordionGroupButton.svelte +99 -99
- package/dist/Components/Action.svelte +138 -138
- package/dist/Components/AlertModal.svelte +125 -125
- package/dist/Components/Base/ContextWrapper.svelte +50 -50
- package/dist/Components/Base/Pagination.svelte +190 -190
- package/dist/Components/Base/Snippets.svelte +29 -29
- package/dist/Components/BigRadioSet.svelte +29 -29
- package/dist/Components/Bubble.svelte +77 -77
- package/dist/Components/Button.svelte +197 -197
- package/dist/Components/Checkbox.svelte +68 -68
- package/dist/Components/CollapsibleCard.svelte +70 -70
- package/dist/Components/Contexts/ContextMenu.svelte +157 -157
- package/dist/Components/Contexts/ContextMenuDivider.svelte +11 -11
- package/dist/Components/Contexts/ContextMenuOption.svelte +52 -52
- package/dist/Components/Contexts/Toast.svelte +61 -61
- package/dist/Components/Contexts/ToastContainer.svelte +46 -46
- package/dist/Components/Contexts/Tooltip.svelte +26 -26
- package/dist/Components/DataMatrixIcon.svelte +41 -41
- package/dist/Components/DateInput.svelte +109 -109
- package/dist/Components/DatePicker.svelte +312 -312
- package/dist/Components/DesktopModal.svelte +106 -106
- package/dist/Components/Dial.svelte +151 -151
- package/dist/Components/DimensionInput.svelte +184 -184
- package/dist/Components/DragMenu/DragMenuHolder.svelte +106 -106
- package/dist/Components/DragMenu/DraggableCard.svelte +41 -41
- package/dist/Components/FileCard.svelte +20 -20
- package/dist/Components/FileUpload.svelte +196 -196
- package/dist/Components/GridInput.svelte +190 -190
- package/dist/Components/GridInputSet.svelte +22 -22
- package/dist/Components/HorizontalTabGroup.svelte +78 -78
- package/dist/Components/HorizontalTabGroupButton.svelte +96 -96
- package/dist/Components/Icon.svelte +97 -97
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/LoadingAnimation.svelte +32 -32
- package/dist/Components/LoadingModal.svelte +47 -47
- package/dist/Components/LoadingOverlay.svelte +27 -27
- package/dist/Components/Modal.svelte +251 -251
- package/dist/Components/MultiSelect.svelte +197 -197
- package/dist/Components/Nav/Nav.svelte +97 -97
- package/dist/Components/Nav/NavServiceMenuList.svelte +34 -34
- package/dist/Components/Nav/NavTab.svelte +91 -91
- package/dist/Components/Nav/ServiceMenuItem.svelte +91 -91
- package/dist/Components/Nav/ServicesNav.svelte +53 -53
- package/dist/Components/NumberInput.svelte +144 -144
- package/dist/Components/PageHeading.svelte +36 -36
- package/dist/Components/PasswordInput.svelte +73 -73
- package/dist/Components/Portal.svelte +25 -25
- package/dist/Components/ProgressBubble.svelte +80 -80
- package/dist/Components/QuerySelect.svelte +411 -411
- package/dist/Components/SingleSelect.svelte +261 -261
- package/dist/Components/StepButton.svelte +120 -120
- package/dist/Components/StepForm.svelte +108 -108
- package/dist/Components/Switch.svelte +36 -36
- package/dist/Components/Table/Body/QuickSearchCell.svelte +632 -632
- package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +30 -30
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +56 -56
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +179 -179
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +49 -49
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +180 -180
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +102 -102
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +119 -119
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +114 -114
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +96 -96
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +72 -72
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +131 -131
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +144 -144
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +238 -238
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +358 -358
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +338 -338
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +183 -183
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +309 -309
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +369 -369
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +170 -170
- package/dist/Components/Table/Body/Rows/TableRow.svelte +259 -259
- package/dist/Components/Table/Body/TableBody.svelte +67 -67
- package/dist/Components/Table/Headers/HighlightAllHeader.svelte +39 -39
- package/dist/Components/Table/Headers/SelectAllHeader.svelte +28 -28
- package/dist/Components/Table/Headers/TableHead.svelte +260 -260
- package/dist/Components/Table/Misc/ColumnPanel.svelte +78 -78
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +99 -99
- package/dist/Components/Table/Misc/FilterInput.svelte +556 -556
- package/dist/Components/Table/Misc/FilterPanel.svelte +46 -46
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +67 -67
- package/dist/Components/Table/Misc/SidePanel.svelte +32 -32
- package/dist/Components/Table/Misc/TableFooter.svelte +304 -304
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +156 -156
- package/dist/Components/Table/Misc/TableSidebar.svelte +176 -176
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +77 -77
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +91 -91
- package/dist/Components/Table/NestedTable.svelte +84 -84
- package/dist/Components/Table/Table.svelte +492 -492
- package/dist/Components/Test/TestContextConsumer.svelte +13 -13
- package/dist/Components/TextArea.svelte +108 -108
- package/dist/Components/TextInput.svelte +147 -147
- package/dist/Components/ThreeStateRadio.svelte +124 -124
- package/dist/Components/Touch/BoolCard.svelte +52 -52
- package/dist/Components/Touch/DateModal.svelte +217 -217
- package/dist/Components/Touch/EditCard.svelte +52 -52
- package/dist/Components/Touch/InfoCard.svelte +24 -24
- package/dist/Components/Touch/InfoTextCard.svelte +21 -21
- package/dist/Components/Touch/ModalExplanation.svelte +20 -20
- package/dist/Components/Touch/NumberKeyboard.svelte +268 -268
- package/dist/Components/Touch/NumberModal.svelte +69 -69
- package/dist/Components/Touch/PlusMinusCard.svelte +50 -50
- package/dist/Components/Touch/SelectModal.svelte +105 -105
- package/dist/Components/Touch/SummaryCard.svelte +65 -65
- package/dist/Components/Touch/TextAreaModal.svelte +86 -86
- package/dist/Components/Touch/TextModal.svelte +123 -123
- package/dist/Components/Touch/TouchCard.svelte +28 -28
- package/dist/Components/Touch/TouchModal.svelte +259 -259
- package/dist/Components/Touch/UtilityButton.svelte +91 -91
- package/dist/Components/VerticalTabGroup.svelte +66 -66
- package/dist/Components/VerticalTabGroupButton.svelte +97 -97
- package/dist/Helpers/Datamatrix.d.ts +10 -10
- package/dist/Helpers/Datamatrix.js +1 -1
- package/dist/Helpers/Helpers.svelte.js +6 -4
- package/dist/Types/Examples/ExampleModal.svelte +34 -34
- package/dist/scss/_basics.scss +12 -12
- package/dist/scss/_colours.scss +134 -134
- package/dist/scss/_mixins.scss +3016 -3016
- package/dist/scss/_sizing.scss +69 -69
- package/dist/scss/_transitions.scss +8 -8
- package/package.json +2 -2
|
@@ -1,261 +1,261 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="T extends object, RowIdType extends Primitive"
|
|
6
|
-
>
|
|
7
|
-
import { dev } from '$app/environment';
|
|
8
|
-
import { devCatch, generateShortUUID } from '../../../../Helpers/Helpers.svelte.js';
|
|
9
|
-
import { getContext, untrack } from 'svelte';
|
|
10
|
-
import NestedTable from '../../NestedTable.svelte';
|
|
11
|
-
import type { ExpandDef } from '../../Types/Columns/Definitions/Expand/ExpandDef.svelte.js';
|
|
12
|
-
import type { DefsWrapper } from '../../Types/Columns/DefsWrapper.js';
|
|
13
|
-
import type { TableCell } from '../../Types/Columns/TableCell.js';
|
|
14
|
-
import { TableContext } from '../../Types/Context/TableContext.svelte.js';
|
|
15
|
-
import { type Primitive } from '../../Types/Context/TableInitOptions.js';
|
|
16
|
-
import ColumnHighlight from './ColumnHighlight.svelte';
|
|
17
|
-
import TableColumn from './Columns/TableColumn.svelte';
|
|
18
|
-
import type { TableRowProps } from './TableRowProps.js';
|
|
19
|
-
|
|
20
|
-
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
21
|
-
|
|
22
|
-
const { row, side, odd = false, customHeight, includeHighlight }: TableRowProps<T> = $props();
|
|
23
|
-
|
|
24
|
-
const hoverable = $derived(tableContext.changeColourOnHover);
|
|
25
|
-
|
|
26
|
-
//HACK converted this from derived to state+deffect because otherwise this throws an unsafe mutation error deeper down the stack
|
|
27
|
-
const cells: Array<TableCell<T>> = $derived(
|
|
28
|
-
side === 'left'
|
|
29
|
-
? row.getLeftVisibleCells()
|
|
30
|
-
: side === 'right'
|
|
31
|
-
? row.getRightVisibleCells()
|
|
32
|
-
: row.getCenterVisibleCells()
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
let expandedColumnDef: ExpandDef<T, object> | undefined = $state();
|
|
36
|
-
|
|
37
|
-
$effect(() => {
|
|
38
|
-
if (cells.length) {
|
|
39
|
-
void tableContext.table.data;
|
|
40
|
-
void tableContext.paginationRepo?.paginationState.pageIndex;
|
|
41
|
-
void tableContext.paginationRepo?.paginationState.pageSize;
|
|
42
|
-
untrack(() => {
|
|
43
|
-
expandedColumnDef = undefined;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
let innerDataPromise: Array<object> | Promise<Array<object>> | undefined = $state();
|
|
49
|
-
let innerColumnDefs: DefsWrapper<object> = $state({ defs: [] });
|
|
50
|
-
let innerTableName: string | undefined = $state();
|
|
51
|
-
|
|
52
|
-
let prevExpandedColumnDef: ExpandDef<T, object> | undefined = $state();
|
|
53
|
-
|
|
54
|
-
const rowIndex = $derived(cells.at(0) && cells[0].row.visibleIndex);
|
|
55
|
-
let id = $state<RowIdType | undefined>();
|
|
56
|
-
const highlighted = $derived(id != undefined && tableContext.highlightedItems.has(id));
|
|
57
|
-
|
|
58
|
-
$effect(() => {
|
|
59
|
-
void row.original;
|
|
60
|
-
void tableContext.selectionExtractor;
|
|
61
|
-
|
|
62
|
-
if (rowIndex != undefined) {
|
|
63
|
-
const maybePromise = tableContext.selectionExtractor(row.original);
|
|
64
|
-
if (maybePromise instanceof Promise) {
|
|
65
|
-
maybePromise
|
|
66
|
-
.then((it) => {
|
|
67
|
-
id = it;
|
|
68
|
-
})
|
|
69
|
-
.catch(devCatch);
|
|
70
|
-
} else {
|
|
71
|
-
id = maybePromise;
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
id = undefined;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const showHighlightButton = $derived(rowIndex != null && includeHighlight);
|
|
79
|
-
|
|
80
|
-
const colspan = $derived(cells.length + (showHighlightButton ? 1 : 0));
|
|
81
|
-
|
|
82
|
-
$effect(() => {
|
|
83
|
-
void expandedColumnDef;
|
|
84
|
-
|
|
85
|
-
untrack(() => {
|
|
86
|
-
if (expandedColumnDef && expandedColumnDef.id != prevExpandedColumnDef?.id) {
|
|
87
|
-
prevExpandedColumnDef = expandedColumnDef;
|
|
88
|
-
innerColumnDefs = expandedColumnDef.getInnerColumnDefs(
|
|
89
|
-
cells[0].row.original,
|
|
90
|
-
cells[0].row.originalIndex
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
innerDataPromise = expandedColumnDef.accessorFn(
|
|
94
|
-
cells[0].row.original,
|
|
95
|
-
cells[0].row.originalIndex
|
|
96
|
-
) as Promise<Array<object>>;
|
|
97
|
-
innerTableName = expandedColumnDef.innerTableName;
|
|
98
|
-
} else if (
|
|
99
|
-
!expandedColumnDef ||
|
|
100
|
-
tableContext.columnVisibility[expandedColumnDef.id] === false
|
|
101
|
-
) {
|
|
102
|
-
innerTableName = undefined;
|
|
103
|
-
expandedColumnDef = prevExpandedColumnDef = innerDataPromise = undefined;
|
|
104
|
-
innerColumnDefs = { defs: [] };
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
function onExpandChange(columnDef: ExpandDef<T, object>) {
|
|
110
|
-
if (expandedColumnDef?.id === columnDef.id) {
|
|
111
|
-
expandedColumnDef = undefined;
|
|
112
|
-
} else {
|
|
113
|
-
expandedColumnDef = columnDef;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
let trRef: HTMLTableRowElement | undefined = $state();
|
|
118
|
-
let _trHeight = $state(0);
|
|
119
|
-
|
|
120
|
-
let innerTrRef: HTMLTableRowElement | undefined = $state();
|
|
121
|
-
let _innerTrHeight = $state(0);
|
|
122
|
-
|
|
123
|
-
$effect(() => {
|
|
124
|
-
void trRef;
|
|
125
|
-
void customHeight;
|
|
126
|
-
|
|
127
|
-
return untrack(() => {
|
|
128
|
-
if (trRef && customHeight == null) {
|
|
129
|
-
const observer = new ResizeObserver((entries) => {
|
|
130
|
-
_trHeight = entries[0].borderBoxSize[0].blockSize;
|
|
131
|
-
});
|
|
132
|
-
observer.observe(trRef);
|
|
133
|
-
|
|
134
|
-
const currenttrRef = trRef;
|
|
135
|
-
return () => {
|
|
136
|
-
observer.unobserve(currenttrRef);
|
|
137
|
-
_trHeight = 0;
|
|
138
|
-
};
|
|
139
|
-
} else {
|
|
140
|
-
_trHeight = 0;
|
|
141
|
-
}
|
|
142
|
-
return () => {};
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
$effect(() => {
|
|
147
|
-
void innerTrRef;
|
|
148
|
-
return untrack(() => {
|
|
149
|
-
if (innerTrRef) {
|
|
150
|
-
const observer = new ResizeObserver((entries) => {
|
|
151
|
-
_innerTrHeight = entries[0].borderBoxSize[0].blockSize;
|
|
152
|
-
});
|
|
153
|
-
observer.observe(innerTrRef);
|
|
154
|
-
|
|
155
|
-
const currentinnerTrRef = innerTrRef;
|
|
156
|
-
return () => {
|
|
157
|
-
observer.unobserve(currentinnerTrRef);
|
|
158
|
-
};
|
|
159
|
-
} else {
|
|
160
|
-
_innerTrHeight = 0;
|
|
161
|
-
}
|
|
162
|
-
return () => {};
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const _totalTrHeight = $derived(_trHeight + _innerTrHeight);
|
|
167
|
-
export const totalTrHeight = {
|
|
168
|
-
get value() {
|
|
169
|
-
return _totalTrHeight;
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
</script>
|
|
173
|
-
|
|
174
|
-
<tr
|
|
175
|
-
class:hoverable
|
|
176
|
-
class:alt={tableContext.alternateRowColours && odd}
|
|
177
|
-
class:highlighted
|
|
178
|
-
style={customHeight ? `height: ${customHeight}px !important;` : null}
|
|
179
|
-
bind:this={trRef}
|
|
180
|
-
>
|
|
181
|
-
{#if showHighlightButton}
|
|
182
|
-
<ColumnHighlight
|
|
183
|
-
rowIndex={rowIndex ??
|
|
184
|
-
(() => {
|
|
185
|
-
if (dev) {
|
|
186
|
-
console.error(`column had invalid row index: ${rowIndex}`);
|
|
187
|
-
}
|
|
188
|
-
return -1;
|
|
189
|
-
})()}
|
|
190
|
-
{highlighted}
|
|
191
|
-
toggleHighlightedRow={() => {
|
|
192
|
-
tableContext.toggleHighlightedRow(row.original)?.catch(devCatch);
|
|
193
|
-
}}
|
|
194
|
-
/>
|
|
195
|
-
{/if}
|
|
196
|
-
{#each cells as cell (cell)}
|
|
197
|
-
<TableColumn
|
|
198
|
-
{cell}
|
|
199
|
-
{expandedColumnDef}
|
|
200
|
-
{onExpandChange}
|
|
201
|
-
/>
|
|
202
|
-
{/each}
|
|
203
|
-
</tr>
|
|
204
|
-
|
|
205
|
-
{#if expandedColumnDef}
|
|
206
|
-
<!-- TODO re-test and re-implement these -->
|
|
207
|
-
<!-- transition:slide={{ duration: 150, axis: 'y', delay: 0 }} -->
|
|
208
|
-
<tr
|
|
209
|
-
class="inner-table"
|
|
210
|
-
bind:this={innerTrRef}
|
|
211
|
-
>
|
|
212
|
-
{#await innerDataPromise}
|
|
213
|
-
<td {colspan}>loading…</td>
|
|
214
|
-
{:then data}
|
|
215
|
-
{#if data && data.length}
|
|
216
|
-
{@const options = expandedColumnDef.innerTableOptions}
|
|
217
|
-
<td
|
|
218
|
-
class="no-padding"
|
|
219
|
-
{colspan}
|
|
220
|
-
>
|
|
221
|
-
{#if innerTableName}
|
|
222
|
-
{#key innerTableName}
|
|
223
|
-
<NestedTable
|
|
224
|
-
tableName={innerTableName}
|
|
225
|
-
{data}
|
|
226
|
-
columnDefWrapper={innerColumnDefs}
|
|
227
|
-
{options}
|
|
228
|
-
getUserId={tableContext.getUserId}
|
|
229
|
-
/>
|
|
230
|
-
{/key}
|
|
231
|
-
{:else}
|
|
232
|
-
<NestedTable
|
|
233
|
-
tableName={generateShortUUID()}
|
|
234
|
-
{data}
|
|
235
|
-
columnDefWrapper={innerColumnDefs}
|
|
236
|
-
{options}
|
|
237
|
-
getUserId={tableContext.getUserId}
|
|
238
|
-
/>
|
|
239
|
-
{/if}
|
|
240
|
-
</td>
|
|
241
|
-
{:else if !data}
|
|
242
|
-
<td {colspan}>Error Fetching data</td>
|
|
243
|
-
{:else}
|
|
244
|
-
<td {colspan}>No Data</td>
|
|
245
|
-
{/if}
|
|
246
|
-
{:catch e}
|
|
247
|
-
{#if dev}
|
|
248
|
-
<td>
|
|
249
|
-
error: {e}
|
|
250
|
-
</td>
|
|
251
|
-
<!-- eslint-disable-next-line svelte/no-at-debug-tags -->
|
|
252
|
-
{@debug e}
|
|
253
|
-
{/if}
|
|
254
|
-
<td {colspan}>Error Fetching data</td>
|
|
255
|
-
{/await}
|
|
256
|
-
</tr>
|
|
257
|
-
{/if}
|
|
258
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object, RowIdType extends Primitive"
|
|
6
|
+
>
|
|
7
|
+
import { dev } from '$app/environment';
|
|
8
|
+
import { devCatch, generateShortUUID } from '../../../../Helpers/Helpers.svelte.js';
|
|
9
|
+
import { getContext, untrack } from 'svelte';
|
|
10
|
+
import NestedTable from '../../NestedTable.svelte';
|
|
11
|
+
import type { ExpandDef } from '../../Types/Columns/Definitions/Expand/ExpandDef.svelte.js';
|
|
12
|
+
import type { DefsWrapper } from '../../Types/Columns/DefsWrapper.js';
|
|
13
|
+
import type { TableCell } from '../../Types/Columns/TableCell.js';
|
|
14
|
+
import { TableContext } from '../../Types/Context/TableContext.svelte.js';
|
|
15
|
+
import { type Primitive } from '../../Types/Context/TableInitOptions.js';
|
|
16
|
+
import ColumnHighlight from './ColumnHighlight.svelte';
|
|
17
|
+
import TableColumn from './Columns/TableColumn.svelte';
|
|
18
|
+
import type { TableRowProps } from './TableRowProps.js';
|
|
19
|
+
|
|
20
|
+
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
21
|
+
|
|
22
|
+
const { row, side, odd = false, customHeight, includeHighlight }: TableRowProps<T> = $props();
|
|
23
|
+
|
|
24
|
+
const hoverable = $derived(tableContext.changeColourOnHover);
|
|
25
|
+
|
|
26
|
+
//HACK converted this from derived to state+deffect because otherwise this throws an unsafe mutation error deeper down the stack
|
|
27
|
+
const cells: Array<TableCell<T>> = $derived(
|
|
28
|
+
side === 'left'
|
|
29
|
+
? row.getLeftVisibleCells()
|
|
30
|
+
: side === 'right'
|
|
31
|
+
? row.getRightVisibleCells()
|
|
32
|
+
: row.getCenterVisibleCells()
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
let expandedColumnDef: ExpandDef<T, object> | undefined = $state();
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (cells.length) {
|
|
39
|
+
void tableContext.table.data;
|
|
40
|
+
void tableContext.paginationRepo?.paginationState.pageIndex;
|
|
41
|
+
void tableContext.paginationRepo?.paginationState.pageSize;
|
|
42
|
+
untrack(() => {
|
|
43
|
+
expandedColumnDef = undefined;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
let innerDataPromise: Array<object> | Promise<Array<object>> | undefined = $state();
|
|
49
|
+
let innerColumnDefs: DefsWrapper<object> = $state({ defs: [] });
|
|
50
|
+
let innerTableName: string | undefined = $state();
|
|
51
|
+
|
|
52
|
+
let prevExpandedColumnDef: ExpandDef<T, object> | undefined = $state();
|
|
53
|
+
|
|
54
|
+
const rowIndex = $derived(cells.at(0) && cells[0].row.visibleIndex);
|
|
55
|
+
let id = $state<RowIdType | undefined>();
|
|
56
|
+
const highlighted = $derived(id != undefined && tableContext.highlightedItems.has(id));
|
|
57
|
+
|
|
58
|
+
$effect(() => {
|
|
59
|
+
void row.original;
|
|
60
|
+
void tableContext.selectionExtractor;
|
|
61
|
+
|
|
62
|
+
if (rowIndex != undefined) {
|
|
63
|
+
const maybePromise = tableContext.selectionExtractor(row.original);
|
|
64
|
+
if (maybePromise instanceof Promise) {
|
|
65
|
+
maybePromise
|
|
66
|
+
.then((it) => {
|
|
67
|
+
id = it;
|
|
68
|
+
})
|
|
69
|
+
.catch(devCatch);
|
|
70
|
+
} else {
|
|
71
|
+
id = maybePromise;
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
id = undefined;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const showHighlightButton = $derived(rowIndex != null && includeHighlight);
|
|
79
|
+
|
|
80
|
+
const colspan = $derived(cells.length + (showHighlightButton ? 1 : 0));
|
|
81
|
+
|
|
82
|
+
$effect(() => {
|
|
83
|
+
void expandedColumnDef;
|
|
84
|
+
|
|
85
|
+
untrack(() => {
|
|
86
|
+
if (expandedColumnDef && expandedColumnDef.id != prevExpandedColumnDef?.id) {
|
|
87
|
+
prevExpandedColumnDef = expandedColumnDef;
|
|
88
|
+
innerColumnDefs = expandedColumnDef.getInnerColumnDefs(
|
|
89
|
+
cells[0].row.original,
|
|
90
|
+
cells[0].row.originalIndex
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
innerDataPromise = expandedColumnDef.accessorFn(
|
|
94
|
+
cells[0].row.original,
|
|
95
|
+
cells[0].row.originalIndex
|
|
96
|
+
) as Promise<Array<object>>;
|
|
97
|
+
innerTableName = expandedColumnDef.innerTableName;
|
|
98
|
+
} else if (
|
|
99
|
+
!expandedColumnDef ||
|
|
100
|
+
tableContext.columnVisibility[expandedColumnDef.id] === false
|
|
101
|
+
) {
|
|
102
|
+
innerTableName = undefined;
|
|
103
|
+
expandedColumnDef = prevExpandedColumnDef = innerDataPromise = undefined;
|
|
104
|
+
innerColumnDefs = { defs: [] };
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
function onExpandChange(columnDef: ExpandDef<T, object>) {
|
|
110
|
+
if (expandedColumnDef?.id === columnDef.id) {
|
|
111
|
+
expandedColumnDef = undefined;
|
|
112
|
+
} else {
|
|
113
|
+
expandedColumnDef = columnDef;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let trRef: HTMLTableRowElement | undefined = $state();
|
|
118
|
+
let _trHeight = $state(0);
|
|
119
|
+
|
|
120
|
+
let innerTrRef: HTMLTableRowElement | undefined = $state();
|
|
121
|
+
let _innerTrHeight = $state(0);
|
|
122
|
+
|
|
123
|
+
$effect(() => {
|
|
124
|
+
void trRef;
|
|
125
|
+
void customHeight;
|
|
126
|
+
|
|
127
|
+
return untrack(() => {
|
|
128
|
+
if (trRef && customHeight == null) {
|
|
129
|
+
const observer = new ResizeObserver((entries) => {
|
|
130
|
+
_trHeight = entries[0].borderBoxSize[0].blockSize;
|
|
131
|
+
});
|
|
132
|
+
observer.observe(trRef);
|
|
133
|
+
|
|
134
|
+
const currenttrRef = trRef;
|
|
135
|
+
return () => {
|
|
136
|
+
observer.unobserve(currenttrRef);
|
|
137
|
+
_trHeight = 0;
|
|
138
|
+
};
|
|
139
|
+
} else {
|
|
140
|
+
_trHeight = 0;
|
|
141
|
+
}
|
|
142
|
+
return () => {};
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
$effect(() => {
|
|
147
|
+
void innerTrRef;
|
|
148
|
+
return untrack(() => {
|
|
149
|
+
if (innerTrRef) {
|
|
150
|
+
const observer = new ResizeObserver((entries) => {
|
|
151
|
+
_innerTrHeight = entries[0].borderBoxSize[0].blockSize;
|
|
152
|
+
});
|
|
153
|
+
observer.observe(innerTrRef);
|
|
154
|
+
|
|
155
|
+
const currentinnerTrRef = innerTrRef;
|
|
156
|
+
return () => {
|
|
157
|
+
observer.unobserve(currentinnerTrRef);
|
|
158
|
+
};
|
|
159
|
+
} else {
|
|
160
|
+
_innerTrHeight = 0;
|
|
161
|
+
}
|
|
162
|
+
return () => {};
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const _totalTrHeight = $derived(_trHeight + _innerTrHeight);
|
|
167
|
+
export const totalTrHeight = {
|
|
168
|
+
get value() {
|
|
169
|
+
return _totalTrHeight;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
</script>
|
|
173
|
+
|
|
174
|
+
<tr
|
|
175
|
+
class:hoverable
|
|
176
|
+
class:alt={tableContext.alternateRowColours && odd}
|
|
177
|
+
class:highlighted
|
|
178
|
+
style={customHeight ? `height: ${customHeight}px !important;` : null}
|
|
179
|
+
bind:this={trRef}
|
|
180
|
+
>
|
|
181
|
+
{#if showHighlightButton}
|
|
182
|
+
<ColumnHighlight
|
|
183
|
+
rowIndex={rowIndex ??
|
|
184
|
+
(() => {
|
|
185
|
+
if (dev) {
|
|
186
|
+
console.error(`column had invalid row index: ${rowIndex}`);
|
|
187
|
+
}
|
|
188
|
+
return -1;
|
|
189
|
+
})()}
|
|
190
|
+
{highlighted}
|
|
191
|
+
toggleHighlightedRow={() => {
|
|
192
|
+
tableContext.toggleHighlightedRow(row.original)?.catch(devCatch);
|
|
193
|
+
}}
|
|
194
|
+
/>
|
|
195
|
+
{/if}
|
|
196
|
+
{#each cells as cell (cell)}
|
|
197
|
+
<TableColumn
|
|
198
|
+
{cell}
|
|
199
|
+
{expandedColumnDef}
|
|
200
|
+
{onExpandChange}
|
|
201
|
+
/>
|
|
202
|
+
{/each}
|
|
203
|
+
</tr>
|
|
204
|
+
|
|
205
|
+
{#if expandedColumnDef}
|
|
206
|
+
<!-- TODO re-test and re-implement these -->
|
|
207
|
+
<!-- transition:slide={{ duration: 150, axis: 'y', delay: 0 }} -->
|
|
208
|
+
<tr
|
|
209
|
+
class="inner-table"
|
|
210
|
+
bind:this={innerTrRef}
|
|
211
|
+
>
|
|
212
|
+
{#await innerDataPromise}
|
|
213
|
+
<td {colspan}>loading…</td>
|
|
214
|
+
{:then data}
|
|
215
|
+
{#if data && data.length}
|
|
216
|
+
{@const options = expandedColumnDef.innerTableOptions}
|
|
217
|
+
<td
|
|
218
|
+
class="no-padding"
|
|
219
|
+
{colspan}
|
|
220
|
+
>
|
|
221
|
+
{#if innerTableName}
|
|
222
|
+
{#key innerTableName}
|
|
223
|
+
<NestedTable
|
|
224
|
+
tableName={innerTableName}
|
|
225
|
+
{data}
|
|
226
|
+
columnDefWrapper={innerColumnDefs}
|
|
227
|
+
{options}
|
|
228
|
+
getUserId={tableContext.getUserId}
|
|
229
|
+
/>
|
|
230
|
+
{/key}
|
|
231
|
+
{:else}
|
|
232
|
+
<NestedTable
|
|
233
|
+
tableName={generateShortUUID()}
|
|
234
|
+
{data}
|
|
235
|
+
columnDefWrapper={innerColumnDefs}
|
|
236
|
+
{options}
|
|
237
|
+
getUserId={tableContext.getUserId}
|
|
238
|
+
/>
|
|
239
|
+
{/if}
|
|
240
|
+
</td>
|
|
241
|
+
{:else if !data}
|
|
242
|
+
<td {colspan}>Error Fetching data</td>
|
|
243
|
+
{:else}
|
|
244
|
+
<td {colspan}>No Data</td>
|
|
245
|
+
{/if}
|
|
246
|
+
{:catch e}
|
|
247
|
+
{#if dev}
|
|
248
|
+
<td>
|
|
249
|
+
error: {e}
|
|
250
|
+
</td>
|
|
251
|
+
<!-- eslint-disable-next-line svelte/no-at-debug-tags -->
|
|
252
|
+
{@debug e}
|
|
253
|
+
{/if}
|
|
254
|
+
<td {colspan}>Error Fetching data</td>
|
|
255
|
+
{/await}
|
|
256
|
+
</tr>
|
|
257
|
+
{/if}
|
|
258
|
+
|
|
259
259
|
<style>tr {
|
|
260
260
|
line-height: var(--line-height, 3);
|
|
261
261
|
transition: line-height 0.2s ease, height 0.2s ease;
|
|
@@ -269,4 +269,4 @@ tr.alt {
|
|
|
269
269
|
}
|
|
270
270
|
tr.highlighted, tr.hoverable:hover {
|
|
271
271
|
background-color: #e6f8fd;
|
|
272
|
-
}</style>
|
|
272
|
+
}</style>
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="T extends object"
|
|
6
|
-
>
|
|
7
|
-
import type { RefWrapper } from '../../../Types/Internal/RefWrapper.js';
|
|
8
|
-
import { getContext } from 'svelte';
|
|
9
|
-
import { TableContext } from '../Types/Context/TableContext.svelte.js';
|
|
10
|
-
import QuickSearchCell from './QuickSearchCell.svelte';
|
|
11
|
-
import TableRow from './Rows/TableRow.svelte';
|
|
12
|
-
import type { TableBodyProps } from './TableBodyProps.js';
|
|
13
|
-
|
|
14
|
-
let { side, heights, columns, includeHighlight }: TableBodyProps<T> = $props();
|
|
15
|
-
|
|
16
|
-
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
17
|
-
|
|
18
|
-
type HasHeight = {
|
|
19
|
-
totalTrHeight?: RefWrapper<number>;
|
|
20
|
-
};
|
|
21
|
-
const rows: Array<TableRow<T, never>> = $state([]);
|
|
22
|
-
|
|
23
|
-
const _rowHeights = $derived(
|
|
24
|
-
// HACK terrible type casting due to svelte type gen not being liked by eslint
|
|
25
|
-
rows.map((it) => {
|
|
26
|
-
return (it as HasHeight | undefined)?.totalTrHeight?.value ?? 0;
|
|
27
|
-
})
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
export const rowHeights = {
|
|
31
|
-
get value() {
|
|
32
|
-
return _rowHeights;
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<tbody>
|
|
38
|
-
{#if tableContext.allowQuickFiltering && tableContext.showQuickFiltering && columns.length}
|
|
39
|
-
<tr class="sticky">
|
|
40
|
-
{#if includeHighlight}
|
|
41
|
-
<td class="highlight-dud"><!-- accomodating for row marking --></td>
|
|
42
|
-
{/if}
|
|
43
|
-
{#each columns as column (column.id)}
|
|
44
|
-
<QuickSearchCell
|
|
45
|
-
{column}
|
|
46
|
-
customFilters={tableContext.remoteFilters}
|
|
47
|
-
/>
|
|
48
|
-
{/each}
|
|
49
|
-
</tr>
|
|
50
|
-
{/if}
|
|
51
|
-
|
|
52
|
-
{#each tableContext.paginationRowModel.rows as row, index (row.visibleIndex)}
|
|
53
|
-
{@const customHeight = heights[index]?.applyTo.includes(side)
|
|
54
|
-
? heights[index].maxHeight
|
|
55
|
-
: undefined}
|
|
56
|
-
<TableRow
|
|
57
|
-
{customHeight}
|
|
58
|
-
{includeHighlight}
|
|
59
|
-
{row}
|
|
60
|
-
{side}
|
|
61
|
-
odd={index % 2 == 1}
|
|
62
|
-
bind:this={rows[index]}
|
|
63
|
-
/>
|
|
64
|
-
{/each}
|
|
65
|
-
</tbody>
|
|
66
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object"
|
|
6
|
+
>
|
|
7
|
+
import type { RefWrapper } from '../../../Types/Internal/RefWrapper.js';
|
|
8
|
+
import { getContext } from 'svelte';
|
|
9
|
+
import { TableContext } from '../Types/Context/TableContext.svelte.js';
|
|
10
|
+
import QuickSearchCell from './QuickSearchCell.svelte';
|
|
11
|
+
import TableRow from './Rows/TableRow.svelte';
|
|
12
|
+
import type { TableBodyProps } from './TableBodyProps.js';
|
|
13
|
+
|
|
14
|
+
let { side, heights, columns, includeHighlight }: TableBodyProps<T> = $props();
|
|
15
|
+
|
|
16
|
+
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
17
|
+
|
|
18
|
+
type HasHeight = {
|
|
19
|
+
totalTrHeight?: RefWrapper<number>;
|
|
20
|
+
};
|
|
21
|
+
const rows: Array<TableRow<T, never>> = $state([]);
|
|
22
|
+
|
|
23
|
+
const _rowHeights = $derived(
|
|
24
|
+
// HACK terrible type casting due to svelte type gen not being liked by eslint
|
|
25
|
+
rows.map((it) => {
|
|
26
|
+
return (it as HasHeight | undefined)?.totalTrHeight?.value ?? 0;
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const rowHeights = {
|
|
31
|
+
get value() {
|
|
32
|
+
return _rowHeights;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<tbody>
|
|
38
|
+
{#if tableContext.allowQuickFiltering && tableContext.showQuickFiltering && columns.length}
|
|
39
|
+
<tr class="sticky">
|
|
40
|
+
{#if includeHighlight}
|
|
41
|
+
<td class="highlight-dud"><!-- accomodating for row marking --></td>
|
|
42
|
+
{/if}
|
|
43
|
+
{#each columns as column (column.id)}
|
|
44
|
+
<QuickSearchCell
|
|
45
|
+
{column}
|
|
46
|
+
customFilters={tableContext.remoteFilters}
|
|
47
|
+
/>
|
|
48
|
+
{/each}
|
|
49
|
+
</tr>
|
|
50
|
+
{/if}
|
|
51
|
+
|
|
52
|
+
{#each tableContext.paginationRowModel.rows as row, index (row.visibleIndex)}
|
|
53
|
+
{@const customHeight = heights[index]?.applyTo.includes(side)
|
|
54
|
+
? heights[index].maxHeight
|
|
55
|
+
: undefined}
|
|
56
|
+
<TableRow
|
|
57
|
+
{customHeight}
|
|
58
|
+
{includeHighlight}
|
|
59
|
+
{row}
|
|
60
|
+
{side}
|
|
61
|
+
odd={index % 2 == 1}
|
|
62
|
+
bind:this={rows[index]}
|
|
63
|
+
/>
|
|
64
|
+
{/each}
|
|
65
|
+
</tbody>
|
|
66
|
+
|
|
67
67
|
<style>td {
|
|
68
68
|
transition: line-height 0.2s ease, height 0.2s ease;
|
|
69
69
|
--input-border: none;
|
|
@@ -90,4 +90,4 @@ tr.sticky {
|
|
|
90
90
|
transition: line-height 0.2s ease, height 0.2s ease;
|
|
91
91
|
height: 61px;
|
|
92
92
|
--height: 61px;
|
|
93
|
-
}</style>
|
|
93
|
+
}</style>
|