@lavalogic/scoria 0.0.28 → 0.0.30
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/Base/Pagination.svelte +237 -0
- package/dist/Components/Base/Pagination.svelte.d.ts +33 -0
- package/dist/Components/Dial.svelte +2 -2
- package/dist/Components/Table/Body/QuickSearchCell.svelte +14 -4
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +25 -14
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +49 -0
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte.d.ts +28 -0
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +1 -1
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +5 -5
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +1 -1
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +16 -45
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +8 -2
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +3 -1
- package/dist/Components/Table/Body/Rows/TableRow.svelte +8 -8
- package/dist/Components/Table/Body/TableBody.svelte +1 -1
- package/dist/Components/Table/ColumnDefinitions/ExampleItemColumnDef.svelte.js +2 -1
- package/dist/Components/Table/Misc/FilterInput.svelte +6 -0
- package/dist/Components/Table/Types/Columns/ColumnPinningState.d.ts +2 -2
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/AccessorDef.svelte.d.ts +1 -1
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/TextInputDef.svelte.d.ts +1 -0
- package/dist/Components/Table/Types/Columns/Definitions/ColumnDef.svelte.d.ts +8 -3
- package/dist/Components/Table/Types/Columns/Definitions/ColumnDef.svelte.js +8 -0
- package/dist/Components/Table/Types/Context/Row.d.ts +2 -1
- package/dist/Components/Table/Types/Context/TableContext.svelte.d.ts +9 -11
- package/dist/Components/Table/Types/Context/TableContext.svelte.js +170 -155
- package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.js +6 -7
- package/dist/Components/Table/Types/Filtering/FilterValueType.d.ts +8 -0
- package/dist/Components/Table/Types/Filtering/FilterValueType.js +8 -0
- package/dist/Components/Table/Types/Filtering/NumberDateFilterMode.d.ts +0 -1
- package/dist/Components/Table/Types/Filtering/NumberDateFilterMode.js +1 -1
- package/dist/Components/Table/Types/Focus/TableFocusDetails.svelte.js +2 -2
- package/dist/Delay/Delay.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +22 -21
|
@@ -14,6 +14,8 @@ import { DateInputDef } from '../Columns/Definitions/Accessors/DateInputDef.svel
|
|
|
14
14
|
import { ProgressBarDef } from '../Columns/Definitions/Display/ProgressBarDef.svelte.js';
|
|
15
15
|
import { DisplayDef } from '../Columns/Definitions/Display/DisplayDef.svelte.js';
|
|
16
16
|
import { browser } from '$app/environment';
|
|
17
|
+
import { NumberDateFilterMode } from '../Filtering/NumberDateFilterMode.js';
|
|
18
|
+
import { FilterValueType } from '../Filtering/FilterValueType.js';
|
|
17
19
|
const SORTING_ICON_WIDTH = 24;
|
|
18
20
|
const InternalSymbol = Symbol();
|
|
19
21
|
export class TableContext {
|
|
@@ -88,12 +90,13 @@ export class TableContext {
|
|
|
88
90
|
this.columnPresets = [...this.columnPresets, defaultPreset];
|
|
89
91
|
};
|
|
90
92
|
this.setupDefaultColumnDefs()
|
|
91
|
-
.then(() => {
|
|
93
|
+
.then((defs) => {
|
|
94
|
+
this.isSelectable = defs.some((it) => it.id.startsWith('is-selectable-'));
|
|
92
95
|
if (this.allowColumnReordering) {
|
|
93
96
|
const savedPresets = localStorage.getItem(`${this.userId}-${tableName}-presets`);
|
|
94
97
|
if (savedPresets) {
|
|
95
98
|
const presets = JSON.parse(savedPresets);
|
|
96
|
-
if (presets[0] && areDefsEquivalent(
|
|
99
|
+
if (presets[0] && areDefsEquivalent(defs, presets[0].columnDefs)) {
|
|
97
100
|
return this.reassignDefsToPresets(presets).then(() => presets);
|
|
98
101
|
}
|
|
99
102
|
}
|
|
@@ -133,7 +136,7 @@ export class TableContext {
|
|
|
133
136
|
// #endregion
|
|
134
137
|
// #region stores
|
|
135
138
|
userId;
|
|
136
|
-
isSelectable = $
|
|
139
|
+
isSelectable = $state(false);
|
|
137
140
|
__queryValues = new SvelteMap();
|
|
138
141
|
_paginationRepo = $state();
|
|
139
142
|
get paginationRepo() {
|
|
@@ -170,26 +173,11 @@ export class TableContext {
|
|
|
170
173
|
set showSelectedOnly(v) {
|
|
171
174
|
this._showSelectedOnly = v;
|
|
172
175
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
get numberFilter() {
|
|
179
|
-
return this._numberFilter;
|
|
180
|
-
}
|
|
181
|
-
_selectFilter = $derived(this.paginationRepo?.selectFilter);
|
|
182
|
-
get selectFilter() {
|
|
183
|
-
return this._selectFilter;
|
|
184
|
-
}
|
|
185
|
-
_boolFilter = $derived(this.paginationRepo?.boolFilter);
|
|
186
|
-
get boolFilter() {
|
|
187
|
-
return this._boolFilter;
|
|
188
|
-
}
|
|
189
|
-
_stringFilter = $derived(this.paginationRepo?.stringFilter);
|
|
190
|
-
get stringFilter() {
|
|
191
|
-
return this._stringFilter;
|
|
192
|
-
}
|
|
176
|
+
dateFilter = $derived(this.paginationRepo?.dateFilter);
|
|
177
|
+
numberFilter = $derived(this.paginationRepo?.numberFilter);
|
|
178
|
+
selectFilter = $derived(this.paginationRepo?.selectFilter);
|
|
179
|
+
boolFilter = $derived(this.paginationRepo?.boolFilter);
|
|
180
|
+
stringFilter = $derived(this.paginationRepo?.stringFilter);
|
|
193
181
|
_limitFooter = $state(false);
|
|
194
182
|
get limitFooter() {
|
|
195
183
|
return this._limitFooter;
|
|
@@ -507,13 +495,62 @@ export class TableContext {
|
|
|
507
495
|
};
|
|
508
496
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
509
497
|
originalRowIndices = $derived(new Map((this.dataRepo?.data ?? []).map((item, index) => [item, index])));
|
|
498
|
+
filteredIndeces = $derived.by(() => {
|
|
499
|
+
if (this.paginationRepo?.paginationType == PaginationType.Local) {
|
|
500
|
+
const filterState = this.dataRepo?.filtering ?? [];
|
|
501
|
+
const data = this.dataRepo?.data ?? [];
|
|
502
|
+
if (!filterState.length) {
|
|
503
|
+
return data.map((_, index) => index) ?? [];
|
|
504
|
+
}
|
|
505
|
+
const filtered = data
|
|
506
|
+
.map((item, index) => {
|
|
507
|
+
const row = this.createRow(item, index, index);
|
|
508
|
+
const x = filterState.every((filter) => {
|
|
509
|
+
const def = this.columnDefsById.get(filter.id);
|
|
510
|
+
if (!def) {
|
|
511
|
+
console.warn(`Could not find column def for filter with id ${filter.id}`);
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
if (def.filterFn) {
|
|
515
|
+
const x = def.filterFn(row, filter.id, filter.value);
|
|
516
|
+
// debugger;
|
|
517
|
+
return x;
|
|
518
|
+
}
|
|
519
|
+
console.warn(`row ${row.id} did not have a filter function`);
|
|
520
|
+
return false;
|
|
521
|
+
});
|
|
522
|
+
// debugger;
|
|
523
|
+
if (x) {
|
|
524
|
+
return index;
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
})
|
|
530
|
+
.filter((it) => it != null);
|
|
531
|
+
return filtered;
|
|
532
|
+
}
|
|
533
|
+
return this.dataRepo?.data.map((_, index) => index) ?? [];
|
|
534
|
+
});
|
|
535
|
+
filteredData = $derived.by(() => {
|
|
536
|
+
if (this.paginationRepo?.paginationType == PaginationType.Local) {
|
|
537
|
+
const data = this.showSelectedOnly
|
|
538
|
+
? // FIXME this will show the selected items by order of insertion to the selectedItems map.
|
|
539
|
+
[...this.selectedItems.values()]
|
|
540
|
+
: (this.filteredIndeces.map((index) => {
|
|
541
|
+
return this.dataRepo.data[index];
|
|
542
|
+
}) ?? []);
|
|
543
|
+
return data;
|
|
544
|
+
}
|
|
545
|
+
return this.dataRepo?.data ?? [];
|
|
546
|
+
});
|
|
510
547
|
sortedData = $derived.by(() => {
|
|
511
548
|
if (this.paginationRepo?.paginationType == PaginationType.Local) {
|
|
512
549
|
const state = this.dataRepo?.sorting ?? [];
|
|
513
550
|
const sortedData = this.showSelectedOnly
|
|
514
551
|
? // FIXME this will show the selected items by order of insertion to the selectedItems map.
|
|
515
552
|
[...this.selectedItems.values()]
|
|
516
|
-
:
|
|
553
|
+
: this.filteredData.concat();
|
|
517
554
|
sortedData.sort((a, b) => {
|
|
518
555
|
const end = state.length;
|
|
519
556
|
for (let i = 0; i < end; i++) {
|
|
@@ -533,58 +570,12 @@ export class TableContext {
|
|
|
533
570
|
});
|
|
534
571
|
return sortedData;
|
|
535
572
|
}
|
|
536
|
-
return this.
|
|
573
|
+
return this.filteredData ?? [];
|
|
537
574
|
});
|
|
538
575
|
sortedRowModel = $derived.by(() => {
|
|
539
576
|
const rows = this.sortedData.map((item, index) => {
|
|
540
577
|
const unsortedIndex = this.originalRowIndices.get(item) ?? index;
|
|
541
|
-
|
|
542
|
-
getValue: (key) => this.columnDefsById.get(key).accessorFn?.(item, unsortedIndex) ?? item[key],
|
|
543
|
-
original: item,
|
|
544
|
-
index,
|
|
545
|
-
id: index.toString(),
|
|
546
|
-
getLeftVisibleCells: () => leftVisibleCells,
|
|
547
|
-
getRightVisibleCells: () => rightVisibleCells,
|
|
548
|
-
getCenterVisibleCells: () => centerVisibleCells
|
|
549
|
-
};
|
|
550
|
-
const makeRow = (def) => {
|
|
551
|
-
const isVisible = $derived(this.columnVisibility[def.id] != false);
|
|
552
|
-
const isSorted = $derived.by(() => {
|
|
553
|
-
const sortState = this.paginationRepo?.sorting.find((it) => it.id == def.id);
|
|
554
|
-
if (!sortState) {
|
|
555
|
-
return 'none';
|
|
556
|
-
}
|
|
557
|
-
if (sortState.desc) {
|
|
558
|
-
return 'desc';
|
|
559
|
-
}
|
|
560
|
-
return 'asc';
|
|
561
|
-
});
|
|
562
|
-
return {
|
|
563
|
-
column: {
|
|
564
|
-
columnDef: def,
|
|
565
|
-
getCanSort: () => def.enableSorting,
|
|
566
|
-
getIsResizing: () => def.isResizing,
|
|
567
|
-
getIsSorted: () => isSorted,
|
|
568
|
-
getIsVisible: () => isVisible,
|
|
569
|
-
getToggleSortingHandler: () => def.enableSorting ? this.getToggleSortingHandler(def) : undefined,
|
|
570
|
-
id: def.id
|
|
571
|
-
},
|
|
572
|
-
id: `${index}_${def.id}`,
|
|
573
|
-
row: row,
|
|
574
|
-
getValue: () => def.accessorFn?.(item, index) ?? item[def.id] // TODO
|
|
575
|
-
};
|
|
576
|
-
};
|
|
577
|
-
const makeCellFromId = (columnId) => {
|
|
578
|
-
const def = this.columnDefsById.get(columnId);
|
|
579
|
-
return makeRow(def);
|
|
580
|
-
};
|
|
581
|
-
const leftVisibleCells = $derived(this.columnPinning.left?.map(makeCellFromId) ?? []);
|
|
582
|
-
const rightVisibleCells = $derived(this.columnPinning.right?.map(makeCellFromId) ?? []);
|
|
583
|
-
const centerVisibleCells = $derived(this.columnDefs
|
|
584
|
-
.filter((it) => !(this.columnPinning.left?.includes(it.id) ||
|
|
585
|
-
this.columnPinning.right?.includes(it.id)))
|
|
586
|
-
.map(makeRow));
|
|
587
|
-
return row;
|
|
578
|
+
return this.createRow(item, index, unsortedIndex);
|
|
588
579
|
});
|
|
589
580
|
return {
|
|
590
581
|
rows,
|
|
@@ -598,10 +589,12 @@ export class TableContext {
|
|
|
598
589
|
paginationRowModel = $derived.by(() => {
|
|
599
590
|
const sortedData = this._currentPageData;
|
|
600
591
|
const rows = sortedData.map((item, index) => {
|
|
592
|
+
const unsortedIndex = this.originalRowIndices.get(item) ?? index;
|
|
601
593
|
const row = {
|
|
602
594
|
getValue: (key) => this.columnDefsById.get(key).accessorFn?.(item, index) ?? item[key],
|
|
603
595
|
original: item,
|
|
604
|
-
index,
|
|
596
|
+
visibleIndex: index,
|
|
597
|
+
originalIndex: unsortedIndex,
|
|
605
598
|
id: index.toString(),
|
|
606
599
|
getLeftVisibleCells: () => leftVisibleCells,
|
|
607
600
|
getRightVisibleCells: () => rightVisibleCells,
|
|
@@ -638,11 +631,10 @@ export class TableContext {
|
|
|
638
631
|
const def = this.columnDefsById.get(columnId);
|
|
639
632
|
return makeRow(def);
|
|
640
633
|
};
|
|
641
|
-
const leftVisibleCells = $derived(this.columnPinning.left?.map(makeCellFromId) ?? []);
|
|
642
|
-
const rightVisibleCells = $derived(this.columnPinning.right?.map(makeCellFromId) ?? []);
|
|
634
|
+
const leftVisibleCells = $derived([...(this.columnPinning.left?.keys() ?? [])].map(makeCellFromId) ?? []);
|
|
635
|
+
const rightVisibleCells = $derived([...(this.columnPinning.right?.keys() ?? [])].map(makeCellFromId) ?? []);
|
|
643
636
|
const centerVisibleCells = $derived(this.columnDefs
|
|
644
|
-
.filter((it) => !(this.columnPinning.left?.
|
|
645
|
-
this.columnPinning.right?.includes(it.id)))
|
|
637
|
+
.filter((it) => !(this.columnPinning.left?.has(it.id) || this.columnPinning.right?.has(it.id)))
|
|
646
638
|
.map(makeRow));
|
|
647
639
|
return row;
|
|
648
640
|
});
|
|
@@ -1570,6 +1562,55 @@ export class TableContext {
|
|
|
1570
1562
|
this.focusEnd = coords;
|
|
1571
1563
|
};
|
|
1572
1564
|
// #region private methods
|
|
1565
|
+
createRow(item, index, unsortedIndex) {
|
|
1566
|
+
const row = {
|
|
1567
|
+
getValue: (key) => this.columnDefsById.get(key).accessorFn?.(item, unsortedIndex) ?? item[key],
|
|
1568
|
+
original: item,
|
|
1569
|
+
visibleIndex: index,
|
|
1570
|
+
originalIndex: unsortedIndex,
|
|
1571
|
+
id: index.toString(),
|
|
1572
|
+
getLeftVisibleCells: () => leftVisibleCells,
|
|
1573
|
+
getRightVisibleCells: () => rightVisibleCells,
|
|
1574
|
+
getCenterVisibleCells: () => centerVisibleCells
|
|
1575
|
+
};
|
|
1576
|
+
const makeRow = (def) => {
|
|
1577
|
+
const isVisible = $derived(this.columnVisibility[def.id] != false);
|
|
1578
|
+
const isSorted = $derived.by(() => {
|
|
1579
|
+
const sortState = this.paginationRepo?.sorting.find((it) => it.id == def.id);
|
|
1580
|
+
if (!sortState) {
|
|
1581
|
+
return 'none';
|
|
1582
|
+
}
|
|
1583
|
+
if (sortState.desc) {
|
|
1584
|
+
return 'desc';
|
|
1585
|
+
}
|
|
1586
|
+
return 'asc';
|
|
1587
|
+
});
|
|
1588
|
+
return {
|
|
1589
|
+
column: {
|
|
1590
|
+
columnDef: def,
|
|
1591
|
+
getCanSort: () => def.enableSorting,
|
|
1592
|
+
getIsResizing: () => def.isResizing,
|
|
1593
|
+
getIsSorted: () => isSorted,
|
|
1594
|
+
getIsVisible: () => isVisible,
|
|
1595
|
+
getToggleSortingHandler: () => def.enableSorting ? this.getToggleSortingHandler(def) : undefined,
|
|
1596
|
+
id: def.id
|
|
1597
|
+
},
|
|
1598
|
+
id: `${index}_${def.id}`,
|
|
1599
|
+
row: row,
|
|
1600
|
+
getValue: () => def.accessorFn?.(item, index) ?? item[def.id] // TODO
|
|
1601
|
+
};
|
|
1602
|
+
};
|
|
1603
|
+
const makeCellFromId = (columnId) => {
|
|
1604
|
+
const def = this.columnDefsById.get(columnId);
|
|
1605
|
+
return makeRow(def);
|
|
1606
|
+
};
|
|
1607
|
+
const leftVisibleCells = $derived([...(this.columnPinning.left?.keys() ?? [])].map(makeCellFromId) ?? []);
|
|
1608
|
+
const rightVisibleCells = $derived([...(this.columnPinning.right?.keys() ?? [])].map(makeCellFromId) ?? []);
|
|
1609
|
+
const centerVisibleCells = $derived(this.columnDefs
|
|
1610
|
+
.filter((it) => !(this.columnPinning.left?.has(it.id) || this.columnPinning.right?.has(it.id)))
|
|
1611
|
+
.map(makeRow));
|
|
1612
|
+
return row;
|
|
1613
|
+
}
|
|
1573
1614
|
columnDefReturnsTextValue = (it) => {
|
|
1574
1615
|
if (!this.dataRepo) {
|
|
1575
1616
|
return false;
|
|
@@ -1607,10 +1648,10 @@ export class TableContext {
|
|
|
1607
1648
|
return;
|
|
1608
1649
|
}
|
|
1609
1650
|
const rows = this.paginationRowModel.rows;
|
|
1610
|
-
const endRowIndex = rows.findIndex((row) => row.
|
|
1651
|
+
const endRowIndex = rows.findIndex((row) => row.visibleIndex === this.focusEnd.row);
|
|
1611
1652
|
this.focusEnd = {
|
|
1612
1653
|
...this.focusEnd,
|
|
1613
|
-
row: rows[Math.max(Math.min(endRowIndex + offset, rows.length - 1), 0)].
|
|
1654
|
+
row: rows[Math.max(Math.min(endRowIndex + offset, rows.length - 1), 0)].visibleIndex
|
|
1614
1655
|
};
|
|
1615
1656
|
}
|
|
1616
1657
|
_moveFocusRow(offset) {
|
|
@@ -1620,8 +1661,8 @@ export class TableContext {
|
|
|
1620
1661
|
}
|
|
1621
1662
|
const newEndRowIndex = (() => {
|
|
1622
1663
|
const rows = this.paginationRowModel.rows;
|
|
1623
|
-
const endRowIndex = rows.findIndex((row) => row.
|
|
1624
|
-
return rows[Math.max(Math.min(endRowIndex + offset, rows.length - 1), 0)].
|
|
1664
|
+
const endRowIndex = rows.findIndex((row) => row.visibleIndex === this.focusStart.row);
|
|
1665
|
+
return rows[Math.max(Math.min(endRowIndex + offset, rows.length - 1), 0)].visibleIndex;
|
|
1625
1666
|
})();
|
|
1626
1667
|
this.moveFocus({ ...this.focusStart, row: newEndRowIndex });
|
|
1627
1668
|
}
|
|
@@ -1634,8 +1675,8 @@ export class TableContext {
|
|
|
1634
1675
|
const { row: startRowIndexId, column: startColumnIndex } = this.focusStart;
|
|
1635
1676
|
const { row: endRowIndexId, column: endColumnIndex } = this.focusEnd;
|
|
1636
1677
|
const model = this.sortedRowModel;
|
|
1637
|
-
const startRowIndex = model?.rows.findIndex((row) => row.
|
|
1638
|
-
const endRowIndex = model?.rows.findIndex((row) => row.
|
|
1678
|
+
const startRowIndex = model?.rows.findIndex((row) => row.visibleIndex === startRowIndexId) ?? -1;
|
|
1679
|
+
const endRowIndex = model?.rows.findIndex((row) => row.visibleIndex === endRowIndexId) ?? -1;
|
|
1639
1680
|
if (!model || startRowIndex == -1 || endRowIndex == -1) {
|
|
1640
1681
|
return;
|
|
1641
1682
|
}
|
|
@@ -1719,10 +1760,11 @@ export class TableContext {
|
|
|
1719
1760
|
if (this.focusStart && this.focusEnd) {
|
|
1720
1761
|
const { row: startRowIndexId, column: startColumnIndex } = this.focusStart;
|
|
1721
1762
|
const { row: endRowIndexId, column: endColumnIndex } = this.focusEnd;
|
|
1722
|
-
const model = this.
|
|
1723
|
-
const
|
|
1724
|
-
const
|
|
1725
|
-
|
|
1763
|
+
// const model = this._currentPageData;
|
|
1764
|
+
const model = this.paginationRowModel;
|
|
1765
|
+
const startRowIndex = model?.rows.findIndex((row) => row.visibleIndex === startRowIndexId) ?? -1;
|
|
1766
|
+
const endRowIndex = model?.rows.findIndex((row) => row.visibleIndex === endRowIndexId) ?? -1;
|
|
1767
|
+
if (!this._currentPageData?.length || startRowIndex == -1 || endRowIndex == -1) {
|
|
1726
1768
|
throw new Error(`copy was missing one of the two indices. First: ${startRowIndex}, second: ${endRowIndex}`);
|
|
1727
1769
|
}
|
|
1728
1770
|
const minRowIndex = Math.min(startRowIndex, endRowIndex);
|
|
@@ -1738,8 +1780,9 @@ export class TableContext {
|
|
|
1738
1780
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
1739
1781
|
const indices = new Map();
|
|
1740
1782
|
for (let i = minRowIndex; i <= maxRowIndex; i++) {
|
|
1741
|
-
const
|
|
1742
|
-
const item =
|
|
1783
|
+
const row = model.rows[i];
|
|
1784
|
+
const item = row.original;
|
|
1785
|
+
const itemIndex = row.originalIndex;
|
|
1743
1786
|
selectedRows.push(item);
|
|
1744
1787
|
indices.set(item, itemIndex);
|
|
1745
1788
|
}
|
|
@@ -1788,10 +1831,10 @@ export class TableContext {
|
|
|
1788
1831
|
const midDefs = [];
|
|
1789
1832
|
const rightDefs = [];
|
|
1790
1833
|
this.columnDefs.forEach((def) => {
|
|
1791
|
-
if (this.columnPinning.left?.
|
|
1834
|
+
if (this.columnPinning.left?.has(def.id)) {
|
|
1792
1835
|
leftDefs.push(def);
|
|
1793
1836
|
}
|
|
1794
|
-
else if (this.columnPinning.right?.
|
|
1837
|
+
else if (this.columnPinning.right?.has(def.id)) {
|
|
1795
1838
|
rightDefs.push(def);
|
|
1796
1839
|
}
|
|
1797
1840
|
else {
|
|
@@ -1820,10 +1863,6 @@ export class TableContext {
|
|
|
1820
1863
|
// const helper = createColumnHelper<T>();
|
|
1821
1864
|
this.assertNoDuplicateIds();
|
|
1822
1865
|
const adjustedDefsPromises = this.defaultColumnDefs.defs.map(async (def) => {
|
|
1823
|
-
// extra width for when filtering between values
|
|
1824
|
-
const needsExtraWidth = this.allowQuickFiltering && 'type' in def && def.type === 'Number';
|
|
1825
|
-
const hasNoText = !needsExtraWidth &&
|
|
1826
|
-
(def.columnType === ColumnType.Expand || def.columnType === ColumnType.RowSelect);
|
|
1827
1866
|
if (def instanceof AccessorDef) {
|
|
1828
1867
|
// if (hasNoDefaultAccessor(temporary)) {
|
|
1829
1868
|
// temporary.accessorKey = def.id as string & keyof T;
|
|
@@ -1855,6 +1894,31 @@ export class TableContext {
|
|
|
1855
1894
|
def.filterFn = this.dateFilter;
|
|
1856
1895
|
}
|
|
1857
1896
|
}
|
|
1897
|
+
else if (this.paginationRepo?.paginationType == PaginationType.Local && !def.filterFn) {
|
|
1898
|
+
switch (def.filterValueType) {
|
|
1899
|
+
case undefined:
|
|
1900
|
+
case 'String': {
|
|
1901
|
+
def.filterFn = this.stringFilter;
|
|
1902
|
+
break;
|
|
1903
|
+
}
|
|
1904
|
+
case 'Bool': {
|
|
1905
|
+
def.filterFn = this.boolFilter;
|
|
1906
|
+
break;
|
|
1907
|
+
}
|
|
1908
|
+
case 'Date': {
|
|
1909
|
+
def.filterFn = this.dateFilter;
|
|
1910
|
+
break;
|
|
1911
|
+
}
|
|
1912
|
+
case 'Number': {
|
|
1913
|
+
def.filterFn = this.numberFilter;
|
|
1914
|
+
break;
|
|
1915
|
+
}
|
|
1916
|
+
case 'Select': {
|
|
1917
|
+
def.filterFn = this.selectFilter;
|
|
1918
|
+
break;
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1858
1922
|
return def;
|
|
1859
1923
|
});
|
|
1860
1924
|
const adjustedDefs = (await Promise.all(adjustedDefsPromises))
|
|
@@ -1894,14 +1958,16 @@ export class TableContext {
|
|
|
1894
1958
|
}
|
|
1895
1959
|
_setNewPinningState() {
|
|
1896
1960
|
this.columnPinning = {
|
|
1897
|
-
|
|
1961
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
1962
|
+
left: new Map(this.columnPinning.left &&
|
|
1898
1963
|
this.columnDefs
|
|
1899
|
-
.filter((col) => this.columnPinning.left?.
|
|
1900
|
-
.map((col) => col.id),
|
|
1901
|
-
|
|
1964
|
+
.filter((col) => this.columnPinning.left?.has(col.id))
|
|
1965
|
+
.map((col, index) => [col.id, index])),
|
|
1966
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
1967
|
+
right: new Map(this.columnPinning.right &&
|
|
1902
1968
|
this.columnDefs
|
|
1903
|
-
.filter((col) => this.columnPinning.right?.
|
|
1904
|
-
.map((col) => col.id)
|
|
1969
|
+
.filter((col) => this.columnPinning.right?.has(col.id))
|
|
1970
|
+
.map((col, index) => [col.id, index]))
|
|
1905
1971
|
}; // TODO
|
|
1906
1972
|
}
|
|
1907
1973
|
getToggleSortingHandler = (def) => (e) => {
|
|
@@ -1989,59 +2055,11 @@ function encapsulate(value) {
|
|
|
1989
2055
|
return `"${value.replace(/[\n]/gm, ' ').replace(/["]/g, '""')}"`;
|
|
1990
2056
|
}
|
|
1991
2057
|
function generateTableOptions(contextObj) {
|
|
1992
|
-
const _pageCount = $derived(contextObj.paginationRepo?.lastPage ?? 1);
|
|
1993
|
-
const _prm = $derived.by(() => {
|
|
1994
|
-
return contextObj.dataRepo?.paginationType === PaginationType.Local
|
|
1995
|
-
? contextObj.paginationRowModel // TODO getPaginationRowModel()
|
|
1996
|
-
: undefined;
|
|
1997
|
-
});
|
|
1998
2058
|
const _pagination = $derived.by(() => {
|
|
1999
2059
|
void contextObj.paginationRepo?.paginationState?.pageSize;
|
|
2000
2060
|
void contextObj.paginationRepo?.paginationState?.pageIndex;
|
|
2001
2061
|
return contextObj.paginationRepo?.paginationState;
|
|
2002
2062
|
});
|
|
2003
|
-
// TODO
|
|
2004
|
-
function todo(fnName) {
|
|
2005
|
-
return () => {
|
|
2006
|
-
throw new Error('TODO ' + fnName);
|
|
2007
|
-
};
|
|
2008
|
-
}
|
|
2009
|
-
// const leftSizePx = $derived.by(() => {
|
|
2010
|
-
// if (contextObj.columnPinning.left?.length) {
|
|
2011
|
-
// return contextObj.columnDefs.reduce((total, current) => {
|
|
2012
|
-
// if (contextObj.columnPinning.left!.includes(current.id)) {
|
|
2013
|
-
// return total + contextObj.measureHeaderWidth(current);
|
|
2014
|
-
// }
|
|
2015
|
-
// return total;
|
|
2016
|
-
// }, 0);
|
|
2017
|
-
// }
|
|
2018
|
-
// return 0;
|
|
2019
|
-
// });
|
|
2020
|
-
// const rightSizePx = $derived.by(() => {
|
|
2021
|
-
// if (contextObj.columnPinning.right?.length) {
|
|
2022
|
-
// return contextObj.columnDefs.reduce((total, current) => {
|
|
2023
|
-
// if (contextObj.columnPinning.right!.includes(current.id)) {
|
|
2024
|
-
// return total + contextObj.measureHeaderWidth(current);
|
|
2025
|
-
// }
|
|
2026
|
-
// return total;
|
|
2027
|
-
// }, 0);
|
|
2028
|
-
// }
|
|
2029
|
-
// return 0;
|
|
2030
|
-
// });
|
|
2031
|
-
// const centerSizePx = $derived.by(() => {
|
|
2032
|
-
// if (contextObj.columnPinning.right?.length) {
|
|
2033
|
-
// return contextObj.columnDefs.reduce((total, current) => {
|
|
2034
|
-
// if (
|
|
2035
|
-
// contextObj.columnPinning.left?.includes(current.id) ||
|
|
2036
|
-
// contextObj.columnPinning.right?.includes(current.id)
|
|
2037
|
-
// ) {
|
|
2038
|
-
// return total;
|
|
2039
|
-
// }
|
|
2040
|
-
// return total + contextObj.measureHeaderWidth(current);
|
|
2041
|
-
// }, 0);
|
|
2042
|
-
// }
|
|
2043
|
-
// return 0;
|
|
2044
|
-
// });
|
|
2045
2063
|
const makeHeader = (def) => {
|
|
2046
2064
|
// const size = $derived(contextObj.measureHeaderWidth(def));
|
|
2047
2065
|
const isVisible = $derived(contextObj.columnVisibility[def.id] != false);
|
|
@@ -2095,8 +2113,7 @@ function generateTableOptions(contextObj) {
|
|
|
2095
2113
|
};
|
|
2096
2114
|
const leftHeaderGroups = $derived.by(() => {
|
|
2097
2115
|
const headers = contextObj.columnDefs
|
|
2098
|
-
.filter((it) => contextObj.columnVisibility[it.id] != false &&
|
|
2099
|
-
contextObj.columnPinning.left?.includes(it.id))
|
|
2116
|
+
.filter((it) => contextObj.columnVisibility[it.id] != false && contextObj.columnPinning.left?.has(it.id))
|
|
2100
2117
|
.map(makeHeader);
|
|
2101
2118
|
return [
|
|
2102
2119
|
{
|
|
@@ -2108,8 +2125,7 @@ function generateTableOptions(contextObj) {
|
|
|
2108
2125
|
});
|
|
2109
2126
|
const rightHeaderGroups = $derived.by(() => {
|
|
2110
2127
|
const headers = contextObj.columnDefs
|
|
2111
|
-
.filter((it) => contextObj.columnVisibility[it.id] != false &&
|
|
2112
|
-
contextObj.columnPinning.right?.includes(it.id))
|
|
2128
|
+
.filter((it) => contextObj.columnVisibility[it.id] != false && contextObj.columnPinning.right?.has(it.id))
|
|
2113
2129
|
.map(makeHeader);
|
|
2114
2130
|
return [
|
|
2115
2131
|
{
|
|
@@ -2122,8 +2138,7 @@ function generateTableOptions(contextObj) {
|
|
|
2122
2138
|
const centerHeaderGroups = $derived.by(() => {
|
|
2123
2139
|
const headers = contextObj.columnDefs
|
|
2124
2140
|
.filter((it) => contextObj.columnVisibility[it.id] != false &&
|
|
2125
|
-
!(contextObj.columnPinning.left?.
|
|
2126
|
-
contextObj.columnPinning.right?.includes(it.id)))
|
|
2141
|
+
!(contextObj.columnPinning.left?.has(it.id) || contextObj.columnPinning.right?.has(it.id)))
|
|
2127
2142
|
.map(makeHeader);
|
|
2128
2143
|
return [
|
|
2129
2144
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Delay } from '../../../../Delay/Delay.js';
|
|
1
2
|
import { FilterType } from '../Filtering/FilterType.js';
|
|
2
3
|
import { NumberDateFilterMode } from '../Filtering/NumberDateFilterMode.js';
|
|
3
4
|
import { StringFilterMode } from '../Filtering/StringFilterMode.js';
|
|
@@ -40,9 +41,6 @@ export class LocalTableDataRepository extends TableDataRepository {
|
|
|
40
41
|
get totalRows() {
|
|
41
42
|
return this._totalRows;
|
|
42
43
|
}
|
|
43
|
-
// public set totalRows(v : number) {
|
|
44
|
-
// this._totalRows = v;
|
|
45
|
-
// }
|
|
46
44
|
_filtering = $state([]);
|
|
47
45
|
get filtering() {
|
|
48
46
|
return this._filtering;
|
|
@@ -72,18 +70,19 @@ export class LocalTableDataRepository extends TableDataRepository {
|
|
|
72
70
|
value = value.trim();
|
|
73
71
|
}
|
|
74
72
|
const oldIndex = this.filtering.findIndex((it) => it.id === id);
|
|
75
|
-
|
|
73
|
+
const newFiltering = this.filtering.concat();
|
|
74
|
+
if (oldIndex === -1 || newFiltering[oldIndex].value != value) {
|
|
76
75
|
if (oldIndex > -1) {
|
|
77
|
-
|
|
76
|
+
newFiltering.splice(oldIndex, 1);
|
|
78
77
|
}
|
|
79
78
|
const hasNoValue = value == null ||
|
|
80
79
|
(typeof value === 'object' && Array.isArray(value) && value.length === 0) ||
|
|
81
80
|
(typeof value === 'string' && value.length === 0);
|
|
82
81
|
if (!hasNoValue) {
|
|
83
|
-
|
|
82
|
+
newFiltering.push({ id, value });
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
|
-
this.filtering =
|
|
85
|
+
this.filtering = newFiltering;
|
|
87
86
|
};
|
|
88
87
|
_pageStartIndex = $derived(this.paginationState.pageIndex * this.paginationState.pageSize);
|
|
89
88
|
get pageStartIndex() {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const FilterValueType: {
|
|
2
|
+
readonly String: "String";
|
|
3
|
+
readonly Number: "Number";
|
|
4
|
+
readonly Date: "Date";
|
|
5
|
+
readonly Bool: "Bool";
|
|
6
|
+
readonly Select: "Select";
|
|
7
|
+
};
|
|
8
|
+
export type FilterValueType = (typeof FilterValueType)[keyof typeof FilterValueType];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export var NumberDateFilterMode;
|
|
2
2
|
(function (NumberDateFilterMode) {
|
|
3
3
|
NumberDateFilterMode["Equals"] = "=";
|
|
4
|
-
|
|
4
|
+
// Only = '__only=',
|
|
5
5
|
NumberDateFilterMode["NotEquals"] = "__notequals=";
|
|
6
6
|
NumberDateFilterMode["LessThan"] = "__lt=";
|
|
7
7
|
NumberDateFilterMode["LessThanOrEqual"] = "__lte=";
|
|
@@ -23,7 +23,7 @@ export class TableFocusDetails {
|
|
|
23
23
|
this._tableContext = v;
|
|
24
24
|
}
|
|
25
25
|
_coordinates = $derived({
|
|
26
|
-
row: this.cell.row.
|
|
26
|
+
row: this.cell.row.visibleIndex,
|
|
27
27
|
column: this.cell.column.columnDef.index,
|
|
28
28
|
id: this.cell.column.columnDef.id
|
|
29
29
|
});
|
|
@@ -31,7 +31,7 @@ export class TableFocusDetails {
|
|
|
31
31
|
return this._coordinates;
|
|
32
32
|
}
|
|
33
33
|
_isMultiFocused = $derived(this.tableContext.focusedColumnIds.has(this.cell.column.columnDef.id) &&
|
|
34
|
-
this.tableContext.focusedRowIndexIds.has(this.cell.row.
|
|
34
|
+
this.tableContext.focusedRowIndexIds.has(this.cell.row.visibleIndex));
|
|
35
35
|
get isMultiFocused() {
|
|
36
36
|
return this._isMultiFocused;
|
|
37
37
|
}
|
package/dist/Delay/Delay.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -156,3 +156,4 @@ export { Validity } from './Types/Internal/Validity.js';
|
|
|
156
156
|
export { type ValidityWrapper } from './Types/Internal/ValidityWrapper.js';
|
|
157
157
|
export { Variant } from './Types/Internal/Variant.js';
|
|
158
158
|
export { Colour, ColourSet } from './scss/colours.js';
|
|
159
|
+
export { FilterValueType } from './Components/Table/Types/Filtering/FilterValueType.js';
|
package/dist/index.js
CHANGED
|
@@ -163,3 +163,4 @@ export { Validity } from './Types/Internal/Validity.js';
|
|
|
163
163
|
export {} from './Types/Internal/ValidityWrapper.js';
|
|
164
164
|
export { Variant } from './Types/Internal/Variant.js';
|
|
165
165
|
export { Colour, ColourSet } from './scss/colours.js';
|
|
166
|
+
export { FilterValueType } from './Components/Table/Types/Filtering/FilterValueType.js';
|