@lavalogic/scoria 0.40.1 → 0.40.3
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 +46 -46
- package/dist/Components/AccordionGroupButton.svelte +76 -76
- package/dist/Components/Action.svelte +136 -136
- package/dist/Components/AlertModal.svelte +195 -195
- package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +729 -729
- package/dist/Components/Base/BaseModal.svelte +125 -125
- package/dist/Components/Base/ContextWrapper.svelte +72 -72
- package/dist/Components/Base/Pagination.svelte +198 -198
- package/dist/Components/Base/Snippets.svelte +36 -36
- package/dist/Components/BigRadioSet.svelte +38 -38
- package/dist/Components/Bubble.svelte +101 -101
- package/dist/Components/Button.svelte +209 -209
- package/dist/Components/Checkbox.svelte +86 -86
- package/dist/Components/CollapsibleCard.svelte +78 -78
- package/dist/Components/Contexts/ContextMenu.svelte +164 -164
- package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
- package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
- package/dist/Components/Contexts/Toast.svelte +86 -86
- package/dist/Components/Contexts/ToastContainer.svelte +65 -65
- package/dist/Components/Contexts/Tooltip.svelte +37 -37
- package/dist/Components/DataMatrixIcon.svelte +112 -112
- package/dist/Components/DateInput.svelte +148 -148
- package/dist/Components/DatePicker.svelte +300 -300
- package/dist/Components/DesktopModal.svelte +90 -90
- package/dist/Components/Dial.svelte +204 -204
- package/dist/Components/DimensionInput.svelte +170 -170
- package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
- package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
- package/dist/Components/FileCard.svelte +24 -24
- package/dist/Components/FileUpload.svelte +236 -236
- package/dist/Components/GridInput.svelte +196 -196
- package/dist/Components/GridInputSet.svelte +29 -29
- package/dist/Components/HorizontalTabGroup.svelte +82 -82
- package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
- package/dist/Components/Icon.svelte +128 -128
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/InfoAlert.svelte +35 -35
- package/dist/Components/LoadingAnimation.svelte +29 -29
- package/dist/Components/LoadingModal.svelte +45 -45
- package/dist/Components/LoadingOverlay.svelte +25 -25
- package/dist/Components/Modal.svelte +258 -258
- package/dist/Components/MultiSelect.svelte +220 -220
- package/dist/Components/Nav/Nav.svelte +110 -110
- package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
- package/dist/Components/Nav/NavTab.svelte +62 -62
- package/dist/Components/Nav/ServiceMenuItem.svelte +112 -112
- package/dist/Components/Nav/ServicesNav.svelte +80 -80
- package/dist/Components/NumberInput.svelte +157 -157
- package/dist/Components/PageHeading.svelte +25 -25
- package/dist/Components/PasswordInput.svelte +88 -88
- package/dist/Components/Portal.svelte +36 -36
- package/dist/Components/ProgressBubble.svelte +107 -107
- package/dist/Components/QuerySelect.svelte +366 -366
- package/dist/Components/SingleSelect.svelte +250 -250
- package/dist/Components/StepButton.svelte +70 -70
- package/dist/Components/StepForm.svelte +140 -140
- package/dist/Components/Switch.svelte +69 -69
- package/dist/Components/Table/ARCHITECTURE.md +298 -298
- package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -679
- package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +454 -454
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -185
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +163 -120
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +234 -234
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +160 -126
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -252
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -221
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
- package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
- package/dist/Components/Table/Body/TableBody.svelte +155 -155
- package/dist/Components/Table/ColumnFactory.svelte.js +7 -0
- package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
- package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
- package/dist/Components/Table/Headers/TableHead.svelte +415 -415
- package/dist/Components/Table/Misc/ColumnPanel.svelte +39 -39
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +39 -39
- package/dist/Components/Table/Misc/FilterInput.svelte +641 -641
- package/dist/Components/Table/Misc/FilterPanel.svelte +190 -190
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +31 -31
- package/dist/Components/Table/Misc/ShareViewModal.svelte +291 -291
- package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
- package/dist/Components/Table/Misc/TableConfigurationModal.svelte +644 -644
- package/dist/Components/Table/Misc/TableFooter.svelte +340 -340
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +140 -140
- package/dist/Components/Table/Misc/TableSidebar.svelte +200 -200
- package/dist/Components/Table/Misc/TableViewDropdown.svelte +105 -105
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
- package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +192 -192
- package/dist/Components/Table/NestedTable.svelte +130 -130
- package/dist/Components/Table/Table.svelte +692 -692
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +9 -0
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.js +6 -0
- package/dist/Components/Table/Types/Public/ColumnOptions.d.ts +19 -0
- package/dist/Components/Test/TestContextConsumer.svelte +13 -13
- package/dist/Components/TextArea.svelte +130 -130
- package/dist/Components/TextInput.svelte +176 -176
- package/dist/Components/ThreeStateRadio.svelte +131 -131
- package/dist/Components/Touch/BoolCard.svelte +45 -45
- package/dist/Components/Touch/DateModal.svelte +209 -209
- package/dist/Components/Touch/EditCard.svelte +59 -59
- package/dist/Components/Touch/InfoCard.svelte +31 -31
- package/dist/Components/Touch/InfoTextCard.svelte +28 -28
- package/dist/Components/Touch/ModalExplanation.svelte +17 -17
- package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
- package/dist/Components/Touch/NumberModal.svelte +79 -79
- package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
- package/dist/Components/Touch/SelectModal.svelte +127 -127
- package/dist/Components/Touch/SummaryCard.svelte +93 -93
- package/dist/Components/Touch/TextAreaModal.svelte +95 -95
- package/dist/Components/Touch/TextModal.svelte +106 -106
- package/dist/Components/Touch/TouchCard.svelte +33 -33
- package/dist/Components/Touch/TouchModal.svelte +274 -274
- package/dist/Components/Touch/UtilityButton.svelte +109 -109
- package/dist/Components/VerticalTabGroup.svelte +79 -79
- package/dist/Components/VerticalTabGroupButton.svelte +58 -58
- package/dist/Helpers/Datamatrix.d.ts +19 -19
- package/dist/Helpers/Datamatrix.js +291 -291
- package/dist/Types/Examples/ExampleModal.svelte +35 -35
- package/dist/scss/_basics.scss +12 -12
- package/dist/scss/_colours.scss +134 -134
- package/dist/scss/_mixins.scss +3392 -3392
- package/dist/scss/_motion.scss +57 -57
- package/dist/scss/_sizing.scss +85 -85
- package/dist/scss/_transitions.scss +8 -8
- package/package.json +1 -1
|
@@ -1,128 +1,157 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="T extends object, RowIdType extends Primitive"
|
|
6
|
-
>
|
|
7
|
-
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
8
|
-
import { type Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
9
|
-
import type { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
10
|
-
import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
11
|
-
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
12
|
-
import { getContext, tick } from 'svelte';
|
|
13
|
-
import type { ChangeEventHandler } from 'svelte/elements';
|
|
14
|
-
import type { TableCheckboxProps } from './TableCheckboxProps.js';
|
|
15
|
-
|
|
16
|
-
const { cell, onchange: parentOnchange }: TableCheckboxProps<T> = $props();
|
|
17
|
-
|
|
18
|
-
const value = $derived(!!cell.getValue());
|
|
19
|
-
|
|
20
|
-
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
21
|
-
|
|
22
|
-
const focusDetails: TableFocusDetails<T, RowIdType> = $derived(
|
|
23
|
-
tableContext._focus.getFocusDetailsFor(cell)
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object, RowIdType extends Primitive"
|
|
6
|
+
>
|
|
7
|
+
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
8
|
+
import { type Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
9
|
+
import type { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
10
|
+
import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
11
|
+
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
12
|
+
import { getContext, tick } from 'svelte';
|
|
13
|
+
import type { ChangeEventHandler } from 'svelte/elements';
|
|
14
|
+
import type { TableCheckboxProps } from './TableCheckboxProps.js';
|
|
15
|
+
|
|
16
|
+
const { cell, onchange: parentOnchange }: TableCheckboxProps<T> = $props();
|
|
17
|
+
|
|
18
|
+
const value = $derived(!!cell.getValue());
|
|
19
|
+
|
|
20
|
+
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
21
|
+
|
|
22
|
+
const focusDetails: TableFocusDetails<T, RowIdType> = $derived(
|
|
23
|
+
tableContext._focus.getFocusDetailsFor(cell)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Resolve the column's (possibly async) `isEditable` predicate for this
|
|
27
|
+
// row. A non-editable checkbox renders disabled (read-only) rather than
|
|
28
|
+
// toggling — mirrors how the inline-edit cells gate on `isEditable`.
|
|
29
|
+
const editableAsync = $derived(
|
|
30
|
+
cell.column.columnDef.isEditable(cell.row.original, cell.row.originalIndex)
|
|
31
|
+
);
|
|
32
|
+
let editable = $state(false);
|
|
33
|
+
let editableCounter = 0;
|
|
34
|
+
$effect(() => {
|
|
35
|
+
void editableAsync;
|
|
36
|
+
const local = (editableCounter = editableCounter + 1);
|
|
37
|
+
(async () => {
|
|
38
|
+
try {
|
|
39
|
+
const resolved = await editableAsync;
|
|
40
|
+
if (editableCounter === local) {
|
|
41
|
+
editable = resolved;
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
if (editableCounter === local) {
|
|
45
|
+
editable = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
})().catch(devCatch);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
let inputRef: HTMLInputElement | undefined = $state();
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Commits the new value through `TableContext.onEditCell` and forwards the
|
|
55
|
+
* native event to the optional parent handler. The `tick` reconcile fixes a
|
|
56
|
+
* race where the table edit was rejected by validation but the input
|
|
57
|
+
* already showed the new checked state.
|
|
58
|
+
*/
|
|
59
|
+
const onchange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
|
60
|
+
if (!editable) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
tableContext
|
|
64
|
+
.onEditCell(
|
|
65
|
+
cell.row.original,
|
|
66
|
+
focusDetails.coordinates,
|
|
67
|
+
(e.target as HTMLInputElement).checked
|
|
68
|
+
)
|
|
69
|
+
.catch(devCatch);
|
|
70
|
+
parentOnchange?.(e);
|
|
71
|
+
|
|
72
|
+
tick()
|
|
73
|
+
.then(() => {
|
|
74
|
+
if (inputRef && value != inputRef.checked) {
|
|
75
|
+
inputRef.checked = value;
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.catch(devCatch);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
let validity: Validity = $state(Validity.Valid);
|
|
82
|
+
$effect(() => {
|
|
83
|
+
const validityPromise = focusDetails.validity;
|
|
84
|
+
|
|
85
|
+
validityPromise
|
|
86
|
+
.then((v) => {
|
|
87
|
+
if (!v) {
|
|
88
|
+
validity = Validity.Neutral;
|
|
89
|
+
} else if (isValidityTuple(v)) {
|
|
90
|
+
validity = v.value;
|
|
91
|
+
} else {
|
|
92
|
+
validity = v;
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
.catch(devCatch);
|
|
96
|
+
});
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
|
100
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
101
|
+
<div
|
|
102
|
+
class="checkbox-cell"
|
|
103
|
+
onmousedown={(e) => {
|
|
104
|
+
// start focus only on left click
|
|
105
|
+
if (e.button === 0) {
|
|
106
|
+
if (e.shiftKey) {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
tableContext.setFocusEnd(focusDetails.coordinates);
|
|
109
|
+
} else {
|
|
110
|
+
tableContext.startFocus(focusDetails.coordinates);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}}
|
|
114
|
+
onkeyup={(e: KeyboardEvent) => {
|
|
115
|
+
if (e.key === 'Enter' && editable) {
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
tableContext.onEditCell(cell.row.original, focusDetails.coordinates, !value).catch(devCatch);
|
|
118
|
+
}
|
|
119
|
+
}}
|
|
120
|
+
onkeydown={(e: KeyboardEvent) => {
|
|
121
|
+
if (e.key == 'Enter' || e.key == 'F2') {
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
}
|
|
124
|
+
}}
|
|
125
|
+
onmouseover={() => {
|
|
126
|
+
if (tableContext.isMousingDown) {
|
|
127
|
+
tableContext.setFocusEnd(focusDetails.coordinates);
|
|
128
|
+
}
|
|
129
|
+
}}
|
|
130
|
+
onmouseup={() => {
|
|
131
|
+
tableContext.endFocus(focusDetails.coordinates);
|
|
132
|
+
}}
|
|
133
|
+
class:info={validity == Validity.Info}
|
|
134
|
+
class:success={validity == Validity.Valid}
|
|
135
|
+
class:warning={validity == Validity.Warning}
|
|
136
|
+
class:error={validity == Validity.Invalid}
|
|
137
|
+
>
|
|
138
|
+
|
|
139
|
+
<label
|
|
140
|
+
class:multifocus={focusDetails.isMultiFocused}
|
|
141
|
+
class:multifocus-start={focusDetails.isMultiFocusStart}
|
|
142
|
+
style={focusDetails.outline}
|
|
143
|
+
>
|
|
144
|
+
<input
|
|
145
|
+
bind:this={inputRef}
|
|
146
|
+
id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
|
|
147
|
+
{onchange}
|
|
148
|
+
type="checkbox"
|
|
149
|
+
checked={value}
|
|
150
|
+
disabled={!editable}
|
|
151
|
+
/>
|
|
152
|
+
</label>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
126
155
|
<style>.focusable,
|
|
127
156
|
.checkbox-cell,
|
|
128
157
|
.input-cell,
|
|
@@ -198,4 +227,9 @@ label.multifocus.multifocus-start {
|
|
|
198
227
|
.input-cell.error,
|
|
199
228
|
.select-cell.error {
|
|
200
229
|
background-color: #f9e9e9;
|
|
201
|
-
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
input:disabled {
|
|
233
|
+
cursor: not-allowed;
|
|
234
|
+
opacity: 0.45;
|
|
235
|
+
}</style>
|
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
module
|
|
6
|
-
>
|
|
7
|
-
import { ExpandDef } from '../../../Types/Columns/Definitions/Expand/ExpandDef.svelte.js';
|
|
8
|
-
import { DisplayType } from '../../../Types/Columns/DisplayType.js';
|
|
9
|
-
import type { TableCell } from '../../../Types/Columns/TableCell.js';
|
|
10
|
-
import type { Component, Snippet } from 'svelte';
|
|
11
|
-
import ActionsCell from './ActionsCell.svelte';
|
|
12
|
-
import BubbleCell from './BubbleCell.svelte';
|
|
13
|
-
import ExpandCell from './ExpandCell.svelte';
|
|
14
|
-
import FocusableImmutableCell from './FocusableImmutableCell.svelte';
|
|
15
|
-
|
|
16
|
-
import { ColumnType } from '../../../Types/Columns/ColumnType.js';
|
|
17
|
-
import { ActionsDef } from '../../../Types/Columns/Definitions/Actions/ActionsDef.svelte.js';
|
|
18
|
-
import { AbstractDisplayDef } from '../../../Types/Columns/Definitions/Display/AbstractDisplayDef.svelte.js';
|
|
19
|
-
import { ProgressBarDef } from '../../../Types/Columns/Definitions/Display/ProgressBarDef.svelte.js';
|
|
20
|
-
import type { ExpandTableCell } from '../../../Types/Columns/ExpandTableCell.js';
|
|
21
|
-
import type { ProgressBarTableCell } from '../../../Types/Columns/ProgressBarTableCell.js';
|
|
22
|
-
import { getErrorMessage } from '../../../../../Helpers/Helpers.svelte.js';
|
|
23
|
-
import AccessorComponent from './AccessorComponent.svelte';
|
|
24
|
-
import type { ActionsTableCell } from './ActionsTableCell.js';
|
|
25
|
-
import ProgressCell from './ProgressCell.svelte';
|
|
26
|
-
import TableRowSelectionCheckbox from './TableRowSelectionCheckbox.svelte';
|
|
27
|
-
import type { TableColumnProps } from './TableColumnProps.js';
|
|
28
|
-
import ValidityCell from './ValidityCell.svelte';
|
|
29
|
-
|
|
30
|
-
/** Narrowing type-guard distinguishing a progress-bar cell by its `columnDef` instance. */
|
|
31
|
-
function isProgressBarTableCell<T extends object>(
|
|
32
|
-
cell: TableCell<T>
|
|
33
|
-
): cell is ProgressBarTableCell<T, unknown> {
|
|
34
|
-
return cell.column.columnDef instanceof ProgressBarDef;
|
|
35
|
-
}
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
<script
|
|
39
|
-
lang="ts"
|
|
40
|
-
generics="T extends object"
|
|
41
|
-
>
|
|
42
|
-
import { dev } from '$app/environment';
|
|
43
|
-
import { RowSelectionDef } from '../../../Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.js';
|
|
44
|
-
import type { Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
45
|
-
import type { RowSelectionTableCell } from './RowSelectionTableCell.js';
|
|
46
|
-
|
|
47
|
-
let { cell, expandedColumnDef, onExpandChange }: TableColumnProps<T> = $props();
|
|
48
|
-
|
|
49
|
-
/** Narrowing type-guard distinguishing the row-selection cell. */
|
|
50
|
-
function isRowSelectionCell<T extends object>(
|
|
51
|
-
cell: TableCell<T>
|
|
52
|
-
): cell is RowSelectionTableCell<T> {
|
|
53
|
-
return cell.column.columnDef instanceof RowSelectionDef;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Returns true when the accessor output is a Svelte component constructor.
|
|
58
|
-
* Distinguishing a Svelte 5 component (a function) from a snippet is a
|
|
59
|
-
* runtime-only heuristic (both are typeof 'function'); the
|
|
60
|
-
* constructor-only branch is reached first because TableColumn checks
|
|
61
|
-
* `valueOrComponentIsConstructor` before `isSnippet`. Tightening this to
|
|
62
|
-
* a real type-level discriminator is tracked under the
|
|
63
|
-
* RowGenericThreading follow-up.
|
|
64
|
-
*/
|
|
65
|
-
function valueOrComponentIsConstructor(
|
|
66
|
-
valueOrComponent: unknown
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
): valueOrComponent is Component<any> {
|
|
69
|
-
return typeof valueOrComponent === 'function';
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Narrowing type-guard distinguishing an actions cell. */
|
|
73
|
-
function isActionsDef(cell: TableCell<T>): cell is ActionsTableCell<T, unknown> {
|
|
74
|
-
return cell.column.columnDef instanceof ActionsDef;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Narrowing type-guard distinguishing the expand-row cell. */
|
|
78
|
-
function isExpandTableCell(
|
|
79
|
-
cell: TableCell<T>
|
|
80
|
-
): cell is ExpandTableCell<T, object, Primitive, unknown> {
|
|
81
|
-
return cell.column.columnDef instanceof ExpandDef;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Heuristic snippet check; both Snippets and Components are functions at runtime. */
|
|
85
|
-
function isSnippet(value: unknown): value is Snippet<[TableCell<T>]> {
|
|
86
|
-
return !!value && typeof value == 'function';
|
|
87
|
-
}
|
|
88
|
-
</script>
|
|
89
|
-
|
|
90
|
-
{#if cell.column.getIsVisible()}
|
|
91
|
-
{@const columnDef = cell.column.columnDef}
|
|
92
|
-
|
|
93
|
-
{#if isRowSelectionCell(cell)}
|
|
94
|
-
<TableRowSelectionCheckbox {cell} />
|
|
95
|
-
{:else if isActionsDef(cell)}
|
|
96
|
-
<ActionsCell {cell} />
|
|
97
|
-
{:else if isExpandTableCell(cell)}
|
|
98
|
-
<ExpandCell
|
|
99
|
-
{cell}
|
|
100
|
-
{expandedColumnDef}
|
|
101
|
-
{onExpandChange}
|
|
102
|
-
/>
|
|
103
|
-
{:else if columnDef.columnType !== ColumnType.Display}
|
|
104
|
-
<AccessorComponent {cell} />
|
|
105
|
-
{:else if cell.column.columnDef instanceof AbstractDisplayDef}
|
|
106
|
-
{#if cell.column.columnDef.displayType === DisplayType.Bubbles}
|
|
107
|
-
<BubbleCell {cell} />
|
|
108
|
-
{:else if cell.column.columnDef.displayType === DisplayType.Validity}
|
|
109
|
-
<ValidityCell {cell} />
|
|
110
|
-
{:else if isProgressBarTableCell(cell)}
|
|
111
|
-
<ProgressCell {cell} />
|
|
112
|
-
{:else if cell.column.columnDef.displayType === DisplayType.Normal}
|
|
113
|
-
<FocusableImmutableCell {cell} />
|
|
114
|
-
{:else}
|
|
115
|
-
{#if dev}
|
|
116
|
-
<!-- eslint-disable-next-line svelte/no-at-debug-tags -->
|
|
117
|
-
{@debug cell}
|
|
118
|
-
{/if}
|
|
119
|
-
Unknown Cell Type
|
|
120
|
-
{/if}
|
|
121
|
-
{:else}
|
|
122
|
-
{@const valueOrComponentPromise =
|
|
123
|
-
cell.column.columnDef.accessorFn?.(cell.row.original, cell.row.originalIndex) ??
|
|
124
|
-
cell.row.original[cell.column.id as keyof typeof cell.row.original]}
|
|
125
|
-
|
|
126
|
-
{#await valueOrComponentPromise}
|
|
127
|
-
<FocusableImmutableCell {cell} />
|
|
128
|
-
{:then Value}
|
|
129
|
-
{#if typeof Value === 'string' || typeof Value == 'number'}
|
|
130
|
-
<FocusableImmutableCell {cell} />
|
|
131
|
-
{:else if valueOrComponentIsConstructor(Value)}
|
|
132
|
-
<FocusableImmutableCell {cell}>
|
|
133
|
-
<Value {cell} />
|
|
134
|
-
</FocusableImmutableCell>
|
|
135
|
-
{:else if isSnippet(Value)}
|
|
136
|
-
<FocusableImmutableCell {cell}>
|
|
137
|
-
<!-- eslint-disable-next-line @typescript-eslint/no-unsafe-call -->
|
|
138
|
-
{@render Value(cell)}
|
|
139
|
-
</FocusableImmutableCell>
|
|
140
|
-
{:else}
|
|
141
|
-
{#if dev}
|
|
142
|
-
<!-- eslint-disable-next-line svelte/no-at-debug-tags -->
|
|
143
|
-
{@debug cell}
|
|
144
|
-
<!-- eslint-disable-next-line svelte/no-at-debug-tags -->
|
|
145
|
-
{@debug Value}
|
|
146
|
-
{/if}
|
|
147
|
-
Unknown Cell or value Type
|
|
148
|
-
{/if}
|
|
149
|
-
{:catch e}
|
|
150
|
-
<FocusableImmutableCell {cell}>
|
|
151
|
-
{#if dev}
|
|
152
|
-
{getErrorMessage(e)}
|
|
153
|
-
{:else}
|
|
154
|
-
Error rendering cell
|
|
155
|
-
{/if}
|
|
156
|
-
</FocusableImmutableCell>
|
|
157
|
-
{/await}
|
|
158
|
-
{/if}
|
|
159
|
-
{/if}
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
module
|
|
6
|
+
>
|
|
7
|
+
import { ExpandDef } from '../../../Types/Columns/Definitions/Expand/ExpandDef.svelte.js';
|
|
8
|
+
import { DisplayType } from '../../../Types/Columns/DisplayType.js';
|
|
9
|
+
import type { TableCell } from '../../../Types/Columns/TableCell.js';
|
|
10
|
+
import type { Component, Snippet } from 'svelte';
|
|
11
|
+
import ActionsCell from './ActionsCell.svelte';
|
|
12
|
+
import BubbleCell from './BubbleCell.svelte';
|
|
13
|
+
import ExpandCell from './ExpandCell.svelte';
|
|
14
|
+
import FocusableImmutableCell from './FocusableImmutableCell.svelte';
|
|
15
|
+
|
|
16
|
+
import { ColumnType } from '../../../Types/Columns/ColumnType.js';
|
|
17
|
+
import { ActionsDef } from '../../../Types/Columns/Definitions/Actions/ActionsDef.svelte.js';
|
|
18
|
+
import { AbstractDisplayDef } from '../../../Types/Columns/Definitions/Display/AbstractDisplayDef.svelte.js';
|
|
19
|
+
import { ProgressBarDef } from '../../../Types/Columns/Definitions/Display/ProgressBarDef.svelte.js';
|
|
20
|
+
import type { ExpandTableCell } from '../../../Types/Columns/ExpandTableCell.js';
|
|
21
|
+
import type { ProgressBarTableCell } from '../../../Types/Columns/ProgressBarTableCell.js';
|
|
22
|
+
import { getErrorMessage } from '../../../../../Helpers/Helpers.svelte.js';
|
|
23
|
+
import AccessorComponent from './AccessorComponent.svelte';
|
|
24
|
+
import type { ActionsTableCell } from './ActionsTableCell.js';
|
|
25
|
+
import ProgressCell from './ProgressCell.svelte';
|
|
26
|
+
import TableRowSelectionCheckbox from './TableRowSelectionCheckbox.svelte';
|
|
27
|
+
import type { TableColumnProps } from './TableColumnProps.js';
|
|
28
|
+
import ValidityCell from './ValidityCell.svelte';
|
|
29
|
+
|
|
30
|
+
/** Narrowing type-guard distinguishing a progress-bar cell by its `columnDef` instance. */
|
|
31
|
+
function isProgressBarTableCell<T extends object>(
|
|
32
|
+
cell: TableCell<T>
|
|
33
|
+
): cell is ProgressBarTableCell<T, unknown> {
|
|
34
|
+
return cell.column.columnDef instanceof ProgressBarDef;
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<script
|
|
39
|
+
lang="ts"
|
|
40
|
+
generics="T extends object"
|
|
41
|
+
>
|
|
42
|
+
import { dev } from '$app/environment';
|
|
43
|
+
import { RowSelectionDef } from '../../../Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.js';
|
|
44
|
+
import type { Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
45
|
+
import type { RowSelectionTableCell } from './RowSelectionTableCell.js';
|
|
46
|
+
|
|
47
|
+
let { cell, expandedColumnDef, onExpandChange }: TableColumnProps<T> = $props();
|
|
48
|
+
|
|
49
|
+
/** Narrowing type-guard distinguishing the row-selection cell. */
|
|
50
|
+
function isRowSelectionCell<T extends object>(
|
|
51
|
+
cell: TableCell<T>
|
|
52
|
+
): cell is RowSelectionTableCell<T> {
|
|
53
|
+
return cell.column.columnDef instanceof RowSelectionDef;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns true when the accessor output is a Svelte component constructor.
|
|
58
|
+
* Distinguishing a Svelte 5 component (a function) from a snippet is a
|
|
59
|
+
* runtime-only heuristic (both are typeof 'function'); the
|
|
60
|
+
* constructor-only branch is reached first because TableColumn checks
|
|
61
|
+
* `valueOrComponentIsConstructor` before `isSnippet`. Tightening this to
|
|
62
|
+
* a real type-level discriminator is tracked under the
|
|
63
|
+
* RowGenericThreading follow-up.
|
|
64
|
+
*/
|
|
65
|
+
function valueOrComponentIsConstructor(
|
|
66
|
+
valueOrComponent: unknown
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
): valueOrComponent is Component<any> {
|
|
69
|
+
return typeof valueOrComponent === 'function';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Narrowing type-guard distinguishing an actions cell. */
|
|
73
|
+
function isActionsDef(cell: TableCell<T>): cell is ActionsTableCell<T, unknown> {
|
|
74
|
+
return cell.column.columnDef instanceof ActionsDef;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Narrowing type-guard distinguishing the expand-row cell. */
|
|
78
|
+
function isExpandTableCell(
|
|
79
|
+
cell: TableCell<T>
|
|
80
|
+
): cell is ExpandTableCell<T, object, Primitive, unknown> {
|
|
81
|
+
return cell.column.columnDef instanceof ExpandDef;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Heuristic snippet check; both Snippets and Components are functions at runtime. */
|
|
85
|
+
function isSnippet(value: unknown): value is Snippet<[TableCell<T>]> {
|
|
86
|
+
return !!value && typeof value == 'function';
|
|
87
|
+
}
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
{#if cell.column.getIsVisible()}
|
|
91
|
+
{@const columnDef = cell.column.columnDef}
|
|
92
|
+
|
|
93
|
+
{#if isRowSelectionCell(cell)}
|
|
94
|
+
<TableRowSelectionCheckbox {cell} />
|
|
95
|
+
{:else if isActionsDef(cell)}
|
|
96
|
+
<ActionsCell {cell} />
|
|
97
|
+
{:else if isExpandTableCell(cell)}
|
|
98
|
+
<ExpandCell
|
|
99
|
+
{cell}
|
|
100
|
+
{expandedColumnDef}
|
|
101
|
+
{onExpandChange}
|
|
102
|
+
/>
|
|
103
|
+
{:else if columnDef.columnType !== ColumnType.Display}
|
|
104
|
+
<AccessorComponent {cell} />
|
|
105
|
+
{:else if cell.column.columnDef instanceof AbstractDisplayDef}
|
|
106
|
+
{#if cell.column.columnDef.displayType === DisplayType.Bubbles}
|
|
107
|
+
<BubbleCell {cell} />
|
|
108
|
+
{:else if cell.column.columnDef.displayType === DisplayType.Validity}
|
|
109
|
+
<ValidityCell {cell} />
|
|
110
|
+
{:else if isProgressBarTableCell(cell)}
|
|
111
|
+
<ProgressCell {cell} />
|
|
112
|
+
{:else if cell.column.columnDef.displayType === DisplayType.Normal}
|
|
113
|
+
<FocusableImmutableCell {cell} />
|
|
114
|
+
{:else}
|
|
115
|
+
{#if dev}
|
|
116
|
+
<!-- eslint-disable-next-line svelte/no-at-debug-tags -->
|
|
117
|
+
{@debug cell}
|
|
118
|
+
{/if}
|
|
119
|
+
Unknown Cell Type
|
|
120
|
+
{/if}
|
|
121
|
+
{:else}
|
|
122
|
+
{@const valueOrComponentPromise =
|
|
123
|
+
cell.column.columnDef.accessorFn?.(cell.row.original, cell.row.originalIndex) ??
|
|
124
|
+
cell.row.original[cell.column.id as keyof typeof cell.row.original]}
|
|
125
|
+
|
|
126
|
+
{#await valueOrComponentPromise}
|
|
127
|
+
<FocusableImmutableCell {cell} />
|
|
128
|
+
{:then Value}
|
|
129
|
+
{#if typeof Value === 'string' || typeof Value == 'number'}
|
|
130
|
+
<FocusableImmutableCell {cell} />
|
|
131
|
+
{:else if valueOrComponentIsConstructor(Value)}
|
|
132
|
+
<FocusableImmutableCell {cell}>
|
|
133
|
+
<Value {cell} />
|
|
134
|
+
</FocusableImmutableCell>
|
|
135
|
+
{:else if isSnippet(Value)}
|
|
136
|
+
<FocusableImmutableCell {cell}>
|
|
137
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-unsafe-call -->
|
|
138
|
+
{@render Value(cell)}
|
|
139
|
+
</FocusableImmutableCell>
|
|
140
|
+
{:else}
|
|
141
|
+
{#if dev}
|
|
142
|
+
<!-- eslint-disable-next-line svelte/no-at-debug-tags -->
|
|
143
|
+
{@debug cell}
|
|
144
|
+
<!-- eslint-disable-next-line svelte/no-at-debug-tags -->
|
|
145
|
+
{@debug Value}
|
|
146
|
+
{/if}
|
|
147
|
+
Unknown Cell or value Type
|
|
148
|
+
{/if}
|
|
149
|
+
{:catch e}
|
|
150
|
+
<FocusableImmutableCell {cell}>
|
|
151
|
+
{#if dev}
|
|
152
|
+
{getErrorMessage(e)}
|
|
153
|
+
{:else}
|
|
154
|
+
Error rendering cell
|
|
155
|
+
{/if}
|
|
156
|
+
</FocusableImmutableCell>
|
|
157
|
+
{/await}
|
|
158
|
+
{/if}
|
|
159
|
+
{/if}
|