@lavalogic/scoria 0.37.29 → 0.37.31
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/SingleSelect.svelte +19 -0
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +24 -0
- package/dist/Components/Table/ColumnFactory.svelte.js +12 -1
- package/dist/Components/Table/Types/Context/TableContext.svelte.js +18 -3
- package/dist/Components/Table/createTable.svelte.js +15 -0
- package/package.json +1 -1
|
@@ -179,10 +179,29 @@
|
|
|
179
179
|
// svelecte always emits the full option object regardless of
|
|
180
180
|
// `valueAsObject`. Map to the shape the discriminated variant
|
|
181
181
|
// promised: primitive for AsPrimitive, object for AsObject.
|
|
182
|
+
if (typeof window !== 'undefined') {
|
|
183
|
+
// eslint-disable-next-line no-console
|
|
184
|
+
console.debug('%c[scoria/SingleSelect] svelecte onChange fired', 'color:#a0a', {
|
|
185
|
+
inputId,
|
|
186
|
+
name,
|
|
187
|
+
newValue,
|
|
188
|
+
newValueType: typeof newValue,
|
|
189
|
+
valueAsObject,
|
|
190
|
+
valueProp,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
182
193
|
if (valueAsObject) {
|
|
183
194
|
void (onchange as (v: V | null) => void | Promise<void>)(newValue);
|
|
184
195
|
} else {
|
|
185
196
|
const primitive = newValue == null ? null : newValue[valueProp];
|
|
197
|
+
if (typeof window !== 'undefined') {
|
|
198
|
+
// eslint-disable-next-line no-console
|
|
199
|
+
console.debug(
|
|
200
|
+
'%c[scoria/SingleSelect] calling outer onchange with primitive',
|
|
201
|
+
'color:#a0a',
|
|
202
|
+
{ primitive }
|
|
203
|
+
);
|
|
204
|
+
}
|
|
186
205
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
187
206
|
void (onchange as (v: V[VP] | null) => void | Promise<void>)(primitive);
|
|
188
207
|
}
|
|
@@ -145,8 +145,32 @@
|
|
|
145
145
|
// V (from `value: T`) clashes with the option type
|
|
146
146
|
// (`SelectOption<T>`); the casts let `V` be inferred
|
|
147
147
|
// from the explicit `onchange` annotation.
|
|
148
|
+
if (dev) {
|
|
149
|
+
console.debug(
|
|
150
|
+
'%c[scoria/TableSelect] onchange fired',
|
|
151
|
+
'color:#0a0',
|
|
152
|
+
{
|
|
153
|
+
columnId: cell.column.columnDef.id,
|
|
154
|
+
newValue,
|
|
155
|
+
newValueType: typeof newValue,
|
|
156
|
+
oldValue: value,
|
|
157
|
+
optional,
|
|
158
|
+
willEdit: newValue !== value && (optional || newValue != null),
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
148
162
|
if (newValue !== value) {
|
|
149
163
|
if (optional || newValue != null) {
|
|
164
|
+
if (dev) {
|
|
165
|
+
console.debug(
|
|
166
|
+
'%c[scoria/TableSelect] calling tableContext.onEditCell',
|
|
167
|
+
'color:#0a0',
|
|
168
|
+
{
|
|
169
|
+
coords: $state.snapshot(editable.focusDetails.coordinates),
|
|
170
|
+
value: newValue,
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
150
174
|
tableContext
|
|
151
175
|
.onEditCell(cell.row.original, editable.focusDetails.coordinates, newValue ?? null)
|
|
152
176
|
.catch(devCatch);
|
|
@@ -294,7 +294,18 @@ export function createColumnFactory() {
|
|
|
294
294
|
.query(queryString, item)
|
|
295
295
|
.then((res) => res),
|
|
296
296
|
getDisplayValue: opts.getDisplayValue ?? ((row) => String(row[opts.id] ?? '')),
|
|
297
|
-
|
|
297
|
+
// Query columns have no static option set (the dropdown
|
|
298
|
+
// is built per-keystroke via the consumer's `query`
|
|
299
|
+
// callback), so the quick-filter row cannot render a
|
|
300
|
+
// `Select`-shaped chip with a fixed option list - that
|
|
301
|
+
// produced "def <id> is declared as a select filter but
|
|
302
|
+
// has no getOptions() function" in dev. Use a `String`
|
|
303
|
+
// filter shape so the quick-filter row renders a free
|
|
304
|
+
// text input; for remote-pagination tables the typed
|
|
305
|
+
// value is forwarded to the server filter, and for
|
|
306
|
+
// local data it falls through to substring matching on
|
|
307
|
+
// the `getDisplayValue` result.
|
|
308
|
+
filterValueType: FilterValueType.String,
|
|
298
309
|
});
|
|
299
310
|
return makeSpec('query', def, {
|
|
300
311
|
onEdit: opts.onEdit,
|
|
@@ -276,9 +276,24 @@ export class TableContext {
|
|
|
276
276
|
if (current !== latest_sortedRowModel) {
|
|
277
277
|
throw new Error(`stale data`);
|
|
278
278
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
// Do NOT throw when `originalIndex` is missing. The
|
|
280
|
+
// `originalRowIndices` effect and this one both
|
|
281
|
+
// re-derive asynchronously on `dataRepo.data`
|
|
282
|
+
// changes; when a row is added (e.g. the
|
|
283
|
+
// auto-pushed empty pod line that fires after a
|
|
284
|
+
// user picks an SKU), the sortedRowModel rebuild
|
|
285
|
+
// can win the race and run against a still-stale
|
|
286
|
+
// `ori` map that does not yet contain the new
|
|
287
|
+
// row's key. The previous `throw` rejected the
|
|
288
|
+
// `Promise.all` for the entire rebuild, which
|
|
289
|
+
// left `_sortedRowModel` pinned to the pre-edit
|
|
290
|
+
// snapshot and stopped editable cells from
|
|
291
|
+
// reflecting their post-edit state - the visible
|
|
292
|
+
// symptom on Receipt's SKU cell. Falling back to
|
|
293
|
+
// `unsortedIndex = index` is a fine approximation
|
|
294
|
+
// for the missing entry; the next reactive pass
|
|
295
|
+
// (after `originalRowIndices` catches up) refines
|
|
296
|
+
// it.
|
|
282
297
|
return this.createRow(item, index, unsortedIndex);
|
|
283
298
|
}))
|
|
284
299
|
.then((rows) => {
|
|
@@ -255,9 +255,24 @@ function makeOnEditCell(editHandlers, onAnyEdit) {
|
|
|
255
255
|
}
|
|
256
256
|
return async (item, coords, value) => {
|
|
257
257
|
const handler = editHandlers.get(coords.id);
|
|
258
|
+
if (typeof window !== 'undefined') {
|
|
259
|
+
// eslint-disable-next-line no-console
|
|
260
|
+
console.debug('%c[scoria/makeOnEditCell] dispatching', 'color:#08f', {
|
|
261
|
+
coordsId: coords.id,
|
|
262
|
+
value,
|
|
263
|
+
handlerFound: !!handler,
|
|
264
|
+
registeredHandlerKeys: Array.from(editHandlers.keys()),
|
|
265
|
+
});
|
|
266
|
+
}
|
|
258
267
|
if (handler) {
|
|
259
268
|
try {
|
|
260
269
|
await handler(item, value, coords);
|
|
270
|
+
if (typeof window !== 'undefined') {
|
|
271
|
+
// eslint-disable-next-line no-console
|
|
272
|
+
console.debug('%c[scoria/makeOnEditCell] handler resolved', 'color:#08f', {
|
|
273
|
+
coordsId: coords.id,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
261
276
|
}
|
|
262
277
|
catch (e) {
|
|
263
278
|
devCatch(e);
|