@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.
Files changed (46) hide show
  1. package/dist/Components/Table/Body/QuickSearchCell.svelte +78 -73
  2. package/dist/Components/Table/Body/Rows/ColumnList.svelte +1 -1
  3. package/dist/Components/Table/Body/Rows/ColumnListRowProps.d.ts +1 -1
  4. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +12 -6
  5. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +15 -35
  6. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +15 -35
  7. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +35 -4
  8. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +60 -26
  9. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +14 -35
  10. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +35 -5
  11. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +82 -139
  12. package/dist/Components/Table/Body/Rows/Columns/TableDatePickerProps.d.ts +1 -1
  13. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +15 -35
  14. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte.d.ts +1 -2
  15. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +14 -34
  16. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +93 -37
  17. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte.d.ts +12 -13
  18. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +14 -34
  19. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +14 -34
  20. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +40 -61
  21. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte.d.ts +12 -11
  22. package/dist/Components/Table/ColumnDefinitions/ExampleItemColumnDefRepository.svelte.js +39 -29
  23. package/dist/Components/Table/Misc/FilterInput.svelte +1 -1
  24. package/dist/Components/Table/Table.svelte +15 -16
  25. package/dist/Components/Table/Types/Columns/DateColumn.d.ts +2 -2
  26. package/dist/Components/Table/Types/Columns/DateTableCell.d.ts +2 -2
  27. package/dist/Components/Table/Types/Columns/Definitions/ColumnDefSet.d.ts +1 -1
  28. package/dist/Components/Table/Types/Columns/Definitions/JSONColumnDefSet.d.ts +1 -1
  29. package/dist/Components/Table/Types/Columns/Definitions/ValidationFn.d.ts +1 -1
  30. package/dist/Components/Table/Types/Context/ITable.d.ts +0 -1
  31. package/dist/Components/Table/Types/Context/Row.d.ts +3 -3
  32. package/dist/Components/Table/Types/Context/TableContext.svelte.d.ts +16 -22
  33. package/dist/Components/Table/Types/Context/TableContext.svelte.js +299 -275
  34. package/dist/Components/Table/Types/DataRepository/IDataRepository.d.ts +1 -1
  35. package/dist/Components/Table/Types/DataRepository/ILocalDataRepository.d.ts +1 -1
  36. package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.d.ts +2 -2
  37. package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.js +23 -7
  38. package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.d.ts +2 -2
  39. package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.js +2 -4
  40. package/dist/Components/Table/Types/Focus/TableFocusDetails.svelte.d.ts +18 -36
  41. package/dist/Components/Table/Types/Focus/TableFocusDetails.svelte.js +77 -113
  42. package/dist/Components/TextInput.svelte +11 -4
  43. package/dist/Components/Touch/DateModal.svelte +26 -14
  44. package/dist/Helpers/Helpers.svelte.d.ts +5 -1
  45. package/dist/Helpers/Helpers.svelte.js +9 -10
  46. package/package.json +14 -14
@@ -6,9 +6,9 @@
6
6
  >
7
7
  import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
8
8
  import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
9
- import { ToastContext } from '../../../../../Contexts/ToastContext.svelte.js';
10
- import { getErrorMessage } from '../../../../../Helpers/Helpers.svelte.js';
9
+ import { devCatch, getErrorMessage, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
11
10
  import type { SelectOption } from '../../../../../Types/Internal/SelectOption.js';
11
+ import { Validity } from '../../../../../Types/Internal/Validity.js';
12
12
  import { getContext } from 'svelte';
13
13
  import type { FocusableImmutableCellProps } from './FocusableImmutableCellProps.js';
14
14
 
@@ -21,7 +21,6 @@
21
21
  );
22
22
 
23
23
  const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
24
- const toastContext = getContext<ToastContext>(ToastContext.identifier);
25
24
 
26
25
  const options: Array<SelectOption<unknown>> = $derived(
27
26
  ('options' in cell.column.columnDef ? cell.column.columnDef.options : []) as Array<
@@ -30,9 +29,26 @@
30
29
  );
31
30
  const hasValue: boolean = $derived(value !== undefined);
32
31
 
33
- const focusDetails: TableFocusDetails<T> = $derived(
34
- new TableFocusDetails(cell, tableContext, toastContext.toast)
32
+ const focusDetails: TableFocusDetails<T, never> = $derived(
33
+ new TableFocusDetails(cell, tableContext)
35
34
  );
35
+
36
+ let validity: Validity = $state(Validity.Valid);
37
+ $effect(() => {
38
+ const validityPromise = focusDetails.validity;
39
+
40
+ validityPromise
41
+ .then((v) => {
42
+ if (!v) {
43
+ validity = Validity.Neutral;
44
+ } else if (isValidityTuple(v)) {
45
+ validity = v.value;
46
+ } else {
47
+ validity = v;
48
+ }
49
+ })
50
+ .catch(devCatch);
51
+ });
36
52
  </script>
37
53
 
38
54
  <!-- svelte-ignore a11y_mouse_events_have_key_events -->
@@ -42,6 +58,10 @@ class:right={focusDetails.rightEdge}
42
58
  class:bottom={focusDetails.bottomEdge} -->
43
59
  <td
44
60
  id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
61
+ class:info={validity == Validity.Info}
62
+ class:success={validity == Validity.Valid}
63
+ class:warning={validity == Validity.Warning}
64
+ class:error={validity == Validity.Invalid}
45
65
  tabIndex={hasValue ? 0 : undefined}
46
66
  class="focusable"
47
67
  style={focusDetails.outline}
@@ -67,30 +87,34 @@ class:bottom={focusDetails.bottomEdge} -->
67
87
  tableContext.endFocus(focusDetails.coordinates);
68
88
  }}
69
89
  >
70
- {#if hasValue}
71
- {#await visibleValue}
90
+ <svelte:boundary>
91
+ {#snippet pending()}
72
92
  loading…
73
- {:then visibleValue}
74
- {(visibleValue instanceof Date
75
- ? visibleValue.toLocaleDateString()
93
+ {/snippet}
94
+ {#snippet onerror(e)}
95
+ Error: {getErrorMessage(e)}
96
+ {/snippet}
97
+ {#if hasValue}
98
+ {@const v = await visibleValue}
99
+
100
+ {(v instanceof Date
101
+ ? v.toLocaleDateString()
76
102
  : options.length
77
- ? options.find((it) => it.value === visibleValue)?.label
78
- : visibleValue) ??
79
- visibleValue ??
103
+ ? options.find((it) => it.value === v)?.label
104
+ : v) ??
105
+ v ??
80
106
  ''}
81
- {:catch e}
82
- {getErrorMessage(e)}
83
- {/await}
84
- {:else if children}
85
- <div
86
- class="slot-wrapper"
87
- class:multifocus={focusDetails.isMultiFocused}
88
- class:multifocus-start={focusDetails.isMultiFocusStart}
89
- >
90
- <!-- TODO {focusDetails.isMultiFocusStart} -->
91
- {@render children()}
92
- </div>
93
- {/if}
107
+ {:else if children}
108
+ <div
109
+ class="slot-wrapper"
110
+ class:multifocus={focusDetails.isMultiFocused}
111
+ class:multifocus-start={focusDetails.isMultiFocusStart}
112
+ >
113
+ <!-- TODO {focusDetails.isMultiFocusStart} -->
114
+ {@render children()}
115
+ </div>
116
+ {/if}
117
+ </svelte:boundary>
94
118
  </td>
95
119
 
96
120
  <style>td {
@@ -147,4 +171,14 @@ div.slot-wrapper {
147
171
  display: flex;
148
172
  align-items: center;
149
173
  justify-content: center;
174
+ }
175
+
176
+ td.info {
177
+ background-color: #1f81a0;
178
+ }
179
+ td.warning {
180
+ background-color: #f8eab8;
181
+ }
182
+ td.error {
183
+ background-color: #f9e9e9;
150
184
  }</style>
@@ -8,10 +8,9 @@
8
8
  import type { ProgressBarTableCell } from '../../../Types/Columns/ProgressBarTableCell.js';
9
9
  import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
10
10
  import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
11
- import { ToastContext } from '../../../../../Contexts/ToastContext.svelte.js';
12
- import { devCatch } from '../../../../../Helpers/Helpers.svelte.js';
11
+ import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
13
12
  import { Validity } from '../../../../../Types/Internal/Validity.js';
14
- import { getContext, tick, untrack } from 'svelte';
13
+ import { getContext } from 'svelte';
15
14
 
16
15
  export interface ProgressCellProps<T extends object, FilterValueType> {
17
16
  cell: ProgressBarTableCell<T, FilterValueType>;
@@ -28,47 +27,27 @@
28
27
  const value: [number, number] = $derived(cell.getValue()) as [number, number];
29
28
 
30
29
  const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
31
- const { toast } = getContext<ToastContext>(ToastContext.identifier);
32
-
33
30
  // const previousRowIndex: number | undefined = $state(undefined);
34
31
 
35
- const focusDetails = $derived(new TableFocusDetails<T>(cell, tableContext, toast));
32
+ const focusDetails = $derived(new TableFocusDetails<T, never>(cell, tableContext));
36
33
 
37
- let previousValidity: Validity = $state(Validity.Valid);
38
34
  let validity: Validity = $state(Validity.Valid);
39
35
  $effect(() => {
40
- focusDetails.validityTuple
41
- .then(([newValidity]) => {
42
- untrack(() => {
43
- tick()
44
- .then(() => {
45
- validity = newValidity;
46
- })
47
- .catch(devCatch);
48
- });
36
+ const validityPromise = focusDetails.validity;
37
+
38
+ validityPromise
39
+ .then((v) => {
40
+ if (!v) {
41
+ validity = Validity.Neutral;
42
+ } else if (isValidityTuple(v)) {
43
+ validity = v.value;
44
+ } else {
45
+ validity = v;
46
+ }
49
47
  })
50
48
  .catch(devCatch);
51
49
  });
52
50
 
53
- $effect(() => {
54
- if (validity != previousValidity) {
55
- untrack(() => {
56
- tick()
57
- .then(() => {
58
- const x =
59
- validity === Validity.Invalid
60
- ? tableContext.addInvalidValue(cell.row.original)
61
- : tableContext.removeInvalidValue(cell.row.original);
62
-
63
- previousValidity = validity;
64
-
65
- return x;
66
- })
67
- .catch(devCatch);
68
- });
69
- }
70
- });
71
-
72
51
  const colours = $derived(
73
52
  cell.column.columnDef.getColour(cell.row.original, cell.row.originalIndex, value)
74
53
  );
@@ -19,8 +19,8 @@
19
19
  import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
20
20
  import type { BoolFilterValueType } from '../../../Types/Filtering/FilterFn.js';
21
21
  import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
22
- import { ToastContext } from '../../../../../Contexts/ToastContext.svelte.js';
23
- import { devCatch } from '../../../../../Helpers/Helpers.svelte.js';
22
+ import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
23
+ import { Validity } from '../../../../../Types/Internal/Validity.js';
24
24
  import { getContext, tick } from 'svelte';
25
25
 
26
26
  import type { ChangeEventHandler } from 'svelte/elements';
@@ -30,10 +30,9 @@
30
30
  const value = $derived(!!cell.getValue());
31
31
 
32
32
  const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
33
- const toastContext = getContext<ToastContext>(ToastContext.identifier);
34
33
 
35
- const focusDetails: TableFocusDetails<T> = $derived(
36
- new TableFocusDetails(cell, tableContext, toastContext.toast)
34
+ const focusDetails: TableFocusDetails<T, never> = $derived(
35
+ new TableFocusDetails(cell, tableContext)
37
36
  );
38
37
 
39
38
  let inputRef: HTMLInputElement | undefined = $state();
@@ -56,6 +55,23 @@
56
55
  })
57
56
  .catch(devCatch);
58
57
  };
58
+
59
+ let validity: Validity = $state(Validity.Valid);
60
+ $effect(() => {
61
+ const validityPromise = focusDetails.validity;
62
+
63
+ validityPromise
64
+ .then((v) => {
65
+ if (!v) {
66
+ validity = Validity.Neutral;
67
+ } else if (isValidityTuple(v)) {
68
+ validity = v.value;
69
+ } else {
70
+ validity = v;
71
+ }
72
+ })
73
+ .catch(devCatch);
74
+ });
59
75
  </script>
60
76
 
61
77
  <!-- svelte-ignore a11y_mouse_events_have_key_events -->
@@ -91,6 +107,10 @@
91
107
  onmouseup={() => {
92
108
  tableContext.endFocus(focusDetails.coordinates);
93
109
  }}
110
+ class:info={validity == Validity.Info}
111
+ class:success={validity == Validity.Valid}
112
+ class:warning={validity == Validity.Warning}
113
+ class:error={validity == Validity.Invalid}
94
114
  >
95
115
  &nbsp;
96
116
  <label
@@ -156,4 +176,14 @@ label.multifocus {
156
176
  }
157
177
  label.multifocus.multifocus-start {
158
178
  background-color: #ffffff;
179
+ }
180
+
181
+ td.info {
182
+ background-color: #1f81a0;
183
+ }
184
+ td.warning {
185
+ background-color: #f8eab8;
186
+ }
187
+ td.error {
188
+ background-color: #f9e9e9;
159
189
  }</style>
@@ -9,8 +9,7 @@
9
9
  import type { CellCoordinates } from '../../../Types/Coordinates/CellCoordinates.js';
10
10
  import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
11
11
  import DateModal from '../../../../Touch/DateModal.svelte';
12
- import { ToastContext } from '../../../../../Contexts/ToastContext.svelte.js';
13
- import { devCatch } from '../../../../../Helpers/Helpers.svelte.js';
12
+ import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
14
13
  import { Validity } from '../../../../../Types/Internal/Validity.js';
15
14
  import { getContext, tick } from 'svelte';
16
15
  import type { TableDatePickerProps } from './TableDatePickerProps.js';
@@ -22,7 +21,6 @@
22
21
  const dateValue = $derived(value && value instanceof Date ? value : undefined);
23
22
 
24
23
  const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
25
- const { toast } = getContext<ToastContext>(ToastContext.identifier);
26
24
 
27
25
  const columnDef = $derived(cell.column.columnDef);
28
26
  const coordinates: CellCoordinates = $derived({
@@ -60,8 +58,8 @@
60
58
  }
61
59
  })().catch(devCatch);
62
60
  });
63
- const focusDetails: TableFocusDetails<T> = $derived(
64
- new TableFocusDetails(cell, tableContext, toast)
61
+ const focusDetails: TableFocusDetails<T, never> = $derived(
62
+ new TableFocusDetails(cell, tableContext)
65
63
  );
66
64
 
67
65
  let modalLock = $state(false);
@@ -98,15 +96,23 @@
98
96
  }
99
97
  }
100
98
 
101
- const validityPromise = $derived(focusDetails.validityTuple);
99
+ let validity: Validity = $state(Validity.Valid);
100
+ let reason = $state<string | undefined>();
102
101
 
103
102
  $effect(() => {
103
+ const validityPromise = focusDetails.validity;
104
+
104
105
  validityPromise
105
- .then(([validity]) => {
106
- if (validity === Validity.Invalid) {
107
- return tableContext.addInvalidValue(cell.row.original);
106
+ .then((v) => {
107
+ if (!v) {
108
+ validity = Validity.Neutral;
109
+ reason = undefined;
110
+ } else if (isValidityTuple(v)) {
111
+ validity = v.value;
112
+ reason = v.reason;
108
113
  } else {
109
- return tableContext.removeInvalidValue(cell.row.original);
114
+ validity = v;
115
+ reason = undefined;
110
116
  }
111
117
  })
112
118
  .catch(devCatch);
@@ -144,141 +150,78 @@
144
150
  <!-- ref={tdref} -->
145
151
 
146
152
  <!-- svelte-ignore a11y_mouse_events_have_key_events -->
147
- {#await validityPromise}
148
- <td
149
- {id}
150
- style={focusDetails.outline}
151
- tabIndex="0"
152
- bind:this={tdref}
153
- class:editable
154
- class="focusable"
155
- class:multifocus={focusDetails.isMultiFocused}
156
- class:multifocus-start={focusDetails.isMultiFocusStart}
157
- onmousedown={(e) => {
158
- // start focus only on left click
159
- if (e.button === 0) {
160
- if (e.shiftKey) {
161
- e.preventDefault();
162
- tableContext.setFocusEnd(coordinates);
163
- } else {
164
- tableContext.startFocus(coordinates);
165
- }
166
- }
167
- }}
168
- onmouseover={() => {
169
- if (tableContext.isMousingDown) {
170
- tableContext.setFocusEnd(coordinates);
171
- }
172
- }}
173
- onmouseup={() => {
174
- tableContext.endFocus(coordinates);
175
- }}
176
- onclick={handleSingleClick}
177
- ondblclick={handleDoubleClick}
178
- >
179
- {#if isBeingEdited}
180
- <DateModal
181
- header="Edit {columnDef.header}"
182
- value={dateValue ?? null}
183
- cancelEditing={() => {
184
- refocusTd();
185
- }}
186
- confirm={(e) => {
187
- tableContext.onEditCell(cell.row.original, coordinates, e).catch(devCatch);
188
- refocusTd();
189
- }}
190
- />
191
- {/if}
192
153
 
193
- {#if !value}
194
- -
195
- {:else if typeof value === 'string'}
196
- <!-- TODO see if we need to mess with time zones here. Very likely -->
197
- {@const parsed = new Date(value)}
198
- {isNaN(parsed.getFullYear()) ? value : parsed.toLocaleString()}
199
- {:else if value instanceof Date}
200
- {value.toLocaleDateString()}
201
- {:else if dev}
202
- <!-- eslint-disable-next-line svelte/no-at-debug-tags -->
203
- {@debug value}
204
- Error reading value
205
- {:else}
206
- -
207
- {/if}
208
- </td>
209
- {:then [validity, message]}
210
- <td
211
- {id}
212
- style={focusDetails.outline}
213
- aria-label={message}
214
- tabIndex="0"
215
- bind:this={tdref}
216
- class:editable
217
- class="focusable"
218
- class:multifocus={focusDetails.isMultiFocused}
219
- class:multifocus-start={focusDetails.isMultiFocusStart}
220
- class:info={validity == Validity.Info}
221
- class:success={validity == Validity.Valid}
222
- class:warning={validity == Validity.Warning}
223
- class:error={validity == Validity.Invalid}
224
- onmousedown={(e) => {
225
- // start focus only on left click
226
- if (e.button === 0) {
227
- if (e.shiftKey) {
228
- e.preventDefault();
229
- tableContext.setFocusEnd(coordinates);
230
- } else {
231
- tableContext.startFocus(coordinates);
232
- }
233
- }
234
- }}
235
- onmouseover={() => {
236
- if (tableContext.isMousingDown) {
154
+ <td
155
+ {id}
156
+ style={focusDetails.outline}
157
+ aria-label={reason}
158
+ tabIndex="0"
159
+ bind:this={tdref}
160
+ class:editable
161
+ class="focusable"
162
+ class:multifocus={focusDetails.isMultiFocused}
163
+ class:multifocus-start={focusDetails.isMultiFocusStart}
164
+ class:info={validity == Validity.Info}
165
+ class:success={validity == Validity.Valid}
166
+ class:warning={validity == Validity.Warning}
167
+ class:error={validity == Validity.Invalid}
168
+ onmousedown={(e) => {
169
+ // start focus only on left click
170
+ if (e.button === 0) {
171
+ if (e.shiftKey) {
172
+ e.preventDefault();
237
173
  tableContext.setFocusEnd(coordinates);
174
+ } else {
175
+ tableContext.startFocus(coordinates);
238
176
  }
239
- }}
240
- onmouseup={() => {
241
- tableContext.endFocus(coordinates);
242
- }}
243
- onclick={handleSingleClick}
244
- ondblclick={handleDoubleClick}
245
- >
246
- {#if modalLock}
247
- <DateModal
248
- header="Edit {columnDef.header}"
249
- value={dateValue ?? null}
250
- showTime={cell.column.columnDef.showTime}
251
- cancelEditing={() => {
252
- refocusTd();
253
- }}
254
- confirm={(e) => {
255
- tableContext.onEditCell(cell.row.original, coordinates, e).catch(devCatch);
256
- refocusTd();
257
- }}
258
- />
259
- {/if}
177
+ }
178
+ }}
179
+ onmouseover={() => {
180
+ if (tableContext.isMousingDown) {
181
+ tableContext.setFocusEnd(coordinates);
182
+ }
183
+ }}
184
+ onmouseup={() => {
185
+ tableContext.endFocus(coordinates);
186
+ }}
187
+ onclick={handleSingleClick}
188
+ ondblclick={handleDoubleClick}
189
+ >
190
+ {#if modalLock}
191
+ <DateModal
192
+ header="Edit {columnDef.header}"
193
+ value={dateValue ?? null}
194
+ showTime={cell.column.columnDef.showTime}
195
+ cancelEditing={() => {
196
+ refocusTd();
197
+ }}
198
+ confirm={(e) => {
199
+ tableContext.onEditCell(cell.row.original, coordinates, e).catch(devCatch);
200
+ refocusTd();
201
+ }}
202
+ />
203
+ {/if}
260
204
 
261
- {#if !value}
262
- -
263
- {:else if typeof value === 'string'}
264
- <!-- TODO see if we need to mess with time zones here. Very likely -->
265
- {@const parsed = new Date(value)}
266
- {isNaN(parsed.getFullYear()) ? value : parsed.toLocaleString()}
267
- {:else if value instanceof Date}
268
- {#if cell.column.columnDef.showTime}
269
- {value.toLocaleString()}
270
- {:else}
271
- {value.toLocaleDateString()}
272
- {/if}
273
- {:else if dev}
274
- <!-- eslint-disable-next-line svelte/no-at-debug-tags -->
275
- {@debug value}
276
- Error reading value
205
+ {#if !value}
206
+ -
207
+ {:else if typeof value === 'string'}
208
+ <!-- TODO see if we need to mess with time zones here. Very likely -->
209
+ {@const parsed = new Date(value)}
210
+ {isNaN(parsed.getFullYear()) ? value : parsed.toLocaleString()}
211
+ {:else if value instanceof Date}
212
+ {#if cell.column.columnDef.showTime}
213
+ {value.toLocaleString()}
277
214
  {:else}
278
- -
215
+ {value.toLocaleDateString()}
279
216
  {/if}
280
- </td>
281
- {/await}
217
+ {:else if dev}
218
+ <!-- eslint-disable-next-line svelte/no-at-debug-tags -->
219
+ {@debug value}
220
+ Error reading value
221
+ {:else}
222
+ -
223
+ {/if}
224
+ </td>
282
225
 
283
226
  <style>td {
284
227
  transition: line-height 0.2s ease, height 0.2s ease;
@@ -1,4 +1,4 @@
1
1
  import type { DateTableCell } from '../../../Types/Columns/DateTableCell.js';
2
2
  export interface TableDatePickerProps<T extends object> {
3
- cell: DateTableCell<T>;
3
+ cell: DateTableCell<T, never, unknown>;
4
4
  }
@@ -5,7 +5,7 @@
5
5
  module
6
6
  >
7
7
  export interface TableNumberInputProps<T extends object> {
8
- cell: TableCell<T, NumberFilterValueType>;
8
+ cell: TableCell<T>;
9
9
  }
10
10
  </script>
11
11
 
@@ -17,10 +17,8 @@
17
17
  import { NumberInputDef } from '../../../Types/Columns/Definitions/Accessors/NumberInputDef.svelte.js';
18
18
  import type { TableCell } from '../../../Types/Columns/TableCell.js';
19
19
  import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
20
- import type { NumberFilterValueType } from '../../../Types/Filtering/FilterFn.js';
21
20
  import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
22
- import { ToastContext } from '../../../../../Contexts/ToastContext.svelte.js';
23
- import { devCatch } from '../../../../../Helpers/Helpers.svelte.js';
21
+ import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
24
22
  import { InputVariant } from '../../../../../Types/Internal/InputVariant.js';
25
23
  import { Validity } from '../../../../../Types/Internal/Validity.js';
26
24
  import { getContext, tick, untrack } from 'svelte';
@@ -55,7 +53,6 @@
55
53
  let inputRef: HTMLInputElement | undefined = $state();
56
54
 
57
55
  const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
58
- const { toast } = getContext<ToastContext>(ToastContext.identifier);
59
56
 
60
57
  const editableAsync = $derived(
61
58
  cell.column.columnDef.isEditable(cell.row.original, cell.row.originalIndex)
@@ -86,8 +83,8 @@
86
83
  })().catch(devCatch);
87
84
  });
88
85
 
89
- const focusDetails: TableFocusDetails<T> = $derived(
90
- new TableFocusDetails(cell, tableContext, toast)
86
+ const focusDetails: TableFocusDetails<T, never> = $derived(
87
+ new TableFocusDetails(cell, tableContext)
91
88
  );
92
89
 
93
90
  const wantsToBeEdited = $derived(
@@ -146,40 +143,23 @@
146
143
  }
147
144
  });
148
145
 
149
- let previousValidity: Validity = $state(Validity.Valid);
150
146
  let validity: Validity = $state(Validity.Valid);
151
147
  $effect(() => {
152
- focusDetails.validityTuple
153
- .then(([newValidity]) => {
154
- untrack(() => {
155
- tick()
156
- .then(() => {
157
- validity = newValidity;
158
- })
159
- .catch(devCatch);
160
- });
148
+ const validityPromise = focusDetails.validity;
149
+
150
+ validityPromise
151
+ .then((v) => {
152
+ if (!v) {
153
+ validity = Validity.Neutral;
154
+ } else if (isValidityTuple(v)) {
155
+ validity = v.value;
156
+ } else {
157
+ validity = v;
158
+ }
161
159
  })
162
160
  .catch(devCatch);
163
161
  });
164
162
 
165
- $effect(() => {
166
- if (validity != previousValidity) {
167
- untrack(() => {
168
- tick()
169
- .then(() => {
170
- const x: Promise<void> =
171
- validity === Validity.Invalid
172
- ? tableContext.addInvalidValue(cell.row.original)
173
- : tableContext.removeInvalidValue(cell.row.original);
174
-
175
- previousValidity = validity;
176
- return x;
177
- })
178
- .catch(devCatch);
179
- });
180
- }
181
- });
182
-
183
163
  function handleBeingEdited() {
184
164
  tableContext.isMousingDown = false;
185
165
  tick()
@@ -1,8 +1,7 @@
1
1
  export interface TableNumberInputProps<T extends object> {
2
- cell: TableCell<T, NumberFilterValueType>;
2
+ cell: TableCell<T>;
3
3
  }
4
4
  import type { TableCell } from '../../../Types/Columns/TableCell.js';
5
- import type { NumberFilterValueType } from '../../../Types/Filtering/FilterFn.js';
6
5
  declare function $$render<T extends object>(): {
7
6
  props: TableNumberInputProps<T>;
8
7
  exports: {};