@lavalogic/scoria 0.17.2 → 0.18.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/dist/Components/Table/Body/QuickSearchCell.svelte +78 -73
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +1 -1
- package/dist/Components/Table/Body/Rows/ColumnListRowProps.d.ts +1 -1
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +12 -6
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +15 -35
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +15 -35
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +35 -4
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +60 -26
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +14 -35
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +35 -5
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +82 -139
- package/dist/Components/Table/Body/Rows/Columns/TableDatePickerProps.d.ts +1 -1
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +15 -35
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte.d.ts +1 -2
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +14 -34
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +93 -37
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte.d.ts +12 -13
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +14 -34
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +14 -34
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +40 -61
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte.d.ts +12 -11
- package/dist/Components/Table/ColumnDefinitions/ExampleItemColumnDefRepository.svelte.js +39 -29
- package/dist/Components/Table/Misc/FilterInput.svelte +1 -1
- package/dist/Components/Table/Table.svelte +15 -16
- package/dist/Components/Table/Types/Columns/DateColumn.d.ts +2 -2
- package/dist/Components/Table/Types/Columns/DateTableCell.d.ts +2 -2
- package/dist/Components/Table/Types/Columns/Definitions/ColumnDefSet.d.ts +1 -1
- package/dist/Components/Table/Types/Columns/Definitions/JSONColumnDefSet.d.ts +1 -1
- package/dist/Components/Table/Types/Columns/Definitions/ValidationFn.d.ts +1 -1
- package/dist/Components/Table/Types/Context/ITable.d.ts +0 -1
- package/dist/Components/Table/Types/Context/Row.d.ts +3 -3
- package/dist/Components/Table/Types/Context/TableContext.svelte.d.ts +16 -22
- package/dist/Components/Table/Types/Context/TableContext.svelte.js +299 -275
- package/dist/Components/Table/Types/DataRepository/IDataRepository.d.ts +1 -1
- package/dist/Components/Table/Types/DataRepository/ILocalDataRepository.d.ts +1 -1
- package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.d.ts +2 -2
- package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.js +23 -7
- package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.d.ts +2 -2
- package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.js +2 -4
- package/dist/Components/Table/Types/Focus/TableFocusDetails.svelte.d.ts +18 -36
- package/dist/Components/Table/Types/Focus/TableFocusDetails.svelte.js +77 -113
- package/dist/Components/TextInput.svelte +11 -4
- package/dist/Components/Touch/DateModal.svelte +26 -14
- package/dist/Helpers/Helpers.svelte.d.ts +5 -1
- package/dist/Helpers/Helpers.svelte.js +9 -10
- package/package.json +14 -14
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
import type { QueryDef } from '../../../Types/Columns/Definitions/Accessors/QueryDef.svelte.js';
|
|
10
10
|
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
11
11
|
import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
12
|
-
import {
|
|
13
|
-
import { devCatch } from '../../../../../Helpers/Helpers.svelte.js';
|
|
12
|
+
import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
14
13
|
import type { SelectOption } from '../../../../../Types/Internal/SelectOption.js';
|
|
15
14
|
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
16
15
|
import { getContext, tick, untrack } from 'svelte';
|
|
@@ -32,7 +31,6 @@
|
|
|
32
31
|
let lastOptions: Array<SelectOption<unknown>> = $state([]);
|
|
33
32
|
|
|
34
33
|
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
35
|
-
const { toast } = getContext<ToastContext>(ToastContext.identifier);
|
|
36
34
|
|
|
37
35
|
const editableAsync = $derived(
|
|
38
36
|
cell.column.columnDef.isEditable(cell.row.original, cell.row.originalIndex)
|
|
@@ -105,8 +103,8 @@
|
|
|
105
103
|
});
|
|
106
104
|
});
|
|
107
105
|
|
|
108
|
-
const focusDetails: TableFocusDetails<T> = $derived(
|
|
109
|
-
new TableFocusDetails(cell, tableContext
|
|
106
|
+
const focusDetails: TableFocusDetails<T, never> = $derived(
|
|
107
|
+
new TableFocusDetails(cell, tableContext)
|
|
110
108
|
);
|
|
111
109
|
|
|
112
110
|
const wantsToBeEdited = $derived(
|
|
@@ -156,41 +154,23 @@
|
|
|
156
154
|
}
|
|
157
155
|
});
|
|
158
156
|
|
|
159
|
-
let previousValidity: Validity = $state(Validity.Valid);
|
|
160
157
|
let validity: Validity = $state(Validity.Valid);
|
|
161
158
|
$effect(() => {
|
|
162
|
-
focusDetails.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
159
|
+
const validityPromise = focusDetails.validity;
|
|
160
|
+
|
|
161
|
+
validityPromise
|
|
162
|
+
.then((v) => {
|
|
163
|
+
if (!v) {
|
|
164
|
+
validity = Validity.Neutral;
|
|
165
|
+
} else if (isValidityTuple(v)) {
|
|
166
|
+
validity = v.value;
|
|
167
|
+
} else {
|
|
168
|
+
validity = v;
|
|
169
|
+
}
|
|
171
170
|
})
|
|
172
171
|
.catch(devCatch);
|
|
173
172
|
});
|
|
174
173
|
|
|
175
|
-
$effect(() => {
|
|
176
|
-
if (validity != previousValidity) {
|
|
177
|
-
untrack(() => {
|
|
178
|
-
tick()
|
|
179
|
-
.then(() => {
|
|
180
|
-
const x =
|
|
181
|
-
validity === Validity.Invalid
|
|
182
|
-
? tableContext.addInvalidValue(cell.row.original)
|
|
183
|
-
: tableContext.removeInvalidValue(cell.row.original);
|
|
184
|
-
|
|
185
|
-
previousValidity = validity;
|
|
186
|
-
|
|
187
|
-
return x;
|
|
188
|
-
})
|
|
189
|
-
.catch(devCatch);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
174
|
const handleTDFocus = () => {
|
|
195
175
|
if (
|
|
196
176
|
editable &&
|
|
@@ -7,36 +7,33 @@
|
|
|
7
7
|
import type { RowSelectionDef } from '../../../Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.js';
|
|
8
8
|
import type { TableCell } from '../../../Types/Columns/TableCell.js';
|
|
9
9
|
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
10
|
+
import { type Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
10
11
|
import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { getContext } from 'svelte';
|
|
12
|
+
import { devCatch, getErrorMessage, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
13
|
+
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
14
|
+
import { getContext, tick, untrack } from 'svelte';
|
|
14
15
|
import type { ChangeEventHandler } from 'svelte/elements';
|
|
15
16
|
|
|
16
17
|
export interface TableCheckboxProps<T extends object> {
|
|
17
18
|
cell: TableCell<T>;
|
|
18
|
-
|
|
19
|
-
onchange?: ChangeEventHandler<HTMLInputElement>;
|
|
20
19
|
}
|
|
21
20
|
</script>
|
|
22
21
|
|
|
23
22
|
<script
|
|
24
23
|
lang="ts"
|
|
25
|
-
generics="T extends object,"
|
|
24
|
+
generics="T extends object,RowIdType extends Primitive"
|
|
26
25
|
>
|
|
27
|
-
const { cell
|
|
26
|
+
const { cell }: TableCheckboxProps<T> = $props();
|
|
28
27
|
|
|
29
|
-
const tableContext = getContext<TableContext<T,
|
|
30
|
-
const toastContext = getContext<ToastContext>(ToastContext.identifier);
|
|
28
|
+
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
31
29
|
|
|
32
|
-
const focusDetails: TableFocusDetails<T> = $derived(
|
|
33
|
-
new TableFocusDetails(cell, tableContext
|
|
30
|
+
const focusDetails: TableFocusDetails<T, RowIdType> = $derived(
|
|
31
|
+
new TableFocusDetails(cell, tableContext)
|
|
34
32
|
);
|
|
35
33
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const keyPromise: Promise<RowIdType> = $derived(
|
|
35
|
+
tableContext.selectionExtractor(cell.row.original)
|
|
36
|
+
);
|
|
40
37
|
const isSelectable = $derived(
|
|
41
38
|
(cell.column.columnDef as RowSelectionDef<T>).isSelectable(
|
|
42
39
|
cell.row.original,
|
|
@@ -44,11 +41,54 @@
|
|
|
44
41
|
)
|
|
45
42
|
);
|
|
46
43
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const isSelectedPromise = $derived.by(async () => {
|
|
45
|
+
void keyPromise;
|
|
46
|
+
void isSelectable;
|
|
47
|
+
void tableContext.selectedItems.size;
|
|
48
|
+
|
|
49
|
+
const key = await keyPromise;
|
|
50
|
+
|
|
51
|
+
return tableContext.selectedItems.has(key);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
let previousValidity: Validity = $state(Validity.Valid);
|
|
55
|
+
let validity: Validity = $state(Validity.Valid);
|
|
56
|
+
$effect(() => {
|
|
57
|
+
const validityPromise = focusDetails.validity;
|
|
58
|
+
|
|
59
|
+
validityPromise
|
|
60
|
+
.then((v) => {
|
|
61
|
+
if (!v) {
|
|
62
|
+
validity = Validity.Neutral;
|
|
63
|
+
} else if (isValidityTuple(v)) {
|
|
64
|
+
validity = v.value;
|
|
65
|
+
} else {
|
|
66
|
+
validity = v;
|
|
67
|
+
}
|
|
68
|
+
})
|
|
50
69
|
.catch(devCatch);
|
|
51
|
-
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
$effect(() => {
|
|
73
|
+
if (validity != previousValidity) {
|
|
74
|
+
untrack(() => {
|
|
75
|
+
tick()
|
|
76
|
+
.then(() => {
|
|
77
|
+
const x: Promise<void> =
|
|
78
|
+
validity === Validity.Invalid
|
|
79
|
+
? tableContext.addInvalidValue(cell.row.original)
|
|
80
|
+
: tableContext.removeInvalidValue(cell.row.original);
|
|
81
|
+
|
|
82
|
+
previousValidity = validity;
|
|
83
|
+
return x;
|
|
84
|
+
})
|
|
85
|
+
.catch(devCatch);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const onchange: ChangeEventHandler<HTMLInputElement> = () => {
|
|
91
|
+
tableContext.toggleSelected(cell.row.original).catch(devCatch);
|
|
52
92
|
};
|
|
53
93
|
|
|
54
94
|
let inputRef: HTMLInputElement | undefined = $state();
|
|
@@ -57,6 +97,10 @@
|
|
|
57
97
|
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
|
58
98
|
<td
|
|
59
99
|
class="checkbox-cell"
|
|
100
|
+
class:info={validity == Validity.Info}
|
|
101
|
+
class:success={validity == Validity.Valid}
|
|
102
|
+
class:warning={validity == Validity.Warning}
|
|
103
|
+
class:error={validity == Validity.Invalid}
|
|
60
104
|
onmousedown={(e) => {
|
|
61
105
|
// start focus only on left click
|
|
62
106
|
if (e.button === 0) {
|
|
@@ -76,7 +120,8 @@
|
|
|
76
120
|
onkeyup={(e) => {
|
|
77
121
|
if (e.key === 'Enter') {
|
|
78
122
|
e.stopPropagation();
|
|
79
|
-
|
|
123
|
+
|
|
124
|
+
tableContext.toggleSelected(cell.row.original).catch(devCatch);
|
|
80
125
|
|
|
81
126
|
inputRef?.dispatchEvent(new InputEvent('change'));
|
|
82
127
|
// tableContext.onEditCell(cell.row.original, focusDetails.coordinates, !value);
|
|
@@ -96,27 +141,28 @@
|
|
|
96
141
|
class:multifocus-start={focusDetails.isMultiFocusStart}
|
|
97
142
|
style={focusDetails.outline}
|
|
98
143
|
>
|
|
99
|
-
{#await
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
144
|
+
{#await isSelectedPromise}
|
|
145
|
+
<input
|
|
146
|
+
id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
|
|
147
|
+
type="checkbox"
|
|
148
|
+
checked={false}
|
|
149
|
+
disabled
|
|
150
|
+
/>
|
|
151
|
+
{:then isSelected}
|
|
152
|
+
<input
|
|
153
|
+
id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
|
|
154
|
+
bind:this={inputRef}
|
|
155
|
+
{onchange}
|
|
156
|
+
type="checkbox"
|
|
157
|
+
checked={isSelected}
|
|
158
|
+
disabled={!isSelectable || tableContext.showSelectedOnly}
|
|
159
|
+
/>
|
|
160
|
+
{:catch e}
|
|
161
|
+
Error: {getErrorMessage(e)}
|
|
105
162
|
{/await}
|
|
106
163
|
</label>
|
|
107
164
|
</td>
|
|
108
165
|
|
|
109
|
-
{#snippet input(isSelectable: boolean)}
|
|
110
|
-
<input
|
|
111
|
-
id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
|
|
112
|
-
bind:this={inputRef}
|
|
113
|
-
{onchange}
|
|
114
|
-
type="checkbox"
|
|
115
|
-
checked={value}
|
|
116
|
-
disabled={!isSelectable || tableContext.showSelectedOnly}
|
|
117
|
-
/>
|
|
118
|
-
{/snippet}
|
|
119
|
-
|
|
120
166
|
<style>td {
|
|
121
167
|
transition: line-height 0.2s ease, height 0.2s ease;
|
|
122
168
|
--input-border: none;
|
|
@@ -165,4 +211,14 @@ label.multifocus {
|
|
|
165
211
|
}
|
|
166
212
|
label.multifocus.multifocus-start {
|
|
167
213
|
background-color: #ffffff;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
td.info {
|
|
217
|
+
background-color: #1f81a0;
|
|
218
|
+
}
|
|
219
|
+
td.warning {
|
|
220
|
+
background-color: #f8eab8;
|
|
221
|
+
}
|
|
222
|
+
td.error {
|
|
223
|
+
background-color: #f9e9e9;
|
|
168
224
|
}</style>
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import type { TableCell } from '../../../Types/Columns/TableCell.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
3
3
|
export interface TableCheckboxProps<T extends object> {
|
|
4
4
|
cell: TableCell<T>;
|
|
5
|
-
onchange?: ChangeEventHandler<HTMLInputElement>;
|
|
6
5
|
}
|
|
7
|
-
declare function $$render<T extends object>(): {
|
|
6
|
+
declare function $$render<T extends object, RowIdType extends Primitive>(): {
|
|
8
7
|
props: TableCheckboxProps<T>;
|
|
9
8
|
exports: {};
|
|
10
9
|
bindings: "";
|
|
11
10
|
slots: {};
|
|
12
11
|
events: {};
|
|
13
12
|
};
|
|
14
|
-
declare class __sveltets_Render<T extends object> {
|
|
15
|
-
props(): ReturnType<typeof $$render<T>>['props'];
|
|
16
|
-
events(): ReturnType<typeof $$render<T>>['events'];
|
|
17
|
-
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
13
|
+
declare class __sveltets_Render<T extends object, RowIdType extends Primitive> {
|
|
14
|
+
props(): ReturnType<typeof $$render<T, RowIdType>>['props'];
|
|
15
|
+
events(): ReturnType<typeof $$render<T, RowIdType>>['events'];
|
|
16
|
+
slots(): ReturnType<typeof $$render<T, RowIdType>>['slots'];
|
|
18
17
|
bindings(): "";
|
|
19
18
|
exports(): {};
|
|
20
19
|
}
|
|
21
20
|
interface $$IsomorphicComponent {
|
|
22
|
-
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']>> & {
|
|
23
|
-
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
24
|
-
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
25
|
-
<T extends object>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
26
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
21
|
+
new <T extends object, RowIdType extends Primitive>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, RowIdType>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, RowIdType>['props']>, ReturnType<__sveltets_Render<T, RowIdType>['events']>, ReturnType<__sveltets_Render<T, RowIdType>['slots']>> & {
|
|
22
|
+
$$bindings?: ReturnType<__sveltets_Render<T, RowIdType>['bindings']>;
|
|
23
|
+
} & ReturnType<__sveltets_Render<T, RowIdType>['exports']>;
|
|
24
|
+
<T extends object, RowIdType extends Primitive>(internal: unknown, props: ReturnType<__sveltets_Render<T, RowIdType>['props']> & {}): ReturnType<__sveltets_Render<T, RowIdType>['exports']>;
|
|
25
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
27
26
|
}
|
|
28
27
|
declare const TableRowSelectionCheckbox: $$IsomorphicComponent;
|
|
29
|
-
type TableRowSelectionCheckbox<T extends object> = InstanceType<typeof TableRowSelectionCheckbox<T>>;
|
|
28
|
+
type TableRowSelectionCheckbox<T extends object, RowIdType extends Primitive> = InstanceType<typeof TableRowSelectionCheckbox<T, RowIdType>>;
|
|
30
29
|
export default TableRowSelectionCheckbox;
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
import SingleSelect from '../../../../SingleSelect.svelte';
|
|
9
9
|
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
10
10
|
import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
11
|
-
import {
|
|
12
|
-
import { devCatch } from '../../../../../Helpers/Helpers.svelte.js';
|
|
11
|
+
import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
13
12
|
import type { SelectOption } from '../../../../../Types/Internal/SelectOption.js';
|
|
14
13
|
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
15
14
|
import { getContext, tick, untrack } from 'svelte';
|
|
@@ -33,8 +32,6 @@
|
|
|
33
32
|
const optional = $derived(cell.column.columnDef.optional);
|
|
34
33
|
|
|
35
34
|
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
36
|
-
const { toast } = getContext<ToastContext>(ToastContext.identifier);
|
|
37
|
-
|
|
38
35
|
const editableAsync = $derived(
|
|
39
36
|
cell.column.columnDef.isEditable(cell.row.original, cell.row.originalIndex)
|
|
40
37
|
);
|
|
@@ -64,8 +61,8 @@
|
|
|
64
61
|
})().catch(devCatch);
|
|
65
62
|
});
|
|
66
63
|
|
|
67
|
-
const focusDetails: TableFocusDetails<T> = $derived(
|
|
68
|
-
new TableFocusDetails(cell, tableContext
|
|
64
|
+
const focusDetails: TableFocusDetails<T, never> = $derived(
|
|
65
|
+
new TableFocusDetails(cell, tableContext)
|
|
69
66
|
);
|
|
70
67
|
|
|
71
68
|
const wantsToBeEdited = $derived(
|
|
@@ -121,40 +118,23 @@
|
|
|
121
118
|
) ?? cell.column.columnDef.getOptions()
|
|
122
119
|
);
|
|
123
120
|
|
|
124
|
-
let previousValidity: Validity = $state(Validity.Valid);
|
|
125
121
|
let validity: Validity = $state(Validity.Valid);
|
|
126
122
|
$effect(() => {
|
|
127
|
-
focusDetails.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
123
|
+
const validityPromise = focusDetails.validity;
|
|
124
|
+
|
|
125
|
+
validityPromise
|
|
126
|
+
.then((v) => {
|
|
127
|
+
if (!v) {
|
|
128
|
+
validity = Validity.Neutral;
|
|
129
|
+
} else if (isValidityTuple(v)) {
|
|
130
|
+
validity = v.value;
|
|
131
|
+
} else {
|
|
132
|
+
validity = v;
|
|
133
|
+
}
|
|
136
134
|
})
|
|
137
135
|
.catch(devCatch);
|
|
138
136
|
});
|
|
139
137
|
|
|
140
|
-
$effect(() => {
|
|
141
|
-
if (validity != previousValidity) {
|
|
142
|
-
untrack(() => {
|
|
143
|
-
tick()
|
|
144
|
-
.then(() => {
|
|
145
|
-
const x =
|
|
146
|
-
validity === Validity.Invalid
|
|
147
|
-
? tableContext.addInvalidValue(cell.row.original)
|
|
148
|
-
: tableContext.removeInvalidValue(cell.row.original);
|
|
149
|
-
|
|
150
|
-
previousValidity = validity;
|
|
151
|
-
|
|
152
|
-
return x;
|
|
153
|
-
})
|
|
154
|
-
.catch(devCatch);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
138
|
function handleTDFocus(): boolean {
|
|
159
139
|
if (
|
|
160
140
|
editable &&
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
10
10
|
import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
11
11
|
import TextInput from '../../../../TextInput.svelte';
|
|
12
|
-
import {
|
|
13
|
-
import { devCatch } from '../../../../../Helpers/Helpers.svelte.js';
|
|
12
|
+
import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
14
13
|
import { InputVariant } from '../../../../../Types/Internal/InputVariant.js';
|
|
15
14
|
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
16
15
|
import { getContext, tick, untrack } from 'svelte';
|
|
@@ -60,10 +59,9 @@
|
|
|
60
59
|
let inputRef = $state<HTMLInputElement | undefined>();
|
|
61
60
|
|
|
62
61
|
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
63
|
-
const toastContext = getContext<ToastContext>(ToastContext.identifier);
|
|
64
62
|
|
|
65
|
-
const focusDetails: TableFocusDetails<T> = $derived(
|
|
66
|
-
new TableFocusDetails(cell, tableContext
|
|
63
|
+
const focusDetails: TableFocusDetails<T, never> = $derived(
|
|
64
|
+
new TableFocusDetails(cell, tableContext)
|
|
67
65
|
);
|
|
68
66
|
|
|
69
67
|
const wantsToBeEdited = $derived(
|
|
@@ -128,41 +126,23 @@
|
|
|
128
126
|
}
|
|
129
127
|
});
|
|
130
128
|
|
|
131
|
-
let previousValidity: Validity = $state(Validity.Valid);
|
|
132
129
|
let validity: Validity = $state(Validity.Valid);
|
|
133
130
|
$effect(() => {
|
|
134
|
-
focusDetails.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
131
|
+
const validityPromise = focusDetails.validity;
|
|
132
|
+
|
|
133
|
+
validityPromise
|
|
134
|
+
.then((v) => {
|
|
135
|
+
if (!v) {
|
|
136
|
+
validity = Validity.Neutral;
|
|
137
|
+
} else if (isValidityTuple(v)) {
|
|
138
|
+
validity = v.value;
|
|
139
|
+
} else {
|
|
140
|
+
validity = v;
|
|
141
|
+
}
|
|
143
142
|
})
|
|
144
143
|
.catch(devCatch);
|
|
145
144
|
});
|
|
146
145
|
|
|
147
|
-
$effect(() => {
|
|
148
|
-
if (validity != previousValidity) {
|
|
149
|
-
untrack(() => {
|
|
150
|
-
tick()
|
|
151
|
-
.then(() => {
|
|
152
|
-
const x =
|
|
153
|
-
validity === Validity.Invalid
|
|
154
|
-
? tableContext.addInvalidValue(cell.row.original)
|
|
155
|
-
: tableContext.removeInvalidValue(cell.row.original);
|
|
156
|
-
|
|
157
|
-
previousValidity = validity;
|
|
158
|
-
|
|
159
|
-
return x;
|
|
160
|
-
})
|
|
161
|
-
.catch(devCatch);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
146
|
function handleBeingEdited() {
|
|
167
147
|
tableContext.isMousingDown = false;
|
|
168
148
|
tick()
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
import type { AbstractDisplayDef } from '../../../Types/Columns/Definitions/Display/AbstractDisplayDef.svelte.js';
|
|
11
11
|
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
12
12
|
import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
13
|
-
import {
|
|
14
|
-
import { devCatch } from '../../../../../Helpers/Helpers.svelte.js';
|
|
13
|
+
import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
15
14
|
import { Colour, ColourSet } from '../../../../../scss/colours.js';
|
|
16
15
|
import { Size } from '../../../../../Types/Internal/Size.js';
|
|
17
16
|
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
@@ -41,20 +40,20 @@
|
|
|
41
40
|
|
|
42
41
|
<script
|
|
43
42
|
lang="ts"
|
|
44
|
-
generics="T extends object, FilterValueType"
|
|
43
|
+
generics="T extends object, FilterValueType, RowIdType extends Primitive"
|
|
45
44
|
>
|
|
46
|
-
import {
|
|
45
|
+
import { type Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
46
|
+
import { getContext, tick } from 'svelte';
|
|
47
47
|
import type { ValidityCellProps } from './ValidityCellProps.js';
|
|
48
48
|
|
|
49
49
|
const { cell }: ValidityCellProps<T, FilterValueType> = $props();
|
|
50
50
|
|
|
51
|
-
const tableContext = getContext<TableContext<T,
|
|
52
|
-
const { toast } = getContext<ToastContext>(ToastContext.identifier);
|
|
51
|
+
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
53
52
|
|
|
54
53
|
const ColumnDef = $derived(cell.column.columnDef as AbstractDisplayDef<T, FilterValueType>);
|
|
55
54
|
|
|
56
|
-
const focusDetails: TableFocusDetails<T> = $derived(
|
|
57
|
-
new TableFocusDetails(cell, tableContext
|
|
55
|
+
const focusDetails: TableFocusDetails<T, RowIdType> = $derived(
|
|
56
|
+
new TableFocusDetails(cell, tableContext)
|
|
58
57
|
);
|
|
59
58
|
|
|
60
59
|
let showModal = $state(false);
|
|
@@ -72,32 +71,27 @@
|
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
73
|
|
|
75
|
-
let validity = $
|
|
74
|
+
let validity: Validity = $state(Validity.Valid);
|
|
75
|
+
let reason = $state<string | undefined>();
|
|
76
76
|
|
|
77
77
|
$effect(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const [validityValue] = await validity;
|
|
89
|
-
|
|
90
|
-
if (ColumnDef.debug) {
|
|
91
|
-
console.log('validity: ', $state.snapshot(validityValue));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (validityValue === Validity.Invalid) {
|
|
95
|
-
return tableContext.addInvalidValue(cell.row.original);
|
|
78
|
+
const validityPromise = focusDetails.validity;
|
|
79
|
+
|
|
80
|
+
validityPromise
|
|
81
|
+
.then((v) => {
|
|
82
|
+
if (!v) {
|
|
83
|
+
validity = Validity.Neutral;
|
|
84
|
+
reason = undefined;
|
|
85
|
+
} else if (isValidityTuple(v)) {
|
|
86
|
+
validity = v.value;
|
|
87
|
+
reason = v.reason;
|
|
96
88
|
} else {
|
|
97
|
-
|
|
89
|
+
validity = v;
|
|
90
|
+
|
|
91
|
+
reason = undefined;
|
|
98
92
|
}
|
|
99
|
-
})
|
|
100
|
-
|
|
93
|
+
})
|
|
94
|
+
.catch(devCatch);
|
|
101
95
|
});
|
|
102
96
|
|
|
103
97
|
const thisId = $derived(
|
|
@@ -115,6 +109,8 @@
|
|
|
115
109
|
.catch(devCatch);
|
|
116
110
|
}
|
|
117
111
|
}
|
|
112
|
+
|
|
113
|
+
const icon = $derived(iconSets[validity]);
|
|
118
114
|
</script>
|
|
119
115
|
|
|
120
116
|
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
|
@@ -145,37 +141,20 @@
|
|
|
145
141
|
class:multifocus={focusDetails.isMultiFocused}
|
|
146
142
|
class:multifocus-start={focusDetails.isMultiFocusStart}
|
|
147
143
|
>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
{:then maybeTuple}
|
|
163
|
-
{@const [value, reason] = maybeTuple}
|
|
164
|
-
<Action
|
|
165
|
-
id={thisId}
|
|
166
|
-
style={focusDetails.outline}
|
|
167
|
-
border={false}
|
|
168
|
-
colourSet={ColourSet.Auxiliary}
|
|
169
|
-
label={reason}
|
|
170
|
-
size={Size.FillWidth}
|
|
171
|
-
icon={iconSets[value]}
|
|
172
|
-
onclick={() => {
|
|
173
|
-
if (ColumnDef.modal) {
|
|
174
|
-
tableContext.setOpenModalCoordinates(focusDetails.coordinates);
|
|
175
|
-
}
|
|
176
|
-
}}
|
|
177
|
-
/>
|
|
178
|
-
{/await}
|
|
144
|
+
<Action
|
|
145
|
+
id={thisId}
|
|
146
|
+
style={focusDetails.outline}
|
|
147
|
+
border={false}
|
|
148
|
+
colourSet={ColourSet.Auxiliary}
|
|
149
|
+
label={reason}
|
|
150
|
+
size={Size.FillWidth}
|
|
151
|
+
{icon}
|
|
152
|
+
onclick={() => {
|
|
153
|
+
if (ColumnDef.modal) {
|
|
154
|
+
tableContext.setOpenModalCoordinates(focusDetails.coordinates);
|
|
155
|
+
}
|
|
156
|
+
}}
|
|
157
|
+
/>
|
|
179
158
|
</div>
|
|
180
159
|
{#if showModal}
|
|
181
160
|
<Portal target={document.body}>
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
+
import { type Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
1
2
|
import type { ValidityCellProps } from './ValidityCellProps.js';
|
|
2
|
-
declare function $$render<T extends object, FilterValueType>(): {
|
|
3
|
+
declare function $$render<T extends object, FilterValueType, RowIdType extends Primitive>(): {
|
|
3
4
|
props: ValidityCellProps<T, FilterValueType>;
|
|
4
5
|
exports: {};
|
|
5
6
|
bindings: "";
|
|
6
7
|
slots: {};
|
|
7
8
|
events: {};
|
|
8
9
|
};
|
|
9
|
-
declare class __sveltets_Render<T extends object, FilterValueType> {
|
|
10
|
-
props(): ReturnType<typeof $$render<T, FilterValueType>>['props'];
|
|
11
|
-
events(): ReturnType<typeof $$render<T, FilterValueType>>['events'];
|
|
12
|
-
slots(): ReturnType<typeof $$render<T, FilterValueType>>['slots'];
|
|
10
|
+
declare class __sveltets_Render<T extends object, FilterValueType, RowIdType extends Primitive> {
|
|
11
|
+
props(): ReturnType<typeof $$render<T, FilterValueType, RowIdType>>['props'];
|
|
12
|
+
events(): ReturnType<typeof $$render<T, FilterValueType, RowIdType>>['events'];
|
|
13
|
+
slots(): ReturnType<typeof $$render<T, FilterValueType, RowIdType>>['slots'];
|
|
13
14
|
bindings(): "";
|
|
14
15
|
exports(): {};
|
|
15
16
|
}
|
|
16
17
|
interface $$IsomorphicComponent {
|
|
17
|
-
new <T extends object, FilterValueType>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, FilterValueType>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, FilterValueType>['props']>, ReturnType<__sveltets_Render<T, FilterValueType>['events']>, ReturnType<__sveltets_Render<T, FilterValueType>['slots']>> & {
|
|
18
|
-
$$bindings?: ReturnType<__sveltets_Render<T, FilterValueType>['bindings']>;
|
|
19
|
-
} & ReturnType<__sveltets_Render<T, FilterValueType>['exports']>;
|
|
20
|
-
<T extends object, FilterValueType>(internal: unknown, props: ReturnType<__sveltets_Render<T, FilterValueType>['props']> & {}): ReturnType<__sveltets_Render<T, FilterValueType>['exports']>;
|
|
21
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
18
|
+
new <T extends object, FilterValueType, RowIdType extends Primitive>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, FilterValueType, RowIdType>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, FilterValueType, RowIdType>['props']>, ReturnType<__sveltets_Render<T, FilterValueType, RowIdType>['events']>, ReturnType<__sveltets_Render<T, FilterValueType, RowIdType>['slots']>> & {
|
|
19
|
+
$$bindings?: ReturnType<__sveltets_Render<T, FilterValueType, RowIdType>['bindings']>;
|
|
20
|
+
} & ReturnType<__sveltets_Render<T, FilterValueType, RowIdType>['exports']>;
|
|
21
|
+
<T extends object, FilterValueType, RowIdType extends Primitive>(internal: unknown, props: ReturnType<__sveltets_Render<T, FilterValueType, RowIdType>['props']> & {}): ReturnType<__sveltets_Render<T, FilterValueType, RowIdType>['exports']>;
|
|
22
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
|
|
22
23
|
}
|
|
23
24
|
declare const ValidityCell: $$IsomorphicComponent;
|
|
24
|
-
type ValidityCell<T extends object, FilterValueType> = InstanceType<typeof ValidityCell<T, FilterValueType>>;
|
|
25
|
+
type ValidityCell<T extends object, FilterValueType, RowIdType extends Primitive> = InstanceType<typeof ValidityCell<T, FilterValueType, RowIdType>>;
|
|
25
26
|
export default ValidityCell;
|