@tanstack/table-core 9.0.0-beta.10 → 9.0.0-beta.11
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/core/cells/coreCellsFeature.types.d.cts +3 -3
- package/dist/core/cells/coreCellsFeature.types.d.ts +3 -3
- package/dist/core/columns/coreColumnsFeature.types.d.cts +4 -4
- package/dist/core/columns/coreColumnsFeature.types.d.ts +4 -4
- package/dist/core/headers/coreHeadersFeature.types.d.cts +5 -5
- package/dist/core/headers/coreHeadersFeature.types.d.ts +5 -5
- package/dist/core/row-models/coreRowModelsFeature.types.d.cts +3 -3
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +3 -3
- package/dist/core/row-models/createCoreRowModel.cjs +1 -2
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +2 -2
- package/dist/core/row-models/createCoreRowModel.d.ts +2 -2
- package/dist/core/row-models/createCoreRowModel.js +1 -2
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
- package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +4 -4
- package/dist/core/table/coreTablesFeature.types.d.ts +4 -4
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +4 -4
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +4 -4
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +9 -9
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +9 -9
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +6 -6
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +6 -6
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +2 -2
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +2 -2
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +2 -2
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +2 -2
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +4 -4
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +4 -4
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +3 -3
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +3 -3
- package/dist/features/row-pinning/rowPinningFeature.types.d.cts +2 -2
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +2 -2
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +2 -2
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +2 -2
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +7 -7
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +7 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/types/Cell.d.cts +1 -1
- package/dist/types/Cell.d.ts +1 -1
- package/dist/types/Column.d.cts +2 -2
- package/dist/types/Column.d.ts +2 -2
- package/dist/types/ColumnDef.d.cts +3 -3
- package/dist/types/ColumnDef.d.ts +3 -3
- package/dist/types/Header.d.cts +1 -1
- package/dist/types/Header.d.ts +1 -1
- package/dist/types/HeaderGroup.d.cts +1 -1
- package/dist/types/HeaderGroup.d.ts +1 -1
- package/dist/types/Row.d.cts +2 -2
- package/dist/types/Row.d.ts +2 -2
- package/dist/types/RowModel.d.cts +1 -1
- package/dist/types/RowModel.d.ts +1 -1
- package/dist/types/RowModelFns.d.cts +1 -1
- package/dist/types/RowModelFns.d.ts +1 -1
- package/dist/types/Table.d.cts +29 -11
- package/dist/types/Table.d.ts +29 -11
- package/dist/types/TableOptions.d.cts +11 -5
- package/dist/types/TableOptions.d.ts +11 -5
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +7 -2
- package/dist/utils.d.ts +7 -2
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/core/cells/coreCellsFeature.types.ts +6 -6
- package/src/core/columns/coreColumnsFeature.types.ts +8 -8
- package/src/core/headers/coreHeadersFeature.types.ts +10 -10
- package/src/core/row-models/coreRowModelsFeature.types.ts +6 -6
- package/src/core/row-models/createCoreRowModel.ts +5 -4
- package/src/core/rows/coreRowsFeature.types.ts +8 -8
- package/src/core/table/constructTable.ts +1 -1
- package/src/core/table/coreTablesFeature.types.ts +8 -8
- package/src/core/table/coreTablesFeature.utils.ts +8 -2
- package/src/features/column-faceting/columnFacetingFeature.types.ts +8 -8
- package/src/features/column-filtering/columnFilteringFeature.types.ts +18 -18
- package/src/features/column-grouping/columnGroupingFeature.types.ts +12 -12
- package/src/features/column-ordering/columnOrderingFeature.types.ts +2 -2
- package/src/features/column-pinning/columnPinningFeature.types.ts +4 -4
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +4 -4
- package/src/features/global-filtering/globalFilteringFeature.types.ts +4 -4
- package/src/features/row-expanding/rowExpandingFeature.types.ts +8 -8
- package/src/features/row-pagination/rowPaginationFeature.types.ts +6 -6
- package/src/features/row-pinning/rowPinningFeature.types.ts +4 -4
- package/src/features/row-selection/rowSelectionFeature.types.ts +4 -4
- package/src/features/row-sorting/rowSortingFeature.types.ts +14 -14
- package/src/types/Cell.ts +2 -2
- package/src/types/Column.ts +4 -4
- package/src/types/ColumnDef.ts +6 -6
- package/src/types/Header.ts +2 -2
- package/src/types/HeaderGroup.ts +2 -2
- package/src/types/Row.ts +4 -4
- package/src/types/RowModel.ts +2 -2
- package/src/types/RowModelFns.ts +2 -2
- package/src/types/Table.ts +64 -17
- package/src/types/TableOptions.ts +54 -12
- package/src/utils.ts +11 -2
|
@@ -6,7 +6,7 @@ import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
|
6
6
|
import { Cell } from "../../types/Cell.cjs";
|
|
7
7
|
|
|
8
8
|
//#region src/core/cells/coreCellsFeature.types.d.ts
|
|
9
|
-
interface CellContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
9
|
+
interface CellContext<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
10
10
|
cell: Cell<TFeatures, TData, TValue>;
|
|
11
11
|
column: Column<TFeatures, TData, TValue>;
|
|
12
12
|
getValue: Getter<TValue>;
|
|
@@ -14,7 +14,7 @@ interface CellContext<TFeatures extends TableFeatures, TData extends RowData, TV
|
|
|
14
14
|
row: Row<TFeatures, TData>;
|
|
15
15
|
table: Table<TFeatures, TData>;
|
|
16
16
|
}
|
|
17
|
-
interface Cell_CoreProperties<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
17
|
+
interface Cell_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
18
18
|
/**
|
|
19
19
|
* The associated Column object for the cell.
|
|
20
20
|
*/
|
|
@@ -32,7 +32,7 @@ interface Cell_CoreProperties<TFeatures extends TableFeatures, TData extends Row
|
|
|
32
32
|
*/
|
|
33
33
|
table: Table_Internal<TFeatures, TData>;
|
|
34
34
|
}
|
|
35
|
-
interface Cell_Cell<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> extends Cell_CoreProperties<TFeatures, TData, TValue> {
|
|
35
|
+
interface Cell_Cell<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> extends Cell_CoreProperties<TFeatures, TData, TValue> {
|
|
36
36
|
/**
|
|
37
37
|
* Returns the rendering context (or props) for cell-based components like cells and aggregated cells. Use these props with your framework's `flexRender` utility to render these using the template of your choice:
|
|
38
38
|
*/
|
|
@@ -6,7 +6,7 @@ import { TableFeatures } from "../../types/TableFeatures.js";
|
|
|
6
6
|
import { Cell } from "../../types/Cell.js";
|
|
7
7
|
|
|
8
8
|
//#region src/core/cells/coreCellsFeature.types.d.ts
|
|
9
|
-
interface CellContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
9
|
+
interface CellContext<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
10
10
|
cell: Cell<TFeatures, TData, TValue>;
|
|
11
11
|
column: Column<TFeatures, TData, TValue>;
|
|
12
12
|
getValue: Getter<TValue>;
|
|
@@ -14,7 +14,7 @@ interface CellContext<TFeatures extends TableFeatures, TData extends RowData, TV
|
|
|
14
14
|
row: Row<TFeatures, TData>;
|
|
15
15
|
table: Table<TFeatures, TData>;
|
|
16
16
|
}
|
|
17
|
-
interface Cell_CoreProperties<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
17
|
+
interface Cell_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
18
18
|
/**
|
|
19
19
|
* The associated Column object for the cell.
|
|
20
20
|
*/
|
|
@@ -32,7 +32,7 @@ interface Cell_CoreProperties<TFeatures extends TableFeatures, TData extends Row
|
|
|
32
32
|
*/
|
|
33
33
|
table: Table_Internal<TFeatures, TData>;
|
|
34
34
|
}
|
|
35
|
-
interface Cell_Cell<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> extends Cell_CoreProperties<TFeatures, TData, TValue> {
|
|
35
|
+
interface Cell_Cell<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> extends Cell_CoreProperties<TFeatures, TData, TValue> {
|
|
36
36
|
/**
|
|
37
37
|
* Returns the rendering context (or props) for cell-based components like cells and aggregated cells. Use these props with your framework's `flexRender` utility to render these using the template of your choice:
|
|
38
38
|
*/
|
|
@@ -5,7 +5,7 @@ import { AccessorFn, ColumnDef } from "../../types/ColumnDef.cjs";
|
|
|
5
5
|
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
6
6
|
|
|
7
7
|
//#region src/core/columns/coreColumnsFeature.types.d.ts
|
|
8
|
-
interface Column_CoreProperties<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
8
|
+
interface Column_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
9
9
|
/**
|
|
10
10
|
* The resolved accessor function to use when extracting the value for the column from each row. Will only be defined if the column def has a valid accessor key or function defined.
|
|
11
11
|
*/
|
|
@@ -38,7 +38,7 @@ interface Column_CoreProperties<TFeatures extends TableFeatures, TData extends R
|
|
|
38
38
|
*/
|
|
39
39
|
table: Table_Internal<TFeatures, TData>;
|
|
40
40
|
}
|
|
41
|
-
interface Column_Column<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> extends Column_CoreProperties<TFeatures, TData, TValue> {
|
|
41
|
+
interface Column_Column<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> extends Column_CoreProperties<TFeatures, TData, TValue> {
|
|
42
42
|
/**
|
|
43
43
|
* Flattens this column and every descendant column into a single array.
|
|
44
44
|
*/
|
|
@@ -49,7 +49,7 @@ interface Column_Column<TFeatures extends TableFeatures, TData extends RowData,
|
|
|
49
49
|
*/
|
|
50
50
|
getLeafColumns: () => Array<Column<TFeatures, TData, TValue>>;
|
|
51
51
|
}
|
|
52
|
-
interface TableOptions_Columns<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
52
|
+
interface TableOptions_Columns<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
53
53
|
/**
|
|
54
54
|
* The array of column defs to use for the table.
|
|
55
55
|
*/
|
|
@@ -59,7 +59,7 @@ interface TableOptions_Columns<TFeatures extends TableFeatures, TData extends Ro
|
|
|
59
59
|
*/
|
|
60
60
|
defaultColumn?: Partial<ColumnDef<TFeatures, TData, TValue>>;
|
|
61
61
|
}
|
|
62
|
-
interface Table_Columns<TFeatures extends TableFeatures, TData extends RowData> {
|
|
62
|
+
interface Table_Columns<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
63
63
|
/**
|
|
64
64
|
* Returns a map of all flat columns by their ID.
|
|
65
65
|
*/
|
|
@@ -5,7 +5,7 @@ import { AccessorFn, ColumnDef } from "../../types/ColumnDef.js";
|
|
|
5
5
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
6
6
|
|
|
7
7
|
//#region src/core/columns/coreColumnsFeature.types.d.ts
|
|
8
|
-
interface Column_CoreProperties<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
8
|
+
interface Column_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
9
9
|
/**
|
|
10
10
|
* The resolved accessor function to use when extracting the value for the column from each row. Will only be defined if the column def has a valid accessor key or function defined.
|
|
11
11
|
*/
|
|
@@ -38,7 +38,7 @@ interface Column_CoreProperties<TFeatures extends TableFeatures, TData extends R
|
|
|
38
38
|
*/
|
|
39
39
|
table: Table_Internal<TFeatures, TData>;
|
|
40
40
|
}
|
|
41
|
-
interface Column_Column<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> extends Column_CoreProperties<TFeatures, TData, TValue> {
|
|
41
|
+
interface Column_Column<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> extends Column_CoreProperties<TFeatures, TData, TValue> {
|
|
42
42
|
/**
|
|
43
43
|
* Flattens this column and every descendant column into a single array.
|
|
44
44
|
*/
|
|
@@ -49,7 +49,7 @@ interface Column_Column<TFeatures extends TableFeatures, TData extends RowData,
|
|
|
49
49
|
*/
|
|
50
50
|
getLeafColumns: () => Array<Column<TFeatures, TData, TValue>>;
|
|
51
51
|
}
|
|
52
|
-
interface TableOptions_Columns<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
52
|
+
interface TableOptions_Columns<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
53
53
|
/**
|
|
54
54
|
* The array of column defs to use for the table.
|
|
55
55
|
*/
|
|
@@ -59,7 +59,7 @@ interface TableOptions_Columns<TFeatures extends TableFeatures, TData extends Ro
|
|
|
59
59
|
*/
|
|
60
60
|
defaultColumn?: Partial<ColumnDef<TFeatures, TData, TValue>>;
|
|
61
61
|
}
|
|
62
|
-
interface Table_Columns<TFeatures extends TableFeatures, TData extends RowData> {
|
|
62
|
+
interface Table_Columns<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
63
63
|
/**
|
|
64
64
|
* Returns a map of all flat columns by their ID.
|
|
65
65
|
*/
|
|
@@ -6,7 +6,7 @@ import { Table } from "../../types/Table.cjs";
|
|
|
6
6
|
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
7
7
|
|
|
8
8
|
//#region src/core/headers/coreHeadersFeature.types.d.ts
|
|
9
|
-
interface Table_Headers<TFeatures extends TableFeatures, TData extends RowData> {
|
|
9
|
+
interface Table_Headers<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
10
10
|
/**
|
|
11
11
|
* Builds the visible header groups for the current column tree, visibility,
|
|
12
12
|
* and pinning state.
|
|
@@ -26,7 +26,7 @@ interface Table_Headers<TFeatures extends TableFeatures, TData extends RowData>
|
|
|
26
26
|
*/
|
|
27
27
|
getLeafHeaders: () => Array<Header<TFeatures, TData, unknown>>;
|
|
28
28
|
}
|
|
29
|
-
interface HeaderContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
29
|
+
interface HeaderContext<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
30
30
|
/**
|
|
31
31
|
* An instance of a column.
|
|
32
32
|
*/
|
|
@@ -40,7 +40,7 @@ interface HeaderContext<TFeatures extends TableFeatures, TData extends RowData,
|
|
|
40
40
|
*/
|
|
41
41
|
table: Table<TFeatures, TData>;
|
|
42
42
|
}
|
|
43
|
-
interface Header_CoreProperties<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
43
|
+
interface Header_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
44
44
|
/**
|
|
45
45
|
* The col-span for the header.
|
|
46
46
|
*/
|
|
@@ -86,7 +86,7 @@ interface Header_CoreProperties<TFeatures extends TableFeatures, TData extends R
|
|
|
86
86
|
*/
|
|
87
87
|
table: Table<TFeatures, TData>;
|
|
88
88
|
}
|
|
89
|
-
interface Header_Header<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> extends Header_CoreProperties<TFeatures, TData, TValue> {
|
|
89
|
+
interface Header_Header<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> extends Header_CoreProperties<TFeatures, TData, TValue> {
|
|
90
90
|
/**
|
|
91
91
|
* Returns the rendering context (or props) for column-based components like headers, footers and filters.
|
|
92
92
|
*/
|
|
@@ -96,7 +96,7 @@ interface Header_Header<TFeatures extends TableFeatures, TData extends RowData,
|
|
|
96
96
|
*/
|
|
97
97
|
getLeafHeaders: () => Array<Header<TFeatures, TData, TValue>>;
|
|
98
98
|
}
|
|
99
|
-
interface HeaderGroup_Header<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
99
|
+
interface HeaderGroup_Header<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
100
100
|
depth: number;
|
|
101
101
|
headers: Array<Header<TFeatures, TData, TValue>>;
|
|
102
102
|
id: string;
|
|
@@ -6,7 +6,7 @@ import { Table } from "../../types/Table.js";
|
|
|
6
6
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
7
7
|
|
|
8
8
|
//#region src/core/headers/coreHeadersFeature.types.d.ts
|
|
9
|
-
interface Table_Headers<TFeatures extends TableFeatures, TData extends RowData> {
|
|
9
|
+
interface Table_Headers<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
10
10
|
/**
|
|
11
11
|
* Builds the visible header groups for the current column tree, visibility,
|
|
12
12
|
* and pinning state.
|
|
@@ -26,7 +26,7 @@ interface Table_Headers<TFeatures extends TableFeatures, TData extends RowData>
|
|
|
26
26
|
*/
|
|
27
27
|
getLeafHeaders: () => Array<Header<TFeatures, TData, unknown>>;
|
|
28
28
|
}
|
|
29
|
-
interface HeaderContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
29
|
+
interface HeaderContext<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
30
30
|
/**
|
|
31
31
|
* An instance of a column.
|
|
32
32
|
*/
|
|
@@ -40,7 +40,7 @@ interface HeaderContext<TFeatures extends TableFeatures, TData extends RowData,
|
|
|
40
40
|
*/
|
|
41
41
|
table: Table<TFeatures, TData>;
|
|
42
42
|
}
|
|
43
|
-
interface Header_CoreProperties<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
43
|
+
interface Header_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
44
44
|
/**
|
|
45
45
|
* The col-span for the header.
|
|
46
46
|
*/
|
|
@@ -86,7 +86,7 @@ interface Header_CoreProperties<TFeatures extends TableFeatures, TData extends R
|
|
|
86
86
|
*/
|
|
87
87
|
table: Table<TFeatures, TData>;
|
|
88
88
|
}
|
|
89
|
-
interface Header_Header<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> extends Header_CoreProperties<TFeatures, TData, TValue> {
|
|
89
|
+
interface Header_Header<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> extends Header_CoreProperties<TFeatures, TData, TValue> {
|
|
90
90
|
/**
|
|
91
91
|
* Returns the rendering context (or props) for column-based components like headers, footers and filters.
|
|
92
92
|
*/
|
|
@@ -96,7 +96,7 @@ interface Header_Header<TFeatures extends TableFeatures, TData extends RowData,
|
|
|
96
96
|
*/
|
|
97
97
|
getLeafHeaders: () => Array<Header<TFeatures, TData, TValue>>;
|
|
98
98
|
}
|
|
99
|
-
interface HeaderGroup_Header<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
99
|
+
interface HeaderGroup_Header<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
|
|
100
100
|
depth: number;
|
|
101
101
|
headers: Array<Header<TFeatures, TData, TValue>>;
|
|
102
102
|
id: string;
|
|
@@ -9,15 +9,15 @@ import { Table_RowModels_Faceted } from "../../features/column-faceting/columnFa
|
|
|
9
9
|
import { Table_RowModels_Grouped } from "../../features/column-grouping/columnGroupingFeature.types.cjs";
|
|
10
10
|
|
|
11
11
|
//#region src/core/row-models/coreRowModelsFeature.types.d.ts
|
|
12
|
-
interface RowModel<TFeatures extends TableFeatures, TData extends RowData> {
|
|
12
|
+
interface RowModel<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
13
13
|
rows: Array<Row<TFeatures, TData>>;
|
|
14
14
|
flatRows: Array<Row<TFeatures, TData>>;
|
|
15
15
|
rowsById: Record<string, Row<TFeatures, TData>>;
|
|
16
16
|
}
|
|
17
|
-
interface CachedRowModel_Core<TFeatures extends TableFeatures, TData extends RowData> {
|
|
17
|
+
interface CachedRowModel_Core<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
18
18
|
coreRowModel: () => RowModel<TFeatures, TData>;
|
|
19
19
|
}
|
|
20
|
-
interface Table_RowModels_Core<TFeatures extends TableFeatures, TData extends RowData> {
|
|
20
|
+
interface Table_RowModels_Core<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
21
21
|
/**
|
|
22
22
|
* Returns the core row model before any processing has been applied.
|
|
23
23
|
*/
|
|
@@ -9,15 +9,15 @@ import { Table_RowModels_Faceted } from "../../features/column-faceting/columnFa
|
|
|
9
9
|
import { Table_RowModels_Grouped } from "../../features/column-grouping/columnGroupingFeature.types.js";
|
|
10
10
|
|
|
11
11
|
//#region src/core/row-models/coreRowModelsFeature.types.d.ts
|
|
12
|
-
interface RowModel<TFeatures extends TableFeatures, TData extends RowData> {
|
|
12
|
+
interface RowModel<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
13
13
|
rows: Array<Row<TFeatures, TData>>;
|
|
14
14
|
flatRows: Array<Row<TFeatures, TData>>;
|
|
15
15
|
rowsById: Record<string, Row<TFeatures, TData>>;
|
|
16
16
|
}
|
|
17
|
-
interface CachedRowModel_Core<TFeatures extends TableFeatures, TData extends RowData> {
|
|
17
|
+
interface CachedRowModel_Core<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
18
18
|
coreRowModel: () => RowModel<TFeatures, TData>;
|
|
19
19
|
}
|
|
20
|
-
interface Table_RowModels_Core<TFeatures extends TableFeatures, TData extends RowData> {
|
|
20
|
+
interface Table_RowModels_Core<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
21
21
|
/**
|
|
22
22
|
* Returns the core row model before any processing has been applied.
|
|
23
23
|
*/
|
|
@@ -9,8 +9,7 @@ const require_rowPaginationFeature_utils = require('../../features/row-paginatio
|
|
|
9
9
|
* The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
|
|
10
10
|
*/
|
|
11
11
|
function createCoreRowModel() {
|
|
12
|
-
return (
|
|
13
|
-
const table = _table;
|
|
12
|
+
return (table) => {
|
|
14
13
|
return require_utils.tableMemo({
|
|
15
14
|
feature: "coreRowModelsFeature",
|
|
16
15
|
table,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCoreRowModel.cjs","names":["tableMemo","table_autoResetPageIndex","constructRow"],"sources":["../../../src/core/row-models/createCoreRowModel.ts"],"sourcesContent":["import { constructRow } from '../rows/constructRow'\nimport { tableMemo } from '../../utils'\nimport { table_autoResetPageIndex } from '../../features/row-pagination/rowPaginationFeature.utils'\nimport type {
|
|
1
|
+
{"version":3,"file":"createCoreRowModel.cjs","names":["tableMemo","table_autoResetPageIndex","constructRow"],"sources":["../../../src/core/row-models/createCoreRowModel.ts"],"sourcesContent":["import { constructRow } from '../rows/constructRow'\nimport { tableMemo } from '../../utils'\nimport { table_autoResetPageIndex } from '../../features/row-pagination/rowPaginationFeature.utils'\nimport type { Table_Internal } from '../../types/Table'\nimport type { RowModel } from './coreRowModelsFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized core row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createCoreRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): (\n table: Table_Internal<TFeatures, TData>,\n) => () => RowModel<TFeatures, TData> {\n return (table) => {\n return tableMemo({\n feature: 'coreRowModelsFeature',\n table,\n fnName: 'table.getCoreRowModel',\n memoDeps: () => [table.options.data],\n fn: () => _createCoreRowModel(table, table.options.data),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createCoreRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n data: ReadonlyArray<TData>,\n): {\n rows: Array<Row<TFeatures, TData>>\n flatRows: Array<Row<TFeatures, TData>>\n rowsById: Record<string, Row<TFeatures, TData>>\n} {\n const rowModel: RowModel<TFeatures, TData> = {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n\n const accessRows = (\n originalRows: ReadonlyArray<TData>,\n depth = 0,\n parentRow?: Row<TFeatures, TData>,\n ): Array<Row<TFeatures, TData>> => {\n const rows = [] as Array<Row<TFeatures, TData>>\n\n for (let i = 0; i < originalRows.length; i++) {\n const originalRow = originalRows[i]!\n // Make the row\n const row = constructRow(\n table,\n table.getRowId(originalRow, i, parentRow),\n originalRow,\n i,\n depth,\n undefined,\n parentRow?.id,\n )\n\n // Keep track of every row in a flat array\n rowModel.flatRows.push(row)\n // Also keep track of every row by its ID\n rowModel.rowsById[row.id] = row\n // Push table row into parent\n rows.push(row)\n\n // Get the original subrows\n if (table.options.getSubRows) {\n row.originalSubRows = table.options.getSubRows(originalRow, i)\n\n // Then recursively access them\n if (row.originalSubRows?.length) {\n row.subRows = accessRows(row.originalSubRows, depth + 1, row)\n }\n }\n }\n\n return rows\n }\n\n rowModel.rows = accessRows(data)\n\n return rowModel\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,qBAKsB;CACpC,QAAQ,UAAU;EAChB,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB,CAAC,MAAM,QAAQ,IAAI;GACnC,UAAU,oBAAoB,OAAO,MAAM,QAAQ,IAAI;GACvD,qBAAqBC,4DAAyB,KAAK;EACrD,CAAC;CACH;AACF;AAEA,SAAS,oBAIP,OACA,MAKA;CACA,MAAM,WAAuC;EAC3C,MAAM,CAAC;EACP,UAAU,CAAC;EACX,UAAU,CAAC;CACb;CAEA,MAAM,cACJ,cACA,QAAQ,GACR,cACiC;EACjC,MAAM,OAAO,CAAC;EAEd,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;GAC5C,MAAM,cAAc,aAAa;GAEjC,MAAM,MAAMC,kCACV,OACA,MAAM,SAAS,aAAa,GAAG,SAAS,GACxC,aACA,GACA,OACA,8DACA,UAAW,EACb;GAGA,SAAS,SAAS,KAAK,GAAG;GAE1B,SAAS,SAAS,IAAI,MAAM;GAE5B,KAAK,KAAK,GAAG;GAGb,IAAI,MAAM,QAAQ,YAAY;;IAC5B,IAAI,kBAAkB,MAAM,QAAQ,WAAW,aAAa,CAAC;IAG7D,4BAAI,IAAI,6FAAiB,QACvB,IAAI,UAAU,WAAW,IAAI,iBAAiB,QAAQ,GAAG,GAAG;GAEhE;EACF;EAEA,OAAO;CACT;CAEA,SAAS,OAAO,WAAW,IAAI;CAE/B,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Table_Internal } from "../../types/Table.cjs";
|
|
3
3
|
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
4
4
|
import { RowModel } from "./coreRowModelsFeature.types.cjs";
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ import { RowModel } from "./coreRowModelsFeature.types.cjs";
|
|
|
9
9
|
*
|
|
10
10
|
* The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
|
|
11
11
|
*/
|
|
12
|
-
declare function createCoreRowModel<TFeatures extends TableFeatures, TData extends RowData>(): (table:
|
|
12
|
+
declare function createCoreRowModel<TFeatures extends TableFeatures, TData extends RowData>(): (table: Table_Internal<TFeatures, TData>) => () => RowModel<TFeatures, TData>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { createCoreRowModel };
|
|
15
15
|
//# sourceMappingURL=createCoreRowModel.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Table_Internal } from "../../types/Table.js";
|
|
3
3
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
4
4
|
import { RowModel } from "./coreRowModelsFeature.types.js";
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ import { RowModel } from "./coreRowModelsFeature.types.js";
|
|
|
9
9
|
*
|
|
10
10
|
* The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
|
|
11
11
|
*/
|
|
12
|
-
declare function createCoreRowModel<TFeatures extends TableFeatures, TData extends RowData>(): (table:
|
|
12
|
+
declare function createCoreRowModel<TFeatures extends TableFeatures, TData extends RowData>(): (table: Table_Internal<TFeatures, TData>) => () => RowModel<TFeatures, TData>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { createCoreRowModel };
|
|
15
15
|
//# sourceMappingURL=createCoreRowModel.d.ts.map
|
|
@@ -9,8 +9,7 @@ import { table_autoResetPageIndex } from "../../features/row-pagination/rowPagin
|
|
|
9
9
|
* The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
|
|
10
10
|
*/
|
|
11
11
|
function createCoreRowModel() {
|
|
12
|
-
return (
|
|
13
|
-
const table = _table;
|
|
12
|
+
return (table) => {
|
|
14
13
|
return tableMemo({
|
|
15
14
|
feature: "coreRowModelsFeature",
|
|
16
15
|
table,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCoreRowModel.js","names":[],"sources":["../../../src/core/row-models/createCoreRowModel.ts"],"sourcesContent":["import { constructRow } from '../rows/constructRow'\nimport { tableMemo } from '../../utils'\nimport { table_autoResetPageIndex } from '../../features/row-pagination/rowPaginationFeature.utils'\nimport type {
|
|
1
|
+
{"version":3,"file":"createCoreRowModel.js","names":[],"sources":["../../../src/core/row-models/createCoreRowModel.ts"],"sourcesContent":["import { constructRow } from '../rows/constructRow'\nimport { tableMemo } from '../../utils'\nimport { table_autoResetPageIndex } from '../../features/row-pagination/rowPaginationFeature.utils'\nimport type { Table_Internal } from '../../types/Table'\nimport type { RowModel } from './coreRowModelsFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized core row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createCoreRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): (\n table: Table_Internal<TFeatures, TData>,\n) => () => RowModel<TFeatures, TData> {\n return (table) => {\n return tableMemo({\n feature: 'coreRowModelsFeature',\n table,\n fnName: 'table.getCoreRowModel',\n memoDeps: () => [table.options.data],\n fn: () => _createCoreRowModel(table, table.options.data),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createCoreRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n data: ReadonlyArray<TData>,\n): {\n rows: Array<Row<TFeatures, TData>>\n flatRows: Array<Row<TFeatures, TData>>\n rowsById: Record<string, Row<TFeatures, TData>>\n} {\n const rowModel: RowModel<TFeatures, TData> = {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n\n const accessRows = (\n originalRows: ReadonlyArray<TData>,\n depth = 0,\n parentRow?: Row<TFeatures, TData>,\n ): Array<Row<TFeatures, TData>> => {\n const rows = [] as Array<Row<TFeatures, TData>>\n\n for (let i = 0; i < originalRows.length; i++) {\n const originalRow = originalRows[i]!\n // Make the row\n const row = constructRow(\n table,\n table.getRowId(originalRow, i, parentRow),\n originalRow,\n i,\n depth,\n undefined,\n parentRow?.id,\n )\n\n // Keep track of every row in a flat array\n rowModel.flatRows.push(row)\n // Also keep track of every row by its ID\n rowModel.rowsById[row.id] = row\n // Push table row into parent\n rows.push(row)\n\n // Get the original subrows\n if (table.options.getSubRows) {\n row.originalSubRows = table.options.getSubRows(originalRow, i)\n\n // Then recursively access them\n if (row.originalSubRows?.length) {\n row.subRows = accessRows(row.originalSubRows, depth + 1, row)\n }\n }\n }\n\n return rows\n }\n\n rowModel.rows = accessRows(data)\n\n return rowModel\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,qBAKsB;CACpC,QAAQ,UAAU;EAChB,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB,CAAC,MAAM,QAAQ,IAAI;GACnC,UAAU,oBAAoB,OAAO,MAAM,QAAQ,IAAI;GACvD,qBAAqB,yBAAyB,KAAK;EACrD,CAAC;CACH;AACF;AAEA,SAAS,oBAIP,OACA,MAKA;CACA,MAAM,WAAuC;EAC3C,MAAM,CAAC;EACP,UAAU,CAAC;EACX,UAAU,CAAC;CACb;CAEA,MAAM,cACJ,cACA,QAAQ,GACR,cACiC;EACjC,MAAM,OAAO,CAAC;EAEd,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;GAC5C,MAAM,cAAc,aAAa;GAEjC,MAAM,MAAM,aACV,OACA,MAAM,SAAS,aAAa,GAAG,SAAS,GACxC,aACA,GACA,OACA,8DACA,UAAW,EACb;GAGA,SAAS,SAAS,KAAK,GAAG;GAE1B,SAAS,SAAS,IAAI,MAAM;GAE5B,KAAK,KAAK,GAAG;GAGb,IAAI,MAAM,QAAQ,YAAY;;IAC5B,IAAI,kBAAkB,MAAM,QAAQ,WAAW,aAAa,CAAC;IAG7D,4BAAI,IAAI,6FAAiB,QACvB,IAAI,UAAU,WAAW,IAAI,iBAAiB,QAAQ,GAAG,GAAG;GAEhE;EACF;EAEA,OAAO;CACT;CAEA,SAAS,OAAO,WAAW,IAAI;CAE/B,OAAO;AACT"}
|
|
@@ -5,7 +5,7 @@ import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
|
5
5
|
import { Cell } from "../../types/Cell.cjs";
|
|
6
6
|
|
|
7
7
|
//#region src/core/rows/coreRowsFeature.types.d.ts
|
|
8
|
-
interface Row_CoreProperties<TFeatures extends TableFeatures, TData extends RowData> {
|
|
8
|
+
interface Row_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
9
9
|
_uniqueValuesCache: Record<string, unknown>;
|
|
10
10
|
_valuesCache: Record<string, unknown>;
|
|
11
11
|
/**
|
|
@@ -41,7 +41,7 @@ interface Row_CoreProperties<TFeatures extends TableFeatures, TData extends RowD
|
|
|
41
41
|
*/
|
|
42
42
|
table: Table_Internal<TFeatures, TData>;
|
|
43
43
|
}
|
|
44
|
-
interface Row_Row<TFeatures extends TableFeatures, TData extends RowData> extends Row_CoreProperties<TFeatures, TData> {
|
|
44
|
+
interface Row_Row<in out TFeatures extends TableFeatures, in out TData extends RowData> extends Row_CoreProperties<TFeatures, TData> {
|
|
45
45
|
/**
|
|
46
46
|
* Builds a lookup of this row's cells keyed by leaf column id.
|
|
47
47
|
*/
|
|
@@ -75,7 +75,7 @@ interface Row_Row<TFeatures extends TableFeatures, TData extends RowData> extend
|
|
|
75
75
|
*/
|
|
76
76
|
renderValue: <TValue>(columnId: string) => TValue;
|
|
77
77
|
}
|
|
78
|
-
interface TableOptions_Rows<TFeatures extends TableFeatures, TData extends RowData> {
|
|
78
|
+
interface TableOptions_Rows<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
79
79
|
/**
|
|
80
80
|
* This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with `.` using their grandparents' index eg. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc.
|
|
81
81
|
* @example getRowId: row => row.userId
|
|
@@ -87,7 +87,7 @@ interface TableOptions_Rows<TFeatures extends TableFeatures, TData extends RowDa
|
|
|
87
87
|
*/
|
|
88
88
|
getSubRows?: (originalRow: TData, index: number) => undefined | ReadonlyArray<TData>;
|
|
89
89
|
}
|
|
90
|
-
interface Table_Rows<TFeatures extends TableFeatures, TData extends RowData> {
|
|
90
|
+
interface Table_Rows<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
91
91
|
getRowId: (_: TData, index: number, parent?: Row<TFeatures, TData>) => string;
|
|
92
92
|
/**
|
|
93
93
|
* Returns the row with the given ID.
|
|
@@ -5,7 +5,7 @@ import { TableFeatures } from "../../types/TableFeatures.js";
|
|
|
5
5
|
import { Cell } from "../../types/Cell.js";
|
|
6
6
|
|
|
7
7
|
//#region src/core/rows/coreRowsFeature.types.d.ts
|
|
8
|
-
interface Row_CoreProperties<TFeatures extends TableFeatures, TData extends RowData> {
|
|
8
|
+
interface Row_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
9
9
|
_uniqueValuesCache: Record<string, unknown>;
|
|
10
10
|
_valuesCache: Record<string, unknown>;
|
|
11
11
|
/**
|
|
@@ -41,7 +41,7 @@ interface Row_CoreProperties<TFeatures extends TableFeatures, TData extends RowD
|
|
|
41
41
|
*/
|
|
42
42
|
table: Table_Internal<TFeatures, TData>;
|
|
43
43
|
}
|
|
44
|
-
interface Row_Row<TFeatures extends TableFeatures, TData extends RowData> extends Row_CoreProperties<TFeatures, TData> {
|
|
44
|
+
interface Row_Row<in out TFeatures extends TableFeatures, in out TData extends RowData> extends Row_CoreProperties<TFeatures, TData> {
|
|
45
45
|
/**
|
|
46
46
|
* Builds a lookup of this row's cells keyed by leaf column id.
|
|
47
47
|
*/
|
|
@@ -75,7 +75,7 @@ interface Row_Row<TFeatures extends TableFeatures, TData extends RowData> extend
|
|
|
75
75
|
*/
|
|
76
76
|
renderValue: <TValue>(columnId: string) => TValue;
|
|
77
77
|
}
|
|
78
|
-
interface TableOptions_Rows<TFeatures extends TableFeatures, TData extends RowData> {
|
|
78
|
+
interface TableOptions_Rows<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
79
79
|
/**
|
|
80
80
|
* This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with `.` using their grandparents' index eg. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc.
|
|
81
81
|
* @example getRowId: row => row.userId
|
|
@@ -87,7 +87,7 @@ interface TableOptions_Rows<TFeatures extends TableFeatures, TData extends RowDa
|
|
|
87
87
|
*/
|
|
88
88
|
getSubRows?: (originalRow: TData, index: number) => undefined | ReadonlyArray<TData>;
|
|
89
89
|
}
|
|
90
|
-
interface Table_Rows<TFeatures extends TableFeatures, TData extends RowData> {
|
|
90
|
+
interface Table_Rows<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
91
91
|
getRowId: (_: TData, index: number, parent?: Row<TFeatures, TData>) => string;
|
|
92
92
|
/**
|
|
93
93
|
* Returns the row with the given ID.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructTable.cjs","names":["cloneState","coreFeatures","atomToStore"],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils'\nimport type { Atom } from '@tanstack/store'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState, TableState_All } from '../../types/TableState'\n\n/**\n * Builds the initial table state from registered features and user initial state.\n *\n * Each feature contributes its default state before user-provided `initialState` values are merged in.\n */\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\n/**\n * Constructs a table instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions.features.coreReactivityFeature!\n\n // Strip the non-feature slots: type-only meta slots, row model factories,\n // and row model fn registries all live on the `features` option but are not\n // table features themselves.\n const {\n aggregationFns,\n columnMeta: _columnMeta,\n coreRowModel,\n expandedRowModel,\n facetedMinMaxValues,\n facetedRowModel,\n facetedUniqueValues,\n filterFns,\n filterMeta: _filterMeta,\n filteredRowModel,\n groupedRowModel,\n paginatedRowModel,\n sortFns,\n sortedRowModel,\n tableMeta: _tableMeta,\n ...features\n } = tableOptions.features\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...features },\n _rowModels: {},\n _rowModelFns: { aggregationFns, filterFns, sortFns },\n baseAtoms: {},\n atoms: {},\n } as unknown as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n const mergedOptions = { ...defaultOptions, ...tableOptions }\n\n if (_reactivity.wrapExternalAtoms && mergedOptions.atoms) {\n for (const [atomKey, _atom] of Object.entries(mergedOptions.atoms)) {\n const atom = _atom as Atom<any>\n const wrappedAtom = _reactivity.createWritableAtom(atom.get(), {\n debugName: `externalAtom/${atomKey}`,\n })\n ;(mergedOptions.atoms as any)[atomKey] = wrappedAtom\n // Two-way syncing between the original atom and the wrapped one.\n let syncExternal = false\n const syncAtomToWrappedSub = atom.subscribe((value) => {\n if (syncExternal) return\n wrappedAtom.set(value)\n })\n const syncWrappedToAtomSub = wrappedAtom.subscribe((value) => {\n syncExternal = true\n atom.set(value)\n syncExternal = false\n })\n _reactivity.addSubscription(syncAtomToWrappedSub)\n _reactivity.addSubscription(syncWrappedToAtomSub)\n }\n }\n\n if (_reactivity.createOptionsStore) {\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >(mergedOptions, { debugName: 'table/optionsStore' })\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get() {\n return table.optionsStore!.get()\n },\n set(value) {\n table.optionsStore!.set(() => value) // or your real update shape\n },\n })\n } else {\n table.options = mergedOptions\n }\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState_All\n >\n\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read either external atom or base atom\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n const externalAtoms = table.options.atoms as\n | Partial<Record<keyof TableState_All, Atom<unknown>>>\n | undefined\n const externalAtom = externalAtoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key]!.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table_syncExternalStateToBaseAtoms(table)\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures> & TableState_All\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n ;(snapshot as Record<string, unknown>)[key] = table.atoms[key]!.get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.entries({\n coreRowModel,\n filteredRowModel,\n groupedRowModel,\n sortedRowModel,\n expandedRowModel,\n paginatedRowModel,\n facetedRowModel,\n facetedMinMaxValues,\n facetedUniqueValues,\n })\n .filter(([, factory]) => factory)\n .map(([key]) => key)\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}\\n`,\n { table },\n )\n }\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.constructTableAPIs?.(table)\n }\n\n return table
|
|
1
|
+
{"version":3,"file":"constructTable.cjs","names":["cloneState","coreFeatures","atomToStore"],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils'\nimport type { Atom } from '@tanstack/store'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState, TableState_All } from '../../types/TableState'\n\n/**\n * Builds the initial table state from registered features and user initial state.\n *\n * Each feature contributes its default state before user-provided `initialState` values are merged in.\n */\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\n/**\n * Constructs a table instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions.features.coreReactivityFeature!\n\n // Strip the non-feature slots: type-only meta slots, row model factories,\n // and row model fn registries all live on the `features` option but are not\n // table features themselves.\n const {\n aggregationFns,\n columnMeta: _columnMeta,\n coreRowModel,\n expandedRowModel,\n facetedMinMaxValues,\n facetedRowModel,\n facetedUniqueValues,\n filterFns,\n filterMeta: _filterMeta,\n filteredRowModel,\n groupedRowModel,\n paginatedRowModel,\n sortFns,\n sortedRowModel,\n tableMeta: _tableMeta,\n ...features\n } = tableOptions.features\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...features },\n _rowModels: {},\n _rowModelFns: { aggregationFns, filterFns, sortFns },\n baseAtoms: {},\n atoms: {},\n } as unknown as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n const mergedOptions = { ...defaultOptions, ...tableOptions }\n\n if (_reactivity.wrapExternalAtoms && mergedOptions.atoms) {\n for (const [atomKey, _atom] of Object.entries(mergedOptions.atoms)) {\n const atom = _atom as Atom<any>\n const wrappedAtom = _reactivity.createWritableAtom(atom.get(), {\n debugName: `externalAtom/${atomKey}`,\n })\n ;(mergedOptions.atoms as any)[atomKey] = wrappedAtom\n // Two-way syncing between the original atom and the wrapped one.\n let syncExternal = false\n const syncAtomToWrappedSub = atom.subscribe((value) => {\n if (syncExternal) return\n wrappedAtom.set(value)\n })\n const syncWrappedToAtomSub = wrappedAtom.subscribe((value) => {\n syncExternal = true\n atom.set(value)\n syncExternal = false\n })\n _reactivity.addSubscription(syncAtomToWrappedSub)\n _reactivity.addSubscription(syncWrappedToAtomSub)\n }\n }\n\n if (_reactivity.createOptionsStore) {\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >(mergedOptions, { debugName: 'table/optionsStore' })\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get() {\n return table.optionsStore!.get()\n },\n set(value) {\n table.optionsStore!.set(() => value) // or your real update shape\n },\n })\n } else {\n table.options = mergedOptions\n }\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState_All\n >\n\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read either external atom or base atom\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n const externalAtoms = table.options.atoms as\n | Partial<Record<keyof TableState_All, Atom<unknown>>>\n | undefined\n const externalAtom = externalAtoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key]!.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table_syncExternalStateToBaseAtoms(table)\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures> & TableState_All\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n ;(snapshot as Record<string, unknown>)[key] = table.atoms[key]!.get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.entries({\n coreRowModel,\n filteredRowModel,\n groupedRowModel,\n sortedRowModel,\n expandedRowModel,\n paginatedRowModel,\n facetedRowModel,\n facetedMinMaxValues,\n facetedUniqueValues,\n })\n .filter(([, factory]) => factory)\n .map(([key]) => key)\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}\\n`,\n { table },\n )\n }\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.constructTableAPIs?.(table)\n }\n\n return table as unknown as Table<TFeatures, TData>\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructTable.js","names":[],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils'\nimport type { Atom } from '@tanstack/store'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState, TableState_All } from '../../types/TableState'\n\n/**\n * Builds the initial table state from registered features and user initial state.\n *\n * Each feature contributes its default state before user-provided `initialState` values are merged in.\n */\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\n/**\n * Constructs a table instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions.features.coreReactivityFeature!\n\n // Strip the non-feature slots: type-only meta slots, row model factories,\n // and row model fn registries all live on the `features` option but are not\n // table features themselves.\n const {\n aggregationFns,\n columnMeta: _columnMeta,\n coreRowModel,\n expandedRowModel,\n facetedMinMaxValues,\n facetedRowModel,\n facetedUniqueValues,\n filterFns,\n filterMeta: _filterMeta,\n filteredRowModel,\n groupedRowModel,\n paginatedRowModel,\n sortFns,\n sortedRowModel,\n tableMeta: _tableMeta,\n ...features\n } = tableOptions.features\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...features },\n _rowModels: {},\n _rowModelFns: { aggregationFns, filterFns, sortFns },\n baseAtoms: {},\n atoms: {},\n } as unknown as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n const mergedOptions = { ...defaultOptions, ...tableOptions }\n\n if (_reactivity.wrapExternalAtoms && mergedOptions.atoms) {\n for (const [atomKey, _atom] of Object.entries(mergedOptions.atoms)) {\n const atom = _atom as Atom<any>\n const wrappedAtom = _reactivity.createWritableAtom(atom.get(), {\n debugName: `externalAtom/${atomKey}`,\n })\n ;(mergedOptions.atoms as any)[atomKey] = wrappedAtom\n // Two-way syncing between the original atom and the wrapped one.\n let syncExternal = false\n const syncAtomToWrappedSub = atom.subscribe((value) => {\n if (syncExternal) return\n wrappedAtom.set(value)\n })\n const syncWrappedToAtomSub = wrappedAtom.subscribe((value) => {\n syncExternal = true\n atom.set(value)\n syncExternal = false\n })\n _reactivity.addSubscription(syncAtomToWrappedSub)\n _reactivity.addSubscription(syncWrappedToAtomSub)\n }\n }\n\n if (_reactivity.createOptionsStore) {\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >(mergedOptions, { debugName: 'table/optionsStore' })\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get() {\n return table.optionsStore!.get()\n },\n set(value) {\n table.optionsStore!.set(() => value) // or your real update shape\n },\n })\n } else {\n table.options = mergedOptions\n }\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState_All\n >\n\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read either external atom or base atom\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n const externalAtoms = table.options.atoms as\n | Partial<Record<keyof TableState_All, Atom<unknown>>>\n | undefined\n const externalAtom = externalAtoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key]!.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table_syncExternalStateToBaseAtoms(table)\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures> & TableState_All\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n ;(snapshot as Record<string, unknown>)[key] = table.atoms[key]!.get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.entries({\n coreRowModel,\n filteredRowModel,\n groupedRowModel,\n sortedRowModel,\n expandedRowModel,\n paginatedRowModel,\n facetedRowModel,\n facetedMinMaxValues,\n facetedUniqueValues,\n })\n .filter(([, factory]) => factory)\n .map(([key]) => key)\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}\\n`,\n { table },\n )\n }\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.constructTableAPIs?.(table)\n }\n\n return table
|
|
1
|
+
{"version":3,"file":"constructTable.js","names":[],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils'\nimport type { Atom } from '@tanstack/store'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState, TableState_All } from '../../types/TableState'\n\n/**\n * Builds the initial table state from registered features and user initial state.\n *\n * Each feature contributes its default state before user-provided `initialState` values are merged in.\n */\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\n/**\n * Constructs a table instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions.features.coreReactivityFeature!\n\n // Strip the non-feature slots: type-only meta slots, row model factories,\n // and row model fn registries all live on the `features` option but are not\n // table features themselves.\n const {\n aggregationFns,\n columnMeta: _columnMeta,\n coreRowModel,\n expandedRowModel,\n facetedMinMaxValues,\n facetedRowModel,\n facetedUniqueValues,\n filterFns,\n filterMeta: _filterMeta,\n filteredRowModel,\n groupedRowModel,\n paginatedRowModel,\n sortFns,\n sortedRowModel,\n tableMeta: _tableMeta,\n ...features\n } = tableOptions.features\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...features },\n _rowModels: {},\n _rowModelFns: { aggregationFns, filterFns, sortFns },\n baseAtoms: {},\n atoms: {},\n } as unknown as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n const mergedOptions = { ...defaultOptions, ...tableOptions }\n\n if (_reactivity.wrapExternalAtoms && mergedOptions.atoms) {\n for (const [atomKey, _atom] of Object.entries(mergedOptions.atoms)) {\n const atom = _atom as Atom<any>\n const wrappedAtom = _reactivity.createWritableAtom(atom.get(), {\n debugName: `externalAtom/${atomKey}`,\n })\n ;(mergedOptions.atoms as any)[atomKey] = wrappedAtom\n // Two-way syncing between the original atom and the wrapped one.\n let syncExternal = false\n const syncAtomToWrappedSub = atom.subscribe((value) => {\n if (syncExternal) return\n wrappedAtom.set(value)\n })\n const syncWrappedToAtomSub = wrappedAtom.subscribe((value) => {\n syncExternal = true\n atom.set(value)\n syncExternal = false\n })\n _reactivity.addSubscription(syncAtomToWrappedSub)\n _reactivity.addSubscription(syncWrappedToAtomSub)\n }\n }\n\n if (_reactivity.createOptionsStore) {\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >(mergedOptions, { debugName: 'table/optionsStore' })\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get() {\n return table.optionsStore!.get()\n },\n set(value) {\n table.optionsStore!.set(() => value) // or your real update shape\n },\n })\n } else {\n table.options = mergedOptions\n }\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState_All\n >\n\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read either external atom or base atom\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n const externalAtoms = table.options.atoms as\n | Partial<Record<keyof TableState_All, Atom<unknown>>>\n | undefined\n const externalAtom = externalAtoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key]!.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table_syncExternalStateToBaseAtoms(table)\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures> & TableState_All\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n ;(snapshot as Record<string, unknown>)[key] = table.atoms[key]!.get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.entries({\n coreRowModel,\n filteredRowModel,\n groupedRowModel,\n sortedRowModel,\n expandedRowModel,\n paginatedRowModel,\n facetedRowModel,\n facetedMinMaxValues,\n facetedUniqueValues,\n })\n .filter(([, factory]) => factory)\n .map(([key]) => key)\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}\\n`,\n { table },\n )\n }\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.constructTableAPIs?.(table)\n }\n\n return table as unknown as Table<TFeatures, TData>\n}\n"],"mappings":"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"}
|
|
@@ -9,7 +9,7 @@ import { IsAny, TableFeatures, ValidateFeatureSlots } from "../../types/TableFea
|
|
|
9
9
|
import { Atom, ReadonlyAtom, ReadonlyStore } from "@tanstack/store";
|
|
10
10
|
|
|
11
11
|
//#region src/core/table/coreTablesFeature.types.d.ts
|
|
12
|
-
interface TableMeta<TFeatures extends TableFeatures, TData extends RowData> {}
|
|
12
|
+
interface TableMeta<in out TFeatures extends TableFeatures, in out TData extends RowData> {}
|
|
13
13
|
/**
|
|
14
14
|
* Resolves the type of `options.meta` for a feature set.
|
|
15
15
|
*
|
|
@@ -53,7 +53,7 @@ type ExternalAtoms<TFeatures extends TableFeatures> = Partial<{ [K in keyof Tabl
|
|
|
53
53
|
type BaseAtoms_All = { [K in keyof TableState_All]?: Atom<TableState_All[K]> };
|
|
54
54
|
type Atoms_All = { [K in keyof TableState_All]?: ReadonlyAtom<TableState_All[K]> };
|
|
55
55
|
type ExternalAtoms_All = Partial<{ [K in keyof TableState_All]: Atom<TableState_All[K]> }>;
|
|
56
|
-
interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowData> {
|
|
56
|
+
interface TableOptions_Table<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
57
57
|
/**
|
|
58
58
|
* The feature modules registered on this table instance.
|
|
59
59
|
*
|
|
@@ -114,7 +114,7 @@ interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowD
|
|
|
114
114
|
*/
|
|
115
115
|
readonly state?: Partial<TableState<TFeatures>>;
|
|
116
116
|
}
|
|
117
|
-
interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends RowData> {
|
|
117
|
+
interface Table_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
118
118
|
/**
|
|
119
119
|
* Table reactivity bindings for interacting with TanStack Store.
|
|
120
120
|
*/
|
|
@@ -178,7 +178,7 @@ interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends Ro
|
|
|
178
178
|
*/
|
|
179
179
|
readonly store: ReadonlyStore<TableState<TFeatures>>;
|
|
180
180
|
}
|
|
181
|
-
interface Table_Table<TFeatures extends TableFeatures, TData extends RowData> extends Table_CoreProperties<TFeatures, TData> {
|
|
181
|
+
interface Table_Table<in out TFeatures extends TableFeatures, in out TData extends RowData> extends Table_CoreProperties<TFeatures, TData> {
|
|
182
182
|
/**
|
|
183
183
|
* Resets the table's internal base atoms to `table.initialState`.
|
|
184
184
|
*
|
|
@@ -9,7 +9,7 @@ import { IsAny, TableFeatures, ValidateFeatureSlots } from "../../types/TableFea
|
|
|
9
9
|
import { Atom, ReadonlyAtom, ReadonlyStore } from "@tanstack/store";
|
|
10
10
|
|
|
11
11
|
//#region src/core/table/coreTablesFeature.types.d.ts
|
|
12
|
-
interface TableMeta<TFeatures extends TableFeatures, TData extends RowData> {}
|
|
12
|
+
interface TableMeta<in out TFeatures extends TableFeatures, in out TData extends RowData> {}
|
|
13
13
|
/**
|
|
14
14
|
* Resolves the type of `options.meta` for a feature set.
|
|
15
15
|
*
|
|
@@ -53,7 +53,7 @@ type ExternalAtoms<TFeatures extends TableFeatures> = Partial<{ [K in keyof Tabl
|
|
|
53
53
|
type BaseAtoms_All = { [K in keyof TableState_All]?: Atom<TableState_All[K]> };
|
|
54
54
|
type Atoms_All = { [K in keyof TableState_All]?: ReadonlyAtom<TableState_All[K]> };
|
|
55
55
|
type ExternalAtoms_All = Partial<{ [K in keyof TableState_All]: Atom<TableState_All[K]> }>;
|
|
56
|
-
interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowData> {
|
|
56
|
+
interface TableOptions_Table<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
57
57
|
/**
|
|
58
58
|
* The feature modules registered on this table instance.
|
|
59
59
|
*
|
|
@@ -114,7 +114,7 @@ interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowD
|
|
|
114
114
|
*/
|
|
115
115
|
readonly state?: Partial<TableState<TFeatures>>;
|
|
116
116
|
}
|
|
117
|
-
interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends RowData> {
|
|
117
|
+
interface Table_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
118
118
|
/**
|
|
119
119
|
* Table reactivity bindings for interacting with TanStack Store.
|
|
120
120
|
*/
|
|
@@ -178,7 +178,7 @@ interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends Ro
|
|
|
178
178
|
*/
|
|
179
179
|
readonly store: ReadonlyStore<TableState<TFeatures>>;
|
|
180
180
|
}
|
|
181
|
-
interface Table_Table<TFeatures extends TableFeatures, TData extends RowData> extends Table_CoreProperties<TFeatures, TData> {
|
|
181
|
+
interface Table_Table<in out TFeatures extends TableFeatures, in out TData extends RowData> extends Table_CoreProperties<TFeatures, TData> {
|
|
182
182
|
/**
|
|
183
183
|
* Resets the table's internal base atoms to `table.initialState`.
|
|
184
184
|
*
|