@lavalogic/scoria 0.33.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.
Files changed (130) hide show
  1. package/README.md +58 -58
  2. package/dist/Components/AccordionGroup.svelte +44 -63
  3. package/dist/Components/AccordionGroup.svelte.d.ts +2 -25
  4. package/dist/Components/AccordionGroupButton.svelte +106 -114
  5. package/dist/Components/AccordionGroupButton.svelte.d.ts +2 -2
  6. package/dist/Components/AccordionGroupButtonProps.d.ts +21 -0
  7. package/dist/Components/AccordionGroupButtonProps.js +1 -0
  8. package/dist/Components/Action.svelte +138 -138
  9. package/dist/Components/AlertModal.svelte +125 -125
  10. package/dist/Components/Base/ContextWrapper.svelte +50 -50
  11. package/dist/Components/Base/Pagination.svelte +190 -190
  12. package/dist/Components/Base/Snippets.svelte +29 -29
  13. package/dist/Components/BigRadioSet.svelte +29 -29
  14. package/dist/Components/Bubble.svelte +77 -77
  15. package/dist/Components/Button.svelte +197 -197
  16. package/dist/Components/Checkbox.svelte +68 -68
  17. package/dist/Components/CollapsibleCard.svelte +70 -70
  18. package/dist/Components/Contexts/ContextMenu.svelte +157 -157
  19. package/dist/Components/Contexts/ContextMenuDivider.svelte +11 -11
  20. package/dist/Components/Contexts/ContextMenuOption.svelte +52 -52
  21. package/dist/Components/Contexts/Toast.svelte +61 -61
  22. package/dist/Components/Contexts/ToastContainer.svelte +46 -46
  23. package/dist/Components/Contexts/Tooltip.svelte +26 -26
  24. package/dist/Components/DataMatrixIcon.svelte +41 -41
  25. package/dist/Components/DateInput.svelte +109 -109
  26. package/dist/Components/DatePicker.svelte +312 -312
  27. package/dist/Components/DesktopModal.svelte +106 -106
  28. package/dist/Components/Dial.svelte +151 -151
  29. package/dist/Components/DimensionInput.svelte +184 -184
  30. package/dist/Components/DragMenu/DragMenuHolder.svelte +106 -106
  31. package/dist/Components/DragMenu/DraggableCard.svelte +41 -41
  32. package/dist/Components/FileCard.svelte +20 -20
  33. package/dist/Components/FileUpload.svelte +196 -196
  34. package/dist/Components/GridInput.svelte +190 -190
  35. package/dist/Components/GridInputSet.svelte +22 -22
  36. package/dist/Components/HorizontalTabGroup.svelte +78 -78
  37. package/dist/Components/HorizontalTabGroupButton.svelte +96 -96
  38. package/dist/Components/Icon.svelte +97 -97
  39. package/dist/Components/Icons.js +357 -357
  40. package/dist/Components/LoadingAnimation.svelte +32 -32
  41. package/dist/Components/LoadingModal.svelte +47 -47
  42. package/dist/Components/LoadingOverlay.svelte +27 -27
  43. package/dist/Components/Modal.svelte +251 -251
  44. package/dist/Components/MultiSelect.svelte +197 -197
  45. package/dist/Components/Nav/Nav.svelte +97 -97
  46. package/dist/Components/Nav/NavServiceMenuList.svelte +34 -34
  47. package/dist/Components/Nav/NavTab.svelte +91 -91
  48. package/dist/Components/Nav/ServiceMenuItem.svelte +91 -91
  49. package/dist/Components/Nav/ServicesNav.svelte +53 -53
  50. package/dist/Components/NumberInput.svelte +144 -144
  51. package/dist/Components/PageHeading.svelte +36 -36
  52. package/dist/Components/PasswordInput.svelte +73 -73
  53. package/dist/Components/Portal.svelte +25 -25
  54. package/dist/Components/ProgressBubble.svelte +80 -80
  55. package/dist/Components/QuerySelect.svelte +411 -411
  56. package/dist/Components/SingleSelect.svelte +261 -261
  57. package/dist/Components/StepButton.svelte +120 -120
  58. package/dist/Components/StepForm.svelte +108 -108
  59. package/dist/Components/Switch.svelte +36 -36
  60. package/dist/Components/Table/Body/QuickSearchCell.svelte +632 -632
  61. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +30 -30
  62. package/dist/Components/Table/Body/Rows/ColumnList.svelte +56 -56
  63. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +179 -179
  64. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +49 -49
  65. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +180 -180
  66. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +102 -102
  67. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +119 -119
  68. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +114 -114
  69. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +96 -96
  70. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +72 -72
  71. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +131 -131
  72. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +144 -144
  73. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +238 -238
  74. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +358 -358
  75. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +338 -338
  76. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +183 -183
  77. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +309 -309
  78. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +369 -369
  79. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +170 -170
  80. package/dist/Components/Table/Body/Rows/TableRow.svelte +259 -259
  81. package/dist/Components/Table/Body/TableBody.svelte +67 -67
  82. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +39 -39
  83. package/dist/Components/Table/Headers/SelectAllHeader.svelte +28 -28
  84. package/dist/Components/Table/Headers/TableHead.svelte +260 -260
  85. package/dist/Components/Table/Misc/ColumnPanel.svelte +78 -78
  86. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +99 -99
  87. package/dist/Components/Table/Misc/FilterInput.svelte +556 -556
  88. package/dist/Components/Table/Misc/FilterPanel.svelte +46 -46
  89. package/dist/Components/Table/Misc/FilterPanelModal.svelte +67 -67
  90. package/dist/Components/Table/Misc/SidePanel.svelte +32 -32
  91. package/dist/Components/Table/Misc/TableFooter.svelte +304 -304
  92. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +156 -156
  93. package/dist/Components/Table/Misc/TableSidebar.svelte +176 -176
  94. package/dist/Components/Table/Misc/ToolboxPanel.svelte +77 -77
  95. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +91 -91
  96. package/dist/Components/Table/NestedTable.svelte +84 -84
  97. package/dist/Components/Table/Table.svelte +492 -492
  98. package/dist/Components/Test/TestContextConsumer.svelte +13 -13
  99. package/dist/Components/TextArea.svelte +108 -108
  100. package/dist/Components/TextInput.svelte +147 -147
  101. package/dist/Components/ThreeStateRadio.svelte +124 -124
  102. package/dist/Components/Touch/BoolCard.svelte +52 -52
  103. package/dist/Components/Touch/DateModal.svelte +217 -217
  104. package/dist/Components/Touch/EditCard.svelte +52 -52
  105. package/dist/Components/Touch/InfoCard.svelte +24 -24
  106. package/dist/Components/Touch/InfoTextCard.svelte +21 -21
  107. package/dist/Components/Touch/ModalExplanation.svelte +20 -20
  108. package/dist/Components/Touch/NumberKeyboard.svelte +268 -268
  109. package/dist/Components/Touch/NumberModal.svelte +69 -69
  110. package/dist/Components/Touch/PlusMinusCard.svelte +50 -50
  111. package/dist/Components/Touch/SelectModal.svelte +105 -105
  112. package/dist/Components/Touch/SummaryCard.svelte +65 -65
  113. package/dist/Components/Touch/TextAreaModal.svelte +86 -86
  114. package/dist/Components/Touch/TextModal.svelte +123 -123
  115. package/dist/Components/Touch/TouchCard.svelte +28 -28
  116. package/dist/Components/Touch/TouchModal.svelte +259 -259
  117. package/dist/Components/Touch/UtilityButton.svelte +91 -91
  118. package/dist/Components/VerticalTabGroup.svelte +66 -66
  119. package/dist/Components/VerticalTabGroupButton.svelte +97 -97
  120. package/dist/Helpers/Datamatrix.d.ts +10 -10
  121. package/dist/Helpers/Datamatrix.js +1 -1
  122. package/dist/Helpers/Helpers.svelte.js +6 -4
  123. package/dist/Types/Examples/ExampleModal.svelte +34 -34
  124. package/dist/index.d.ts +1 -0
  125. package/dist/scss/_basics.scss +12 -12
  126. package/dist/scss/_colours.scss +134 -134
  127. package/dist/scss/_mixins.scss +3016 -3016
  128. package/dist/scss/_sizing.scss +69 -69
  129. package/dist/scss/_transitions.scss +8 -8
  130. package/package.json +2 -2
