@lavalogic/scoria 0.7.1 → 0.7.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.
@@ -55,26 +55,28 @@
55
55
  let asyncCounter = 0;
56
56
  $effect(() => {
57
57
  void editableAsync;
58
- const localCounter = (asyncCounter = asyncCounter + 1);
59
- (async () => {
60
- try {
61
- const isEditable = await editableAsync;
62
- if (asyncCounter === localCounter) {
63
- editable = isEditable;
64
- } else if (dev) {
65
- console.log('skipping async editable because it is stale');
66
- }
67
- } catch (e) {
68
- if (dev) {
69
- console.error(e);
70
- }
71
- if (asyncCounter === localCounter) {
72
- editable = false;
73
- } else if (dev) {
74
- console.log('skipping async editable because it is stale');
58
+ untrack(() => {
59
+ const localCounter = (asyncCounter = asyncCounter + 1);
60
+ (async () => {
61
+ try {
62
+ const isEditable = await editableAsync;
63
+ if (asyncCounter === localCounter) {
64
+ editable = isEditable;
65
+ } else if (dev) {
66
+ console.log('skipping async editable because it is stale');
67
+ }
68
+ } catch (e) {
69
+ if (dev) {
70
+ console.error(e);
71
+ }
72
+ if (asyncCounter === localCounter) {
73
+ editable = false;
74
+ } else if (dev) {
75
+ console.log('skipping async editable because it is stale');
76
+ }
75
77
  }
76
- }
77
- })();
78
+ })();
79
+ });
78
80
  });
79
81
 
80
82
  const focusDetails: TableFocusDetails<T> = $derived(
@@ -266,7 +268,7 @@
266
268
  tableContext.onEditCell(
267
269
  cell.row.original,
268
270
  focusDetails.coordinates,
269
- newValue?.value ?? null
271
+ columnDef.valueAsObject ? (newValue ?? null) : (newValue?.value ?? null)
270
272
  );
271
273
  }
272
274
 
@@ -11,6 +11,7 @@ import { DisplayDef } from '../Types/Columns/Definitions/Display/DisplayDef.svel
11
11
  import { ProgressBarDef } from '../Types/Columns/Definitions/Display/ProgressBarDef.svelte.js';
12
12
  import { ValidityDef } from '../Types/Columns/Definitions/Display/ValidityDef.svelte.js';
13
13
  import { asyncSleep } from '../../../Helpers/Helpers.svelte.js';
14
+ import { QueryDef } from '../Types/Columns/Definitions/Accessors/QueryDef.svelte.js';
14
15
  export class ExampleItemColumnDef {
15
16
  static generateExampleItemColumnDefs(modal) {
16
17
  let defs = $state([
@@ -39,6 +40,32 @@ export class ExampleItemColumnDef {
39
40
  id: 'id',
40
41
  filterValueType: 'Number'
41
42
  }),
43
+ new QueryDef({
44
+ header: 'simulated query def',
45
+ valueAsObject: true,
46
+ getDisplayValue: async (item, index) => {
47
+ if (item.someDate) {
48
+ return item.someDate.getTime().toString();
49
+ }
50
+ return index.toString();
51
+ },
52
+ isEditable: () => true,
53
+ id: 'simulatedQuery',
54
+ query: async (v, item, index) => {
55
+ if (!v) {
56
+ return [];
57
+ }
58
+ asyncSleep(100);
59
+ return item.someDate
60
+ ? new Array(5).fill(0).map((it, index) => {
61
+ return {
62
+ label: (it + index).toString(),
63
+ value: (it + index).toString()
64
+ };
65
+ })
66
+ : [];
67
+ }
68
+ }),
42
69
  new TextInputDef({
43
70
  header: 'Name',
44
71
  id: 'name',
@@ -600,7 +600,13 @@ export class TableContext {
600
600
  const rows = sortedData.map((item, index) => {
601
601
  const unsortedIndex = this.originalRowIndices.get(item) ?? index;
602
602
  const row = {
603
- getValue: (key) => this.columnDefsById.get(key).accessorFn?.(item, index) ?? item[key],
603
+ getValue: (key) => {
604
+ const gotValue = this.columnDefsById.get(key).accessorFn?.(item, index);
605
+ if (gotValue !== undefined) {
606
+ return gotValue;
607
+ }
608
+ return item[key];
609
+ },
604
610
  original: item,
605
611
  visibleIndex: index,
606
612
  originalIndex: unsortedIndex,
@@ -633,7 +639,13 @@ export class TableContext {
633
639
  },
634
640
  id: `${index}_${def.id}`,
635
641
  row: row,
636
- getValue: () => def.accessorFn?.(item, index) ?? item[def.id] // TODO
642
+ getValue: () => {
643
+ const gotValue = def.accessorFn?.(item, index);
644
+ if (gotValue !== undefined) {
645
+ return gotValue;
646
+ }
647
+ return item[def.id];
648
+ }
637
649
  };
638
650
  };
639
651
  const makeCellFromId = (columnId) => {
@@ -1585,7 +1597,13 @@ export class TableContext {
1585
1597
  // #region private methods
1586
1598
  createRow(item, index, unsortedIndex) {
1587
1599
  const row = {
1588
- getValue: (key) => this.columnDefsById.get(key).accessorFn?.(item, unsortedIndex) ?? item[key],
1600
+ getValue: (key) => {
1601
+ const gotValue = this.columnDefsById.get(key).accessorFn?.(item, unsortedIndex);
1602
+ if (gotValue !== undefined) {
1603
+ return gotValue;
1604
+ }
1605
+ return item[key];
1606
+ },
1589
1607
  original: item,
1590
1608
  visibleIndex: index,
1591
1609
  originalIndex: unsortedIndex,
@@ -1618,7 +1636,13 @@ export class TableContext {
1618
1636
  },
1619
1637
  id: `${index}_${def.id}`,
1620
1638
  row: row,
1621
- getValue: () => def.accessorFn?.(item, index) ?? item[def.id] // TODO
1639
+ getValue: () => {
1640
+ const gotValue = def.accessorFn?.(item, index);
1641
+ if (gotValue !== undefined) {
1642
+ return gotValue;
1643
+ }
1644
+ return item[def.id];
1645
+ }
1622
1646
  };
1623
1647
  };
1624
1648
  const makeCellFromId = (columnId) => {
@@ -1,4 +1,5 @@
1
1
  import type { SQLDate } from '../Internal/Misc.js';
2
+ import type { SelectOption } from '../Internal/SelectOption.js';
2
3
  import type { ExampleSelectEnum } from './ExampleSelectEnum.js';
3
4
  export interface ExampleItem {
4
5
  id: number;
@@ -12,4 +13,5 @@ export interface ExampleItem {
12
13
  floDateWithTime: SQLDate | null;
13
14
  someSelect: ExampleSelectEnum | null;
14
15
  someBubbles: string[];
16
+ simulatedQuery: SelectOption<string> | null;
15
17
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lavalogic/scoria",
3
3
  "description": "Svelte components used for the FloWMS Web Frontend",
4
- "version": "0.7.1",
4
+ "version": "0.7.3",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },