@lavalogic/scoria 0.5.1 → 0.5.4
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/Table/Body/QuickSearchCell.svelte +14 -5
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +2 -0
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +6 -6
- package/dist/Components/Table/Misc/FilterInput.svelte +19 -8
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/SelectDef.svelte.d.ts +0 -1
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/SelectDef.svelte.js +0 -1
- package/dist/Components/Table/Types/Context/TableContext.svelte.d.ts +1 -2
- package/dist/Components/Table/Types/Context/TableContext.svelte.js +2 -3
- package/dist/Components/Table/Types/DataRepository/IDataRepository.d.ts +1 -0
- package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.d.ts +1 -0
- package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.js +1 -0
- package/dist/Components/Table/Types/Filtering/CustomFilter.d.ts +1 -0
- package/package.json +1 -1
|
@@ -125,8 +125,13 @@
|
|
|
125
125
|
// as unknown as string | number | undefined;
|
|
126
126
|
|
|
127
127
|
if (gotValue != undefined) {
|
|
128
|
-
const key =
|
|
129
|
-
|
|
128
|
+
const key =
|
|
129
|
+
customFilter?.id ??
|
|
130
|
+
customFilter?.label ??
|
|
131
|
+
customFilter?.objectName ??
|
|
132
|
+
customFilter?.queryKey ??
|
|
133
|
+
def.id;
|
|
134
|
+
const x = key == null ? null : tableContext.dataRepo.__queryValues.get(key);
|
|
130
135
|
value = (x ?? null) as SelectOption<unknown> | null;
|
|
131
136
|
}
|
|
132
137
|
} catch (e) {
|
|
@@ -286,7 +291,11 @@
|
|
|
286
291
|
{#if hasQuery}
|
|
287
292
|
{#if typeof value == 'object'}
|
|
288
293
|
{@const label =
|
|
289
|
-
customFilter
|
|
294
|
+
customFilter?.id ??
|
|
295
|
+
customFilter?.label ??
|
|
296
|
+
customFilter?.objectName ??
|
|
297
|
+
customFilter?.queryKey ??
|
|
298
|
+
def.id}
|
|
290
299
|
<!-- TODO: multiselect -->
|
|
291
300
|
|
|
292
301
|
<QuerySelect
|
|
@@ -300,8 +309,8 @@
|
|
|
300
309
|
bind:options={lastQueryOptions}
|
|
301
310
|
onchange={(newValue) => {
|
|
302
311
|
tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
|
|
303
|
-
tableContext.__queryValues.set(label, newValue);
|
|
304
|
-
value = newValue as SelectOption<
|
|
312
|
+
tableContext.dataRepo.__queryValues.set(label, newValue);
|
|
313
|
+
value = newValue as SelectOption<T> | null;
|
|
305
314
|
}}
|
|
306
315
|
/>
|
|
307
316
|
{:else}
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
|
|
29
29
|
let tdref = $state<HTMLTableCellElement | undefined>();
|
|
30
30
|
|
|
31
|
-
const selectValue = $derived(cell.getValue());
|
|
31
|
+
const selectValue = $derived(cell.getValue() as T |null|undefined);
|
|
32
32
|
|
|
33
33
|
const visibleValue = $derived(
|
|
34
|
-
cell.column.columnDef.getDisplayValue(cell.row.original, cell.row.originalIndex)
|
|
34
|
+
cell.column.columnDef.getDisplayValue!(cell.row.original, cell.row.originalIndex)
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
const optional = $derived((cell.column.columnDef as SelectDef<T>).optional ?? false);
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
const optionsPromise = $derived(
|
|
89
|
-
cell.column.columnDef.getSpecificOptions?.(
|
|
89
|
+
(cell.column.columnDef.getSpecificOptions?.(
|
|
90
90
|
cell.row.original,
|
|
91
91
|
focusDetails.coordinates.column
|
|
92
|
-
) ?? cell.column.columnDef.getOptions()
|
|
92
|
+
) ?? cell.column.columnDef.getOptions()) as SelectOption<T>[] | Promise<SelectOption<T>[]>
|
|
93
93
|
);
|
|
94
94
|
|
|
95
95
|
let previousValidity: Validity = $state(Validity.Valid);
|
|
@@ -205,13 +205,13 @@
|
|
|
205
205
|
name="Item"
|
|
206
206
|
valueProp="value"
|
|
207
207
|
labelProp="label"
|
|
208
|
-
value={selectValue}
|
|
208
|
+
value={selectValue ?? null}
|
|
209
209
|
{options}
|
|
210
210
|
width="100%"
|
|
211
211
|
clearable={cell.column.columnDef.clearable}
|
|
212
212
|
onfocus={addKeydownEvent}
|
|
213
213
|
valueAsObject={false}
|
|
214
|
-
onchange={(newValue: SelectOption<
|
|
214
|
+
onchange={(newValue: SelectOption<T> | null) => {
|
|
215
215
|
if (newValue?.value !== value) {
|
|
216
216
|
if (optional || newValue?.value != null) {
|
|
217
217
|
tableContext.onEditCell(
|
|
@@ -161,8 +161,13 @@
|
|
|
161
161
|
// as unknown as string | number | undefined;
|
|
162
162
|
|
|
163
163
|
if (filteringStateValue != undefined) {
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
console.log(`query values:`, tableContext.dataRepo.__queryValues);
|
|
165
|
+
const x = tableContext.dataRepo.__queryValues.get(
|
|
166
|
+
customFilter?.id ?? customFilter?.label ??
|
|
167
|
+
customFilter?.objectName ??
|
|
168
|
+
customFilter?.queryKey ??
|
|
169
|
+
def.id ??
|
|
170
|
+
_uuid
|
|
166
171
|
);
|
|
167
172
|
|
|
168
173
|
if (def.debug) {
|
|
@@ -350,7 +355,10 @@
|
|
|
350
355
|
<div class="maxwidth">
|
|
351
356
|
{#await optionsPromise then options}
|
|
352
357
|
<MultiSelect
|
|
353
|
-
label={customFilter?.
|
|
358
|
+
label={customFilter?.id ?? customFilter?.label ??
|
|
359
|
+
customFilter?.objectName ??
|
|
360
|
+
customFilter?.queryKey ??
|
|
361
|
+
def.id}
|
|
354
362
|
labelProp="label"
|
|
355
363
|
valueProp="value"
|
|
356
364
|
name={customFilter?.objectName ?? 'Item'}
|
|
@@ -375,8 +383,8 @@
|
|
|
375
383
|
{#await options then options}
|
|
376
384
|
{#if hasQuery}
|
|
377
385
|
{#if typeof value == 'object'}
|
|
378
|
-
{@const label =
|
|
379
|
-
customFilter?.label ?? customFilter?.objectName ?? customFilter?.queryKey}
|
|
386
|
+
{@const label = customFilter?.id ??
|
|
387
|
+
customFilter?.label ?? customFilter?.objectName ?? customFilter?.queryKey ?? def.id}
|
|
380
388
|
<!-- TODO: multiselect -->
|
|
381
389
|
|
|
382
390
|
<QuerySelect
|
|
@@ -391,9 +399,9 @@
|
|
|
391
399
|
bind:options={lastQueryOptions}
|
|
392
400
|
onchange={(newValue) => {
|
|
393
401
|
tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
|
|
394
|
-
tableContext.__queryValues.set(label ?? _uuid, newValue);
|
|
402
|
+
tableContext.dataRepo.__queryValues.set(label ?? _uuid, newValue);
|
|
395
403
|
// FIXME <T> is lost when autoformatting. why?
|
|
396
|
-
value = newValue as SelectOption | null;
|
|
404
|
+
value = newValue as SelectOption<T> | null;
|
|
397
405
|
}}
|
|
398
406
|
/>
|
|
399
407
|
{:else}
|
|
@@ -401,7 +409,10 @@
|
|
|
401
409
|
{/if}
|
|
402
410
|
{:else}
|
|
403
411
|
<MultiSelect
|
|
404
|
-
label={customFilter?.
|
|
412
|
+
label={customFilter?.id ?? customFilter?.label ??
|
|
413
|
+
customFilter?.objectName ??
|
|
414
|
+
customFilter?.queryKey ??
|
|
415
|
+
def.id}
|
|
405
416
|
labelProp="label"
|
|
406
417
|
valueProp="value"
|
|
407
418
|
name={customFilter?.objectName ?? 'Item'}
|
|
@@ -18,7 +18,6 @@ export declare class SelectDef<T extends object> extends AccessorDef<T, SelectFi
|
|
|
18
18
|
get filterFn(): FilterFn<T, SelectFilterValueType<T>> | CustomFilterFn | undefined;
|
|
19
19
|
set filterFn(v: FilterFn<T, SelectFilterValueType<T>> | CustomFilterFn | undefined);
|
|
20
20
|
readonly sortingFn?: (a: T, b: T) => 1 | -1 | 0;
|
|
21
|
-
readonly getDisplayValue: (item: T, index: number) => string | null | Promise<string | null>;
|
|
22
21
|
readonly optional: boolean;
|
|
23
22
|
readonly clearable: boolean;
|
|
24
23
|
readonly getSpecificOptions?: (item: T, index: number) => Array<SelectOption<unknown>> | Promise<Array<SelectOption<unknown>>>;
|
|
@@ -37,7 +37,6 @@ export declare class TableContext<T extends object> {
|
|
|
37
37
|
protected constructor(INTERNAL_ONLY: symbol, defaultColumnDefs: DefsWrapper<T>, tableName: string, dataRepo: IDataRepository<T>, allowCopy: boolean, enableResize: boolean, allowColumnReordering: boolean, allowQuickFiltering: boolean, showQuickFilterByDefault: boolean, allowAdvancedFiltering: boolean, toolbarPosition: ToolbarPosition, displayFooter: boolean, selectionExtractor: TableInitOptions<T>['selectionExtractor'], getUserId: () => string | undefined, _onEditCell?: TableInitOptions<T>['onEditCell']);
|
|
38
38
|
private readonly userId;
|
|
39
39
|
private isSelectable;
|
|
40
|
-
__queryValues: SvelteMap<string, unknown>;
|
|
41
40
|
private _paginationRepo;
|
|
42
41
|
get paginationRepo(): IDataRepository<T> | undefined;
|
|
43
42
|
set paginationRepo(v: IDataRepository<T> | undefined);
|
|
@@ -45,7 +44,7 @@ export declare class TableContext<T extends object> {
|
|
|
45
44
|
get showQuickFiltering(): boolean;
|
|
46
45
|
set showQuickFiltering(v: boolean);
|
|
47
46
|
private _dataRepo;
|
|
48
|
-
get dataRepo(): IDataRepository<T
|
|
47
|
+
get dataRepo(): IDataRepository<T>;
|
|
49
48
|
private set dataRepo(value);
|
|
50
49
|
private _remoteFilters;
|
|
51
50
|
get remoteFilters(): CustomRemoteFilters | undefined;
|
|
@@ -64,7 +64,7 @@ export class TableContext {
|
|
|
64
64
|
if (INTERNAL_ONLY != InternalSymbol) {
|
|
65
65
|
throw new Error('This class may only be instantiated through the static init() method');
|
|
66
66
|
}
|
|
67
|
-
this.
|
|
67
|
+
this._dataRepo = $state(dataRepo);
|
|
68
68
|
// this.dataRepo.forceRefresh = this.forceVisibilityUpdate;
|
|
69
69
|
if (defaultColumnDefs.remoteFilters) {
|
|
70
70
|
this.remoteFilters = defaultColumnDefs.remoteFilters;
|
|
@@ -147,7 +147,6 @@ export class TableContext {
|
|
|
147
147
|
// #region stores
|
|
148
148
|
userId;
|
|
149
149
|
isSelectable = $state(false);
|
|
150
|
-
__queryValues = new SvelteMap();
|
|
151
150
|
_paginationRepo = $state();
|
|
152
151
|
get paginationRepo() {
|
|
153
152
|
return this._paginationRepo;
|
|
@@ -162,7 +161,7 @@ export class TableContext {
|
|
|
162
161
|
set showQuickFiltering(v) {
|
|
163
162
|
this._showQuickFiltering = this.allowQuickFiltering && v;
|
|
164
163
|
}
|
|
165
|
-
_dataRepo
|
|
164
|
+
_dataRepo;
|
|
166
165
|
get dataRepo() {
|
|
167
166
|
return this._dataRepo;
|
|
168
167
|
}
|
|
@@ -31,6 +31,7 @@ export interface IDataRepository<T extends object> {
|
|
|
31
31
|
pageStartIndex: number;
|
|
32
32
|
pageEndIndexExclusive: number;
|
|
33
33
|
previouslyViewedPage: number;
|
|
34
|
+
__queryValues: SvelteMap<string, unknown>;
|
|
34
35
|
readonly paginationType: PaginationType;
|
|
35
36
|
filterType: FilterType;
|
|
36
37
|
data: T[];
|
|
@@ -29,6 +29,7 @@ export declare abstract class TableDataRepository<T extends object> implements I
|
|
|
29
29
|
abstract pageStartIndex: number;
|
|
30
30
|
abstract pageEndIndexExclusive: number;
|
|
31
31
|
constructor(tableName: string, getUserId: () => string | undefined);
|
|
32
|
+
__queryValues: SvelteMap<string, unknown>;
|
|
32
33
|
private _paginationState;
|
|
33
34
|
get paginationState(): ReadonlyPaginationState;
|
|
34
35
|
set paginationState(v: ReadonlyPaginationState);
|
|
@@ -3,6 +3,7 @@ import type { CustomFilterType } from './CustomFilterType.js';
|
|
|
3
3
|
export interface CustomFilter {
|
|
4
4
|
queryKey: string;
|
|
5
5
|
type: CustomFilterType;
|
|
6
|
+
id: string;
|
|
6
7
|
valueAsObject?: boolean;
|
|
7
8
|
options?: Array<SelectOption<string | number>> | Promise<Array<SelectOption<string | number>>>;
|
|
8
9
|
multiSelect?: boolean;
|