@@ -1,311 +1,311 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- module
6
- >
7
- import { dev } from '$app/environment';
8
- import SingleSelect from '../../../../SingleSelect.svelte';
9
- import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
10
- import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
11
- import { devCatch, isValidityTuple, loadingText } from '../../../../../Helpers/Helpers.svelte.js';
12
- import type { SelectOption } from '../../../../../Types/Internal/SelectOption.js';
13
- import { Validity } from '../../../../../Types/Internal/Validity.js';
14
- import { getContext, tick } from 'svelte';
15
- import type { TableSelectProps } from './TableSelectProps.js';
16
- </script>
17
-
18
- <script
19
- lang="ts"
20
- generics="T extends object"
21
- >
22
- const { cell }: TableSelectProps<T, T> = $props();
23
-
24
- let tdref = $state<HTMLTableCellElement | undefined>();
25
-
26
- const selectValue = $derived(cell.getValue() as T | Promise<T> | null | undefined);
27
-
28
- const visibleValue = $derived(
29
- cell.column.columnDef.getDisplayValue(cell.row.original, cell.row.originalIndex)
30
- );
31
-
32
- const optional = $derived(cell.column.columnDef.optional);
33
-
34
- const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
35
-
36
- const editable = $derived(
37
- cell.column.columnDef.isEditable(cell.row.original, cell.row.originalIndex)
38
- );
39
-
40
- const focusDetails: TableFocusDetails<T, never> = $derived(
41
- new TableFocusDetails(cell, tableContext)
42
- );
43
-
44
- const wantsToBeEdited = $derived(
45
- tableContext.focusStart?.column === focusDetails.coordinates.column &&
46
- tableContext.focusEnd?.column === focusDetails.coordinates.column &&
47
- tableContext.focusStart.row === focusDetails.coordinates.row &&
48
- tableContext.focusEnd.row === focusDetails.coordinates.row &&
49
- !tableContext.isMousingDown &&
50
- tableContext.focusStartIsBeingEdited
51
- );
52
-
53
- let isBeingEdited = $derived(false);
54
-
55
- function handleIsEditable(isEditable: boolean): Promise<void> {
56
- if (isEditable) {
57
- return tick().then(() => {
58
- isBeingEdited = true;
59
- });
60
- } else {
61
- if (isBeingEdited) {
62
- return tick()
63
- .then(() => {
64
- if (!tableContext.singleClickEditing) {
65
- tableContext.focusStartIsBeingEdited = false;
66
- }
67
-
68
- isBeingEdited = false;
69
- })
70
- .catch(devCatch);
71
- }
72
- }
73
-
74
- return Promise.resolve();
75
- }
76
-
77
- $effect(() => {
78
- void editable;
79
- if (wantsToBeEdited) {
80
- if (editable instanceof Promise) {
81
- editable
82
- .then((isEditable) => {
83
- return handleIsEditable(isEditable);
84
- })
85
-
86
- .catch(devCatch);
87
- } else {
88
- handleIsEditable(editable).catch(devCatch);
89
- }
90
- } else {
91
- tick()
92
- .then(() => {
93
- isBeingEdited = false;
94
- tableContext.focusStartIsBeingEdited = false;
95
- })
96
- .catch(devCatch);
97
- }
98
- });
99
-
100
- const optionsPromise = $derived(
101
- cell.column.columnDef.getSpecificOptions?.(
102
- cell.row.original,
103
- focusDetails.coordinates.column
104
- ) ?? cell.column.columnDef.getOptions()
105
- );
106
-
107
- let validity: Validity = $state(Validity.Valid);
108
- $effect(() => {
109
- const validityPromise = focusDetails.validity;
110
-
111
- validityPromise
112
- .then((v) => {
113
- if (!v) {
114
- validity = Validity.Neutral;
115
- } else if (isValidityTuple(v)) {
116
- validity = v.value;
117
- } else {
118
- validity = v;
119
- }
120
- })
121
- .catch(devCatch);
122
- });
123
-
124
- async function handleTDFocus(): Promise<boolean> {
125
- if (
126
- (await editable) &&
127
- tableContext.focusStart?.column === focusDetails.coordinates.column &&
128
- tableContext.focusStart.row === focusDetails.coordinates.row
129
- ) {
130
- if (
131
- tableContext.focusEnd?.column !== focusDetails.coordinates.column ||
132
- tableContext.focusEnd.row !== focusDetails.coordinates.row
133
- ) {
134
- tableContext.setFocusEnd(focusDetails.coordinates);
135
- }
136
-
137
- tableContext.isMousingDown = false;
138
- tableContext.focusStartIsBeingEdited = true;
139
- return true;
140
- }
141
-
142
- return false;
143
- }
144
-
145
- async function handleSingleClick(): Promise<boolean> {
146
- return tableContext.singleClickEditing && (await handleTDFocus());
147
- }
148
- async function handleDoubleClick(): Promise<boolean> {
149
- return !tableContext.singleClickEditing && (await handleTDFocus());
150
- }
151
-
152
- function handleTab(e: KeyboardEvent) {
153
- if (e.key === 'Escape') {
154
- e.preventDefault();
155
- e.stopPropagation();
156
-
157
- tableContext.focusStartIsBeingEdited = false;
158
- tick()
159
- .then(() => {
160
- tdref?.focus();
161
- })
162
- .catch(devCatch);
163
- }
164
- if (e.key === 'Tab') {
165
- e.preventDefault();
166
- }
167
- }
168
-
169
- function keydownForce(e: KeyboardEvent) {
170
- handleTab(e);
171
- if (!(e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
172
- tdref?.dispatchEvent(
173
- new KeyboardEvent('keydown', {
174
- key: e.key,
175
- altKey: e.getModifierState('Alt'),
176
- metaKey: e.getModifierState('Meta'),
177
- shiftKey: e.getModifierState('Shift'),
178
- ctrlKey: e.getModifierState('Control'),
179
- bubbles: true,
180
- })
181
- );
182
- }
183
- }
184
-
185
- function addKeydownEvent(target: HTMLInputElement | undefined) {
186
- target?.addEventListener('keydown', keydownForce);
187
- }
188
-
189
- function tryHandleTDFocus() {
190
- handleTDFocus().catch(devCatch);
191
- }
192
-
193
- let prevtdref: HTMLTableCellElement | undefined = undefined;
194
- $effect(() => {
195
- if (tdref) {
196
- if (tdref != prevtdref) {
197
- tdref.addEventListener('edit', tryHandleTDFocus);
198
- } else {
199
- prevtdref = tdref;
200
- }
201
- }
202
- });
203
- </script>
204
-
205
- {#if isBeingEdited}
206
- <!-- onkeydown={handleInputKeydown} -->
207
- <!-- onkeydown={handleEsc} -->
208
- <td
209
- class="select-cell"
210
- bind:this={tdref}
211
- >
212
- {#await Promise.all([optionsPromise, selectValue])}
213
- {loadingText}
214
- {:then [options, value]}
215
- <SingleSelect
216
- focusOnLoad
217
- name="Item"
218
- valueProp="value"
219
- labelProp="label"
220
- value={value ?? null}
221
- {options}
222
- width="100%"
223
- clearable={cell.column.columnDef.clearable}
224
- onfocus={addKeydownEvent}
225
- valueAsObject={false}
226
- onchange={(newValue: SelectOption<T> | null) => {
227
- if (newValue?.value !== value) {
228
- if (optional || newValue?.value != null) {
229
- tableContext
230
- .onEditCell(cell.row.original, focusDetails.coordinates, newValue?.value ?? null)
231
- .catch(devCatch);
232
- }
233
- }
234
- tableContext.focusStartIsBeingEdited = false;
235
- tick()
236
- .then(() => {
237
- tdref?.focus();
238
- })
239
- .catch(devCatch);
240
- }}
241
- />
242
- {:catch e}
243
- {#if dev}
244
- error: {e}
245
- <!-- eslint-disable-next-line svelte/no-at-debug-tags -->
246
- {@debug e}
247
- {/if}
248
- could not retrieve options
249
- {/await}
250
- </td>
251
- {:else}
252
- <!-- // onkeydown={handleTdKeydown} -->
253
- <!-- svelte-ignore a11y_mouse_events_have_key_events -->
254
- <td
255
- bind:this={tdref}
256
- tabIndex="0"
257
- style={focusDetails.outline}
258
- id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
259
- class="focusable editable"
260
- class:multifocus={focusDetails.isMultiFocused}
261
- class:multifocus-start={focusDetails.isMultiFocusStart}
262
- class:info={validity == Validity.Info}
263
- class:success={validity == Validity.Valid}
264
- class:warning={validity == Validity.Warning}
265
- class:error={validity == Validity.Invalid}
266
- ondblclick={() => {
267
- handleDoubleClick().catch(devCatch);
268
- }}
269
- onmousedown={(e) => {
270
- // start focus only on left click
271
- if (e.button === 0) {
272
- if (e.shiftKey) {
273
- e.preventDefault();
274
- tableContext.setFocusEnd(focusDetails.coordinates);
275
- } else {
276
- tableContext.startFocus(focusDetails.coordinates);
277
- }
278
- }
279
- }}
280
- onmouseover={() => {
281
- if (tableContext.isMousingDown) {
282
- tableContext.setFocusEnd(focusDetails.coordinates);
283
- }
284
- }}
285
- onmouseup={() => {
286
- handleSingleClick()
287
- .then((wasHandled) => {
288
- if (!wasHandled) {
289
- tableContext.endFocus(focusDetails.coordinates);
290
- }
291
- })
292
- .catch(devCatch);
293
- }}
294
- >{#await visibleValue}
295
- {loadingText}
296
- {:then value}
297
- {value ?? '-'}
298
- {:catch e}
299
- {#if dev}
300
- error: {e}
301
- <!-- eslint-disable-next-line svelte/no-at-debug-tags -->
302
- {@debug e}
303
- {/if}
304
- Could not retrieve options
305
- {/await}</td
306
- >
307
- {/if}
308
-
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ module
6
+ >
7
+ import { dev } from '$app/environment';
8
+ import SingleSelect from '../../../../SingleSelect.svelte';
9
+ import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
10
+ import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
11
+ import { devCatch, isValidityTuple, loadingText } from '../../../../../Helpers/Helpers.svelte.js';
12
+ import type { SelectOption } from '../../../../../Types/Internal/SelectOption.js';
13
+ import { Validity } from '../../../../../Types/Internal/Validity.js';
14
+ import { getContext, tick } from 'svelte';
15
+ import type { TableSelectProps } from './TableSelectProps.js';
16
+ </script>
17
+
18
+ <script
19
+ lang="ts"
20
+ generics="T extends object"
21
+ >
22
+ const { cell }: TableSelectProps<T, T> = $props();
23
+
24
+ let tdref = $state<HTMLTableCellElement | undefined>();
25
+
26
+ const selectValue = $derived(cell.getValue() as T | Promise<T> | null | undefined);
27
+
28
+ const visibleValue = $derived(
29
+ cell.column.columnDef.getDisplayValue(cell.row.original, cell.row.originalIndex)
30
+ );
31
+
32
+ const optional = $derived(cell.column.columnDef.optional);
33
+
34
+ const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
35
+
36
+ const editable = $derived(
37
+ cell.column.columnDef.isEditable(cell.row.original, cell.row.originalIndex)
38
+ );
39
+
40
+ const focusDetails: TableFocusDetails<T, never> = $derived(
41
+ new TableFocusDetails(cell, tableContext)
42
+ );
43
+
44
+ const wantsToBeEdited = $derived(
45
+ tableContext.focusStart?.column === focusDetails.coordinates.column &&
46
+ tableContext.focusEnd?.column === focusDetails.coordinates.column &&
47
+ tableContext.focusStart.row === focusDetails.coordinates.row &&
48
+ tableContext.focusEnd.row === focusDetails.coordinates.row &&
49
+ !tableContext.isMousingDown &&
50
+ tableContext.focusStartIsBeingEdited
51
+ );
52
+
53
+ let isBeingEdited = $derived(false);
54
+
55
+ function handleIsEditable(isEditable: boolean): Promise<void> {
56
+ if (isEditable) {
57
+ return tick().then(() => {
58
+ isBeingEdited = true;
59
+ });
60
+ } else {
61
+ if (isBeingEdited) {
62
+ return tick()
63
+ .then(() => {
64
+ if (!tableContext.singleClickEditing) {
65
+ tableContext.focusStartIsBeingEdited = false;
66
+ }
67
+
68
+ isBeingEdited = false;
69
+ })
70
+ .catch(devCatch);
71
+ }
72
+ }
73
+
74
+ return Promise.resolve();
75
+ }
76
+
77
+ $effect(() => {
78
+ void editable;
79
+ if (wantsToBeEdited) {
80
+ if (editable instanceof Promise) {
81
+ editable
82
+ .then((isEditable) => {
83
+ return handleIsEditable(isEditable);
84
+ })
85
+
86
+ .catch(devCatch);
87
+ } else {
88
+ handleIsEditable(editable).catch(devCatch);
89
+ }
90
+ } else {
91
+ tick()
92
+ .then(() => {
93
+ isBeingEdited = false;
94
+ tableContext.focusStartIsBeingEdited = false;
95
+ })
96
+ .catch(devCatch);
97
+ }
98
+ });
99
+
100
+ const optionsPromise = $derived(
101
+ cell.column.columnDef.getSpecificOptions?.(
102
+ cell.row.original,
103
+ focusDetails.coordinates.column
104
+ ) ?? cell.column.columnDef.getOptions()
105
+ );
106
+
107
+ let validity: Validity = $state(Validity.Valid);
108
+ $effect(() => {
109
+ const validityPromise = focusDetails.validity;
110
+
111
+ validityPromise
112
+ .then((v) => {
113
+ if (!v) {
114
+ validity = Validity.Neutral;
115
+ } else if (isValidityTuple(v)) {
116
+ validity = v.value;
117
+ } else {
118
+ validity = v;
119
+ }
120
+ })
121
+ .catch(devCatch);
122
+ });
123
+
124
+ async function handleTDFocus(): Promise<boolean> {
125
+ if (
126
+ (await editable) &&
127
+ tableContext.focusStart?.column === focusDetails.coordinates.column &&
128
+ tableContext.focusStart.row === focusDetails.coordinates.row
129
+ ) {
130
+ if (
131
+ tableContext.focusEnd?.column !== focusDetails.coordinates.column ||
132
+ tableContext.focusEnd.row !== focusDetails.coordinates.row
133
+ ) {
134
+ tableContext.setFocusEnd(focusDetails.coordinates);
135
+ }
136
+
137
+ tableContext.isMousingDown = false;
138
+ tableContext.focusStartIsBeingEdited = true;
139
+ return true;
140
+ }
141
+
142
+ return false;
143
+ }
144
+
145
+ async function handleSingleClick(): Promise<boolean> {
146
+ return tableContext.singleClickEditing && (await handleTDFocus());
147
+ }
148
+ async function handleDoubleClick(): Promise<boolean> {
149
+ return !tableContext.singleClickEditing && (await handleTDFocus());
150
+ }
151
+
152
+ function handleTab(e: KeyboardEvent) {
153
+ if (e.key === 'Escape') {
154
+ e.preventDefault();
155
+ e.stopPropagation();
156
+
157
+ tableContext.focusStartIsBeingEdited = false;
158
+ tick()
159
+ .then(() => {
160
+ tdref?.focus();
161
+ })
162
+ .catch(devCatch);
163
+ }
164
+ if (e.key === 'Tab') {
165
+ e.preventDefault();
166
+ }
167
+ }
168
+
169
+ function keydownForce(e: KeyboardEvent) {
170
+ handleTab(e);
171
+ if (!(e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
172
+ tdref?.dispatchEvent(
173
+ new KeyboardEvent('keydown', {
174
+ key: e.key,
175
+ altKey: e.getModifierState('Alt'),
176
+ metaKey: e.getModifierState('Meta'),
177
+ shiftKey: e.getModifierState('Shift'),
178
+ ctrlKey: e.getModifierState('Control'),
179
+ bubbles: true,
180
+ })
181
+ );
182
+ }
183
+ }
184
+
185
+ function addKeydownEvent(target: HTMLInputElement | undefined) {
186
+ target?.addEventListener('keydown', keydownForce);
187
+ }
188
+
189
+ function tryHandleTDFocus() {
190
+ handleTDFocus().catch(devCatch);
191
+ }
192
+
193
+ let prevtdref: HTMLTableCellElement | undefined = undefined;
194
+ $effect(() => {
195
+ if (tdref) {
196
+ if (tdref != prevtdref) {
197
+ tdref.addEventListener('edit', tryHandleTDFocus);
198
+ } else {
199
+ prevtdref = tdref;
200
+ }
201
+ }
202
+ });
203
+ </script>
204
+
205
+ {#if isBeingEdited}
206
+ <!-- onkeydown={handleInputKeydown} -->
207
+ <!-- onkeydown={handleEsc} -->
208
+ <td
209
+ class="select-cell"
210
+ bind:this={tdref}
211
+ >
212
+ {#await Promise.all([optionsPromise, selectValue])}
213
+ {loadingText}
214
+ {:then [options, value]}
215
+ <SingleSelect
216
+ focusOnLoad
217
+ name="Item"
218
+ valueProp="value"
219
+ labelProp="label"
220
+ value={value ?? null}
221
+ {options}
222
+ width="100%"
223
+ clearable={cell.column.columnDef.clearable}
224
+ onfocus={addKeydownEvent}
225
+ valueAsObject={false}
226
+ onchange={(newValue: SelectOption<T> | null) => {
227
+ if (newValue?.value !== value) {
228
+ if (optional || newValue?.value != null) {
229
+ tableContext
230
+ .onEditCell(cell.row.original, focusDetails.coordinates, newValue?.value ?? null)
231
+ .catch(devCatch);
232
+ }
233
+ }
234
+ tableContext.focusStartIsBeingEdited = false;
235
+ tick()
236
+ .then(() => {
237
+ tdref?.focus();
238
+ })
239
+ .catch(devCatch);
240
+ }}
241
+ />
242
+ {:catch e}
243
+ {#if dev}
244
+ error: {e}
245
+ <!-- eslint-disable-next-line svelte/no-at-debug-tags -->
246
+ {@debug e}
247
+ {/if}
248
+ could not retrieve options
249
+ {/await}
250
+ </td>
251
+ {:else}
252
+ <!-- // onkeydown={handleTdKeydown} -->
253
+ <!-- svelte-ignore a11y_mouse_events_have_key_events -->
254
+ <td
255
+ bind:this={tdref}
256
+ tabIndex="0"
257
+ style={focusDetails.outline}
258
+ id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
259
+ class="focusable editable"
260
+ class:multifocus={focusDetails.isMultiFocused}
261
+ class:multifocus-start={focusDetails.isMultiFocusStart}
262
+ class:info={validity == Validity.Info}
263
+ class:success={validity == Validity.Valid}
264
+ class:warning={validity == Validity.Warning}
265
+ class:error={validity == Validity.Invalid}
266
+ ondblclick={() => {
267
+ handleDoubleClick().catch(devCatch);
268
+ }}
269
+ onmousedown={(e) => {
270
+ // start focus only on left click
271
+ if (e.button === 0) {
272
+ if (e.shiftKey) {
273
+ e.preventDefault();
274
+ tableContext.setFocusEnd(focusDetails.coordinates);
275
+ } else {
276
+ tableContext.startFocus(focusDetails.coordinates);
277
+ }
278
+ }
279
+ }}
280
+ onmouseover={() => {
281
+ if (tableContext.isMousingDown) {
282
+ tableContext.setFocusEnd(focusDetails.coordinates);
283
+ }
284
+ }}
285
+ onmouseup={() => {
286
+ handleSingleClick()
287
+ .then((wasHandled) => {
288
+ if (!wasHandled) {
289
+ tableContext.endFocus(focusDetails.coordinates);
290
+ }
291
+ })
292
+ .catch(devCatch);
293
+ }}
294
+ >{#await visibleValue}
295
+ {loadingText}
296
+ {:then value}
297
+ {value ?? '-'}
298
+ {:catch e}
299
+ {#if dev}
300
+ error: {e}
301
+ <!-- eslint-disable-next-line svelte/no-at-debug-tags -->
302
+ {@debug e}
303
+ {/if}
304
+ Could not retrieve options
305
+ {/await}</td
306
+ >
307
+ {/if}
308
+
309
309
  <style>td {
310
310
  transition: line-height 0.2s ease, height 0.2s ease;
311
311
  --input-border: none;
@@ -361,4 +361,4 @@ td :global(.select-wrapper) {
361
361
  --sv-general-padding: 0px;
362
362
  --sv-item-wrap-padding: 0px 0.75rem;
363
363
  --input-height: var(--height);
364
- }</style>
364
+ }</style>