@lavalogic/scoria 0.0.39 → 0.0.41

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.
@@ -2,14 +2,13 @@
2
2
 
3
3
  <script lang="ts" module>
4
4
  interface QuerySelectPropsAsObjectCommonProps<V extends object, VP extends ValueProp<V>> {
5
- options: V[];
6
-
7
5
  labelProp: NonNullableKey<V>;
8
6
  valueProp: VP;
9
7
 
10
8
  query: (value: string) => Promise<V[]>;
11
9
  onchange: (newValue: V | null) => void;
12
10
 
11
+ options?: V[];
13
12
  name?: string;
14
13
  disabled?: boolean;
15
14
  width?: string;
@@ -34,6 +33,7 @@
34
33
  extends QuerySelectPropsAsObjectCommonProps<V, VP> {
35
34
  valueAsObject: false;
36
35
  value: V[VP] | null;
36
+ options: V[];
37
37
  }
38
38
 
39
39
  export type QuerySelectProps<V extends object, VP extends ValueProp<V>> =
@@ -1,9 +1,9 @@
1
1
  interface QuerySelectPropsAsObjectCommonProps<V extends object, VP extends ValueProp<V>> {
2
- options: V[];
3
2
  labelProp: NonNullableKey<V>;
4
3
  valueProp: VP;
5
4
  query: (value: string) => Promise<V[]>;
6
5
  onchange: (newValue: V | null) => void;
6
+ options?: V[];
7
7
  name?: string;
8
8
  disabled?: boolean;
9
9
  width?: string;
@@ -24,6 +24,7 @@ export interface QuerySelectPropsAsObject<V extends object, VP extends ValueProp
24
24
  export interface QuerySelectPropsAsPrimitive<V extends object, VP extends ValueProp<V>> extends QuerySelectPropsAsObjectCommonProps<V, VP> {
25
25
  valueAsObject: false;
26
26
  value: V[VP] | null;
27
+ options: V[];
27
28
  }
28
29
  export type QuerySelectProps<V extends object, VP extends ValueProp<V>> = QuerySelectPropsAsObject<V, VP> | QuerySelectPropsAsPrimitive<V, VP>;
29
30
  import type { NonNullableKey, ValueProp } from '../Types/Internal/Misc.js';
@@ -2,6 +2,7 @@
2
2
 
3
3
  <script lang="ts" module>
4
4
  import QuerySelect from '../../../../QuerySelect.svelte';
5
+ import type { Column } from '../../../Types/Columns/Column.js';
5
6
  import type { QueryDef } from '../../../Types/Columns/Definitions/Accessors/QueryDef.svelte.js';
6
7
  import type { TableCell } from '../../../Types/Columns/TableCell.js';
7
8
  import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
@@ -10,8 +11,17 @@
10
11
  import type { SelectOption } from '../../../../../Types/Internal/SelectOption.js';
11
12
  import { Validity } from '../../../../../Types/Internal/Validity.js';
12
13
  import { getContext, tick, untrack } from 'svelte';
14
+
15
+ export interface TableQueryColumn<T extends object> extends Column<T> {
16
+ columnDef: QueryDef<T>;
17
+ }
18
+
19
+ export interface TableQueryCell<T extends object> extends TableCell<T> {
20
+ column: TableQueryColumn<T>;
21
+ }
22
+
13
23
  export interface TableQuerySelectProps<T extends object> {
14
- cell: TableCell<T>;
24
+ cell: TableQueryCell<T>;
15
25
  }
16
26
  </script>
17
27
 
@@ -22,6 +32,10 @@
22
32
  (cell.getValue() ?? null) as SelectOption<unknown> | Promise<SelectOption<unknown>> | null
23
33
  );
24
34
 
35
+ const visibleValue = $derived(
36
+ cell.column.columnDef.getDisplayValue(cell.row.original, cell.row.originalIndex)
37
+ );
38
+
25
39
  let tdref = $state<HTMLTableCellElement | undefined>();
26
40
 
27
41
  const columnDef: QueryDef<T> = $derived(cell.column.columnDef) as unknown as QueryDef<T>; // TODO stabilise and remove `as unknown`
@@ -269,7 +283,7 @@
269
283
  }
270
284
  }}
271
285
  >
272
- {#await value}
286
+ {#await visibleValue}
273
287
  loading…
274
288
  {:then v}
275
289
  {v}
@@ -1,6 +1,14 @@
1
+ import type { Column } from '../../../Types/Columns/Column.js';
2
+ import type { QueryDef } from '../../../Types/Columns/Definitions/Accessors/QueryDef.svelte.js';
1
3
  import type { TableCell } from '../../../Types/Columns/TableCell.js';
4
+ export interface TableQueryColumn<T extends object> extends Column<T> {
5
+ columnDef: QueryDef<T>;
6
+ }
7
+ export interface TableQueryCell<T extends object> extends TableCell<T> {
8
+ column: TableQueryColumn<T>;
9
+ }
2
10
  export interface TableQuerySelectProps<T extends object> {
3
- cell: TableCell<T>;
11
+ cell: TableQueryCell<T>;
4
12
  }
5
13
  declare function $$render<T extends object>(): {
6
14
  props: TableQuerySelectProps<T>;
@@ -1,7 +1,6 @@
1
1
  <svelte:options runes />
2
2
 
3
3
  <script lang="ts" module>
4
- import { dev } from '$app/environment';
5
4
  import SingleSelect from '../../../../SingleSelect.svelte';
6
5
  import type { Column } from '../../../Types/Columns/Column.js';
7
6
  import type { SelectDef } from '../../../Types/Columns/Definitions/Accessors/SelectDef.svelte.js';
@@ -5,10 +5,12 @@ import { AccessorDef } from './AccessorDef.svelte.js';
5
5
  export interface QueryDefProps<T extends object> extends ColumnDefProps<T> {
6
6
  valueAsObject: boolean;
7
7
  query: (queryString: string, item: T, index: number) => Promise<Array<SelectOption<unknown>>>;
8
+ getDisplayValue: (item: T, index: number) => string | null | Promise<string | null>;
8
9
  }
9
10
  export declare class QueryDef<T extends object> extends AccessorDef<T, StringFilterValueType> {
10
11
  readonly accessorType: "Query";
11
12
  constructor(props: QueryDefProps<T>);
12
13
  readonly valueAsObject: boolean;
14
+ readonly getDisplayValue: (item: T, index: number) => string | null | Promise<string | null>;
13
15
  readonly query: (queryString: string, item: T, index: number) => Promise<Array<SelectOption<unknown>>>;
14
16
  }
@@ -6,7 +6,9 @@ export class QueryDef extends AccessorDef {
6
6
  super(props);
7
7
  this.valueAsObject = $derived(props.valueAsObject);
8
8
  this.query = $derived(props.query);
9
+ this.getDisplayValue = $derived(props.getDisplayValue);
9
10
  }
10
11
  valueAsObject;
12
+ getDisplayValue;
11
13
  query;
12
14
  }
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.0.39",
4
+ "version": "0.0.41",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },