@tanstack/table-core 9.0.0-alpha.37 → 9.0.0-alpha.39
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.cjs.map +1 -1
- package/dist/core/cells/coreCellsFeature.d.cts +1 -1
- package/dist/core/cells/coreCellsFeature.d.ts +1 -1
- package/dist/core/cells/coreCellsFeature.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.d.cts +1 -1
- package/dist/core/columns/coreColumnsFeature.d.ts +1 -1
- package/dist/core/columns/coreColumnsFeature.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.d.cts +1 -1
- package/dist/core/headers/coreHeadersFeature.d.ts +1 -1
- package/dist/core/headers/coreHeadersFeature.js.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.d.cts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.d.ts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.d.cts +1 -1
- package/dist/core/rows/coreRowsFeature.d.ts +1 -1
- package/dist/core/rows/coreRowsFeature.js.map +1 -1
- package/dist/core/table/coreTablesFeature.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.d.cts +1 -1
- package/dist/core/table/coreTablesFeature.d.ts +1 -1
- package/dist/core/table/coreTablesFeature.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.d.cts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.d.ts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.d.cts +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.d.ts +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.cts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.ts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.d.cts +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.d.ts +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +29 -6
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.d.cts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.d.ts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.js +30 -7
- package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.d.cts +1 -1
- package/dist/features/column-resizing/columnResizingFeature.d.ts +1 -1
- package/dist/features/column-resizing/columnResizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.d.cts +1 -1
- package/dist/features/column-sizing/columnSizingFeature.d.ts +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.d.cts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.d.ts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.d.cts +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.d.ts +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.d.cts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.d.ts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.d.cts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.d.ts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.d.cts +1 -1
- package/dist/features/row-pinning/rowPinningFeature.d.ts +1 -1
- package/dist/features/row-pinning/rowPinningFeature.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.d.cts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.d.ts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.d.cts +1 -1
- package/dist/features/row-sorting/rowSortingFeature.d.ts +1 -1
- package/dist/features/row-sorting/rowSortingFeature.js.map +1 -1
- package/dist/features/table-reactivity/tableReactivityFeature.cjs.map +1 -1
- package/dist/features/table-reactivity/tableReactivityFeature.d.cts +1 -1
- package/dist/features/table-reactivity/tableReactivityFeature.d.ts +1 -1
- package/dist/features/table-reactivity/tableReactivityFeature.js.map +1 -1
- package/dist/index.d.cts +23 -23
- package/dist/index.d.ts +23 -23
- package/dist/types/TableFeatures.d.cts +1 -1
- package/dist/types/TableFeatures.d.ts +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/core/cells/coreCellsFeature.ts +1 -1
- package/src/core/columns/coreColumnsFeature.ts +1 -1
- package/src/core/headers/coreHeadersFeature.ts +1 -1
- package/src/core/row-models/coreRowModelsFeature.ts +1 -1
- package/src/core/rows/coreRowsFeature.ts +1 -1
- package/src/core/table/coreTablesFeature.ts +1 -1
- package/src/features/column-faceting/columnFacetingFeature.ts +1 -1
- package/src/features/column-filtering/columnFilteringFeature.ts +1 -1
- package/src/features/column-grouping/columnGroupingFeature.ts +1 -1
- package/src/features/column-ordering/columnOrderingFeature.ts +1 -1
- package/src/features/column-pinning/columnPinningFeature.ts +20 -1
- package/src/features/column-resizing/columnResizingFeature.ts +1 -1
- package/src/features/column-sizing/columnSizingFeature.ts +1 -1
- package/src/features/column-visibility/columnVisibilityFeature.ts +1 -1
- package/src/features/global-filtering/globalFilteringFeature.ts +1 -1
- package/src/features/row-expanding/rowExpandingFeature.ts +1 -1
- package/src/features/row-pagination/rowPaginationFeature.ts +1 -1
- package/src/features/row-pinning/rowPinningFeature.ts +1 -1
- package/src/features/row-selection/rowSelectionFeature.ts +1 -1
- package/src/features/row-sorting/rowSortingFeature.ts +1 -1
- package/src/features/table-reactivity/tableReactivityFeature.ts +1 -1
- package/src/types/TableFeatures.ts +1 -1
- package/src/utils.ts +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CellData, DeepKeys, DeepValue, Getter, NoInfer, OnChangeFn, PartialKeys, Prettify, RequiredKeys, RowData, UnionToIntersection, Updater } from "./types/type-utils.cjs";
|
|
2
|
-
import { constructCoreCellsFeature, coreCellsFeature } from "./core/cells/coreCellsFeature.cjs";
|
|
3
|
-
import { constructCoreColumnsFeature, coreColumnsFeature } from "./core/columns/coreColumnsFeature.cjs";
|
|
4
|
-
import { constructCoreHeadersFeature, coreHeadersFeature } from "./core/headers/coreHeadersFeature.cjs";
|
|
5
|
-
import { constructCoreRowModelsFeature, coreRowModelsFeature } from "./core/row-models/coreRowModelsFeature.cjs";
|
|
6
|
-
import { constructCoreRowsFeature, coreRowsFeature } from "./core/rows/coreRowsFeature.cjs";
|
|
7
|
-
import { constructCoreTablesFeature, coreTablesFeature } from "./core/table/coreTablesFeature.cjs";
|
|
2
|
+
import { CoreCellsFeatureConstructors, constructCoreCellsFeature, coreCellsFeature } from "./core/cells/coreCellsFeature.cjs";
|
|
3
|
+
import { CoreColumnsFeatureConstructors, constructCoreColumnsFeature, coreColumnsFeature } from "./core/columns/coreColumnsFeature.cjs";
|
|
4
|
+
import { CoreHeadersFeatureConstructors, constructCoreHeadersFeature, coreHeadersFeature } from "./core/headers/coreHeadersFeature.cjs";
|
|
5
|
+
import { CoreRowModelsFeatureConstructors, constructCoreRowModelsFeature, coreRowModelsFeature } from "./core/row-models/coreRowModelsFeature.cjs";
|
|
6
|
+
import { CoreRowsFeatureConstructors, constructCoreRowsFeature, coreRowsFeature } from "./core/rows/coreRowsFeature.cjs";
|
|
7
|
+
import { CoreTablesFeatureConstructors, constructCoreTablesFeature, coreTablesFeature } from "./core/table/coreTablesFeature.cjs";
|
|
8
8
|
import { CoreFeatures, coreFeatures } from "./core/coreFeatures.cjs";
|
|
9
9
|
import { BuiltInSortFn, reSplitAlphaNumeric, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns } from "./fns/sortFns.cjs";
|
|
10
10
|
import { CachedRowModel_Sorted, ColumnDef_RowSorting, ColumnSort, Column_RowSorting, CreateRowModel_Sorted, CustomSortFns, RowModelFns_RowSorting, SortDirection, SortFn, SortFnOption, SortFns, SortingState, TableOptions_RowSorting, TableState_RowSorting, Table_RowModels_Sorted, Table_RowSorting } from "./features/row-sorting/rowSortingFeature.types.cjs";
|
|
@@ -34,22 +34,22 @@ import { CachedRowModel_All, CachedRowModels, CachedRowModels_Plugins, CreateRow
|
|
|
34
34
|
import { TableState, TableState_All, TableState_Plugins } from "./types/TableState.cjs";
|
|
35
35
|
import { Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, ExternalAtoms, ExternalAtoms_All, TableMeta, TableOptions_Table, Table_CoreProperties, Table_Table } from "./core/table/coreTablesFeature.types.cjs";
|
|
36
36
|
import { DebugOptions, TableOptions, TableOptions_All, TableOptions_Core, TableOptions_Plugins } from "./types/TableOptions.cjs";
|
|
37
|
-
import { columnFacetingFeature, constructColumnFacetingFeature } from "./features/column-faceting/columnFacetingFeature.cjs";
|
|
38
|
-
import { columnFilteringFeature, constructColumnFilteringFeature } from "./features/column-filtering/columnFilteringFeature.cjs";
|
|
39
|
-
import { columnGroupingFeature, constructColumnGroupingFeature } from "./features/column-grouping/columnGroupingFeature.cjs";
|
|
40
|
-
import { columnOrderingFeature, constructColumnOrderingFeature } from "./features/column-ordering/columnOrderingFeature.cjs";
|
|
41
|
-
import { columnPinningFeature, constructColumnPinningFeature } from "./features/column-pinning/columnPinningFeature.cjs";
|
|
42
|
-
import { columnResizingFeature, constructColumnResizingFeature } from "./features/column-resizing/columnResizingFeature.cjs";
|
|
43
|
-
import { columnSizingFeature, constructColumnSizingFeature } from "./features/column-sizing/columnSizingFeature.cjs";
|
|
44
|
-
import { columnVisibilityFeature, constructColumnVisibilityFeature } from "./features/column-visibility/columnVisibilityFeature.cjs";
|
|
45
|
-
import { constructGlobalFilteringFeature, globalFilteringFeature } from "./features/global-filtering/globalFilteringFeature.cjs";
|
|
46
|
-
import { constructRowExpandingFeature, rowExpandingFeature } from "./features/row-expanding/rowExpandingFeature.cjs";
|
|
47
|
-
import { constructRowPaginationFeature, rowPaginationFeature } from "./features/row-pagination/rowPaginationFeature.cjs";
|
|
48
|
-
import { constructRowPinningFeature, rowPinningFeature } from "./features/row-pinning/rowPinningFeature.cjs";
|
|
49
|
-
import { constructRowSelectionFeature, rowSelectionFeature } from "./features/row-selection/rowSelectionFeature.cjs";
|
|
50
|
-
import { constructRowSortingFeature, rowSortingFeature } from "./features/row-sorting/rowSortingFeature.cjs";
|
|
37
|
+
import { ColumnFacetingFeatureConstructors, columnFacetingFeature, constructColumnFacetingFeature } from "./features/column-faceting/columnFacetingFeature.cjs";
|
|
38
|
+
import { ColumnFilteringFeatureConstructors, columnFilteringFeature, constructColumnFilteringFeature } from "./features/column-filtering/columnFilteringFeature.cjs";
|
|
39
|
+
import { ColumnGroupingFeatureConstructors, columnGroupingFeature, constructColumnGroupingFeature } from "./features/column-grouping/columnGroupingFeature.cjs";
|
|
40
|
+
import { ColumnOrderingFeatureConstructors, columnOrderingFeature, constructColumnOrderingFeature } from "./features/column-ordering/columnOrderingFeature.cjs";
|
|
41
|
+
import { ColumnPinningFeatureConstructors, columnPinningFeature, constructColumnPinningFeature } from "./features/column-pinning/columnPinningFeature.cjs";
|
|
42
|
+
import { ColumnResizingFeatureConstructors, columnResizingFeature, constructColumnResizingFeature } from "./features/column-resizing/columnResizingFeature.cjs";
|
|
43
|
+
import { ColumnSizingFeatureConstructors, columnSizingFeature, constructColumnSizingFeature } from "./features/column-sizing/columnSizingFeature.cjs";
|
|
44
|
+
import { ColumnVisibilityFeatureConstructors, columnVisibilityFeature, constructColumnVisibilityFeature } from "./features/column-visibility/columnVisibilityFeature.cjs";
|
|
45
|
+
import { GlobalFilteringFeatureConstructors, constructGlobalFilteringFeature, globalFilteringFeature } from "./features/global-filtering/globalFilteringFeature.cjs";
|
|
46
|
+
import { RowExpandingFeatureConstructors, constructRowExpandingFeature, rowExpandingFeature } from "./features/row-expanding/rowExpandingFeature.cjs";
|
|
47
|
+
import { RowPaginationFeatureConstructors, constructRowPaginationFeature, rowPaginationFeature } from "./features/row-pagination/rowPaginationFeature.cjs";
|
|
48
|
+
import { RowPinningFeatureConstructors, constructRowPinningFeature, rowPinningFeature } from "./features/row-pinning/rowPinningFeature.cjs";
|
|
49
|
+
import { RowSelectionFeatureConstructors, constructRowSelectionFeature, rowSelectionFeature } from "./features/row-selection/rowSelectionFeature.cjs";
|
|
50
|
+
import { RowSortingFeatureConstructors, constructRowSortingFeature, rowSortingFeature } from "./features/row-sorting/rowSortingFeature.cjs";
|
|
51
51
|
import { StockFeatures, stockFeatures } from "./features/stockFeatures.cjs";
|
|
52
|
-
import { AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, ConstructTableAPIs, ExtractFeatureTypes, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, InitRowInstanceData, Plugins, TableFeature, TableFeatures } from "./types/TableFeatures.cjs";
|
|
52
|
+
import { AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, ConstructTableAPIs, ExtractFeatureTypes, FeatureConstructors, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, InitRowInstanceData, Plugins, TableFeature, TableFeatures } from "./types/TableFeatures.cjs";
|
|
53
53
|
import { CachedRowModel_Faceted, Column_ColumnFaceting, CreateRowModel_Faceted, Table_ColumnFaceting, Table_RowModels_Faceted } from "./features/column-faceting/columnFacetingFeature.types.cjs";
|
|
54
54
|
import { Table, Table_Core, Table_Internal, Table_Plugins } from "./types/Table.cjs";
|
|
55
55
|
import { CachedRowModel_Core, CachedRowModel_Plugins, CreateRowModel_Core, CreateRowModel_Plugins, RowModel, Table_RowModels, Table_RowModels_Core } from "./core/row-models/coreRowModelsFeature.types.cjs";
|
|
@@ -67,7 +67,7 @@ import { constructHeader } from "./core/headers/constructHeader.cjs";
|
|
|
67
67
|
import { constructRow } from "./core/rows/constructRow.cjs";
|
|
68
68
|
import { createCoreRowModel } from "./core/row-models/createCoreRowModel.cjs";
|
|
69
69
|
import { constructTable, getInitialTableState } from "./core/table/constructTable.cjs";
|
|
70
|
-
import { constructReactivityFeature } from "./features/table-reactivity/tableReactivityFeature.cjs";
|
|
70
|
+
import { TableReactivityFeatureConstructors, constructReactivityFeature } from "./features/table-reactivity/tableReactivityFeature.cjs";
|
|
71
71
|
import { createFacetedMinMaxValues } from "./features/column-faceting/createFacetedMinMaxValues.cjs";
|
|
72
72
|
import { createFacetedRowModel } from "./features/column-faceting/createFacetedRowModel.cjs";
|
|
73
73
|
import { createFacetedUniqueValues } from "./features/column-faceting/createFacetedUniqueValues.cjs";
|
|
@@ -76,4 +76,4 @@ import { createGroupedRowModel } from "./features/column-grouping/createGroupedR
|
|
|
76
76
|
import { createExpandedRowModel, expandRows } from "./features/row-expanding/createExpandedRowModel.cjs";
|
|
77
77
|
import { createPaginatedRowModel } from "./features/row-pagination/createPaginatedRowModel.cjs";
|
|
78
78
|
import { createSortedRowModel } from "./features/row-sorting/createSortedRowModel.cjs";
|
|
79
|
-
export { $internalMemoFnMeta, API, APIObject, AccessorColumnDef, AccessorFn, AccessorFnColumnDef, AccessorFnColumnDefBase, AccessorKeyColumnDef, AccessorKeyColumnDefBase, AggregationFn, AggregationFnOption, AggregationFns, AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, BuiltInAggregationFn, BuiltInFilterFn, BuiltInSortFn, CachedRowModel_All, CachedRowModel_Core, CachedRowModel_Expanded, CachedRowModel_Faceted, CachedRowModel_Filtered, CachedRowModel_Grouped, CachedRowModel_Paginated, CachedRowModel_Plugins, CachedRowModel_Sorted, CachedRowModels, CachedRowModels_Plugins, Cell, CellContext, CellData, Cell_Cell, Cell_ColumnGrouping, Cell_Core, Cell_CoreProperties, Cell_Plugins, Column, ColumnDef, ColumnDefBase, ColumnDefBase_All, ColumnDefResolved, ColumnDefTemplate, ColumnDef_ColumnFiltering, ColumnDef_ColumnGrouping, ColumnDef_ColumnPinning, ColumnDef_ColumnResizing, ColumnDef_ColumnSizing, ColumnDef_ColumnVisibility, ColumnDef_GlobalFiltering, ColumnDef_Plugins, ColumnDef_RowSorting, ColumnDefaultOptions, ColumnFilter, ColumnFilterAutoRemoveTestFn, ColumnFiltersState, ColumnHelper, ColumnMeta, ColumnOrderDefaultOptions, ColumnOrderState, ColumnPinningDefaultOptions, ColumnPinningPosition, ColumnPinningState, ColumnResizeDirection, ColumnResizeMode, ColumnResizingDefaultOptions, ColumnSizingDefaultOptions, ColumnSizingState, ColumnSort, ColumnVisibilityState, Column_Column, Column_ColumnFaceting, Column_ColumnFiltering, Column_ColumnGrouping, Column_ColumnOrdering, Column_ColumnPinning, Column_ColumnResizing, Column_ColumnSizing, Column_ColumnVisibility, Column_Core, Column_CoreProperties, Column_GlobalFiltering, Column_Internal, Column_Plugins, Column_RowSorting, ConstructTableAPIs, CoreFeatures, CreateRowModel_Core, CreateRowModel_Expanded, CreateRowModel_Faceted, CreateRowModel_Filtered, CreateRowModel_Grouped, CreateRowModel_Paginated, CreateRowModel_Plugins, CreateRowModel_Sorted, CreateRowModels, CreateRowModels_All, CreateRowModels_Plugins, CustomAggregationFns, CustomFilterFns, CustomSortFns, DebugOptions, DeepKeys, DeepValue, DisplayColumnDef, ExpandedState, ExpandedStateList, ExternalAtoms, ExternalAtoms_All, ExtractFeatureTypes, FilterFn, FilterFnOption, FilterFns, FilterMeta, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, Getter, GroupColumnDef, GroupingColumnMode, GroupingState, Header, HeaderContext, HeaderGroup, HeaderGroup_Core, HeaderGroup_Header, HeaderGroup_Plugins, Header_ColumnResizing, Header_ColumnSizing, Header_Core, Header_CoreProperties, Header_Header, Header_Plugins, IdIdentifier, IdentifiedColumnDef, InitRowInstanceData, MemoFnMeta, NoInfer, OnChangeFn, PaginationDefaultOptions, PaginationState, PartialKeys, Plugins, Prettify, PrototypeAPI, PrototypeAPIObject, RequiredKeys, ResolvedColumnFilter, Row, RowData, RowModel, RowModelFns, RowModelFns_All, RowModelFns_ColumnFiltering, RowModelFns_ColumnGrouping, RowModelFns_Core, RowModelFns_Plugins, RowModelFns_RowSorting, RowPinningDefaultOptions, RowPinningPosition, RowPinningState, RowSelectionState, Row_ColumnFiltering, Row_ColumnGrouping, Row_ColumnPinning, Row_ColumnVisibility, Row_Core, Row_CoreProperties, Row_Plugins, Row_Row, Row_RowExpanding, Row_RowPinning, Row_RowSelection, SortDirection, SortFn, SortFnOption, SortFns, SortingState, StockFeatures, StringHeaderIdentifier, StringOrTemplateHeader, Table, TableFeature, TableFeatures, TableMeta, TableOptions, TableOptions_All, TableOptions_Cell, TableOptions_ColumnFiltering, TableOptions_ColumnGrouping, TableOptions_ColumnOrdering, TableOptions_ColumnPinning, TableOptions_ColumnResizing, TableOptions_ColumnSizing, TableOptions_ColumnVisibility, TableOptions_Columns, TableOptions_Core, TableOptions_GlobalFiltering, TableOptions_Plugins, TableOptions_RowExpanding, TableOptions_RowPagination, TableOptions_RowPinning, TableOptions_RowSelection, TableOptions_RowSorting, TableOptions_Rows, TableOptions_Table, TableState, TableState_All, TableState_ColumnFiltering, TableState_ColumnGrouping, TableState_ColumnOrdering, TableState_ColumnPinning, TableState_ColumnResizing, TableState_ColumnSizing, TableState_ColumnVisibility, TableState_GlobalFiltering, TableState_Plugins, TableState_RowExpanding, TableState_RowPagination, TableState_RowPinning, TableState_RowSelection, TableState_RowSorting, Table_ColumnFaceting, Table_ColumnFiltering, Table_ColumnGrouping, Table_ColumnOrdering, Table_ColumnPinning, Table_ColumnResizing, Table_ColumnSizing, Table_ColumnVisibility, Table_Columns, Table_Core, Table_CoreProperties, Table_GlobalFiltering, Table_Headers, Table_Internal, Table_Plugins, Table_RowExpanding, Table_RowModels, Table_RowModels_Core, Table_RowModels_Expanded, Table_RowModels_Faceted, Table_RowModels_Filtered, Table_RowModels_Grouped, Table_RowModels_Paginated, Table_RowModels_Sorted, Table_RowPagination, Table_RowPinning, Table_RowSelection, Table_RowSorting, Table_Rows, Table_Table, TransformFilterValueFn, UnionToIntersection, Updater, VisibilityDefaultOptions, aggregationFn_count, aggregationFn_extent, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, aggregationFns, assignPrototypeAPIs, assignTableAPIs, buildHeaderGroups, callMemoOrStaticFn, cloneState, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnResizingState, columnSizingFeature, columnVisibilityFeature, constructCell, constructColumn, constructColumnFacetingFeature, constructColumnFilteringFeature, constructColumnGroupingFeature, constructColumnOrderingFeature, constructColumnPinningFeature, constructColumnResizingFeature, constructColumnSizingFeature, constructColumnVisibilityFeature, constructCoreCellsFeature, constructCoreColumnsFeature, constructCoreHeadersFeature, constructCoreRowModelsFeature, constructCoreRowsFeature, constructCoreTablesFeature, constructGlobalFilteringFeature, constructHeader, constructReactivityFeature, constructRow, constructRowExpandingFeature, constructRowPaginationFeature, constructRowPinningFeature, constructRowSelectionFeature, constructRowSortingFeature, constructTable, coreCellsFeature, coreColumnsFeature, coreFeatures, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createColumnHelper, createCoreRowModel, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, expandRows, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_weakEquals, filterFns, flattenBy, functionalUpdate, getFunctionNameInfo, getInitialTableState, getMemoFnMeta, globalFilteringFeature, isFunction, isNumberArray, makeStateUpdater, memo, noop, reSplitAlphaNumeric, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns, stockFeatures, tableFeatures, tableMemo, tableOptions };
|
|
79
|
+
export { $internalMemoFnMeta, API, APIObject, AccessorColumnDef, AccessorFn, AccessorFnColumnDef, AccessorFnColumnDefBase, AccessorKeyColumnDef, AccessorKeyColumnDefBase, AggregationFn, AggregationFnOption, AggregationFns, AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, BuiltInAggregationFn, BuiltInFilterFn, BuiltInSortFn, CachedRowModel_All, CachedRowModel_Core, CachedRowModel_Expanded, CachedRowModel_Faceted, CachedRowModel_Filtered, CachedRowModel_Grouped, CachedRowModel_Paginated, CachedRowModel_Plugins, CachedRowModel_Sorted, CachedRowModels, CachedRowModels_Plugins, Cell, CellContext, CellData, Cell_Cell, Cell_ColumnGrouping, Cell_Core, Cell_CoreProperties, Cell_Plugins, Column, ColumnDef, ColumnDefBase, ColumnDefBase_All, ColumnDefResolved, ColumnDefTemplate, ColumnDef_ColumnFiltering, ColumnDef_ColumnGrouping, ColumnDef_ColumnPinning, ColumnDef_ColumnResizing, ColumnDef_ColumnSizing, ColumnDef_ColumnVisibility, ColumnDef_GlobalFiltering, ColumnDef_Plugins, ColumnDef_RowSorting, ColumnDefaultOptions, ColumnFacetingFeatureConstructors, ColumnFilter, ColumnFilterAutoRemoveTestFn, ColumnFilteringFeatureConstructors, ColumnFiltersState, ColumnGroupingFeatureConstructors, ColumnHelper, ColumnMeta, ColumnOrderDefaultOptions, ColumnOrderState, ColumnOrderingFeatureConstructors, ColumnPinningDefaultOptions, ColumnPinningFeatureConstructors, ColumnPinningPosition, ColumnPinningState, ColumnResizeDirection, ColumnResizeMode, ColumnResizingDefaultOptions, ColumnResizingFeatureConstructors, ColumnSizingDefaultOptions, ColumnSizingFeatureConstructors, ColumnSizingState, ColumnSort, ColumnVisibilityFeatureConstructors, ColumnVisibilityState, Column_Column, Column_ColumnFaceting, Column_ColumnFiltering, Column_ColumnGrouping, Column_ColumnOrdering, Column_ColumnPinning, Column_ColumnResizing, Column_ColumnSizing, Column_ColumnVisibility, Column_Core, Column_CoreProperties, Column_GlobalFiltering, Column_Internal, Column_Plugins, Column_RowSorting, ConstructTableAPIs, CoreCellsFeatureConstructors, CoreColumnsFeatureConstructors, CoreFeatures, CoreHeadersFeatureConstructors, CoreRowModelsFeatureConstructors, CoreRowsFeatureConstructors, CoreTablesFeatureConstructors, CreateRowModel_Core, CreateRowModel_Expanded, CreateRowModel_Faceted, CreateRowModel_Filtered, CreateRowModel_Grouped, CreateRowModel_Paginated, CreateRowModel_Plugins, CreateRowModel_Sorted, CreateRowModels, CreateRowModels_All, CreateRowModels_Plugins, CustomAggregationFns, CustomFilterFns, CustomSortFns, DebugOptions, DeepKeys, DeepValue, DisplayColumnDef, ExpandedState, ExpandedStateList, ExternalAtoms, ExternalAtoms_All, ExtractFeatureTypes, FeatureConstructors, FilterFn, FilterFnOption, FilterFns, FilterMeta, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, Getter, GlobalFilteringFeatureConstructors, GroupColumnDef, GroupingColumnMode, GroupingState, Header, HeaderContext, HeaderGroup, HeaderGroup_Core, HeaderGroup_Header, HeaderGroup_Plugins, Header_ColumnResizing, Header_ColumnSizing, Header_Core, Header_CoreProperties, Header_Header, Header_Plugins, IdIdentifier, IdentifiedColumnDef, InitRowInstanceData, MemoFnMeta, NoInfer, OnChangeFn, PaginationDefaultOptions, PaginationState, PartialKeys, Plugins, Prettify, PrototypeAPI, PrototypeAPIObject, RequiredKeys, ResolvedColumnFilter, Row, RowData, RowExpandingFeatureConstructors, RowModel, RowModelFns, RowModelFns_All, RowModelFns_ColumnFiltering, RowModelFns_ColumnGrouping, RowModelFns_Core, RowModelFns_Plugins, RowModelFns_RowSorting, RowPaginationFeatureConstructors, RowPinningDefaultOptions, RowPinningFeatureConstructors, RowPinningPosition, RowPinningState, RowSelectionFeatureConstructors, RowSelectionState, RowSortingFeatureConstructors, Row_ColumnFiltering, Row_ColumnGrouping, Row_ColumnPinning, Row_ColumnVisibility, Row_Core, Row_CoreProperties, Row_Plugins, Row_Row, Row_RowExpanding, Row_RowPinning, Row_RowSelection, SortDirection, SortFn, SortFnOption, SortFns, SortingState, StockFeatures, StringHeaderIdentifier, StringOrTemplateHeader, Table, TableFeature, TableFeatures, TableMeta, TableOptions, TableOptions_All, TableOptions_Cell, TableOptions_ColumnFiltering, TableOptions_ColumnGrouping, TableOptions_ColumnOrdering, TableOptions_ColumnPinning, TableOptions_ColumnResizing, TableOptions_ColumnSizing, TableOptions_ColumnVisibility, TableOptions_Columns, TableOptions_Core, TableOptions_GlobalFiltering, TableOptions_Plugins, TableOptions_RowExpanding, TableOptions_RowPagination, TableOptions_RowPinning, TableOptions_RowSelection, TableOptions_RowSorting, TableOptions_Rows, TableOptions_Table, TableReactivityFeatureConstructors, TableState, TableState_All, TableState_ColumnFiltering, TableState_ColumnGrouping, TableState_ColumnOrdering, TableState_ColumnPinning, TableState_ColumnResizing, TableState_ColumnSizing, TableState_ColumnVisibility, TableState_GlobalFiltering, TableState_Plugins, TableState_RowExpanding, TableState_RowPagination, TableState_RowPinning, TableState_RowSelection, TableState_RowSorting, Table_ColumnFaceting, Table_ColumnFiltering, Table_ColumnGrouping, Table_ColumnOrdering, Table_ColumnPinning, Table_ColumnResizing, Table_ColumnSizing, Table_ColumnVisibility, Table_Columns, Table_Core, Table_CoreProperties, Table_GlobalFiltering, Table_Headers, Table_Internal, Table_Plugins, Table_RowExpanding, Table_RowModels, Table_RowModels_Core, Table_RowModels_Expanded, Table_RowModels_Faceted, Table_RowModels_Filtered, Table_RowModels_Grouped, Table_RowModels_Paginated, Table_RowModels_Sorted, Table_RowPagination, Table_RowPinning, Table_RowSelection, Table_RowSorting, Table_Rows, Table_Table, TransformFilterValueFn, UnionToIntersection, Updater, VisibilityDefaultOptions, aggregationFn_count, aggregationFn_extent, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, aggregationFns, assignPrototypeAPIs, assignTableAPIs, buildHeaderGroups, callMemoOrStaticFn, cloneState, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnResizingState, columnSizingFeature, columnVisibilityFeature, constructCell, constructColumn, constructColumnFacetingFeature, constructColumnFilteringFeature, constructColumnGroupingFeature, constructColumnOrderingFeature, constructColumnPinningFeature, constructColumnResizingFeature, constructColumnSizingFeature, constructColumnVisibilityFeature, constructCoreCellsFeature, constructCoreColumnsFeature, constructCoreHeadersFeature, constructCoreRowModelsFeature, constructCoreRowsFeature, constructCoreTablesFeature, constructGlobalFilteringFeature, constructHeader, constructReactivityFeature, constructRow, constructRowExpandingFeature, constructRowPaginationFeature, constructRowPinningFeature, constructRowSelectionFeature, constructRowSortingFeature, constructTable, coreCellsFeature, coreColumnsFeature, coreFeatures, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createColumnHelper, createCoreRowModel, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, expandRows, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_weakEquals, filterFns, flattenBy, functionalUpdate, getFunctionNameInfo, getInitialTableState, getMemoFnMeta, globalFilteringFeature, isFunction, isNumberArray, makeStateUpdater, memo, noop, reSplitAlphaNumeric, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns, stockFeatures, tableFeatures, tableMemo, tableOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CellData, DeepKeys, DeepValue, Getter, NoInfer, OnChangeFn, PartialKeys, Prettify, RequiredKeys, RowData, UnionToIntersection, Updater } from "./types/type-utils.js";
|
|
2
|
-
import { constructCoreCellsFeature, coreCellsFeature } from "./core/cells/coreCellsFeature.js";
|
|
3
|
-
import { constructCoreColumnsFeature, coreColumnsFeature } from "./core/columns/coreColumnsFeature.js";
|
|
4
|
-
import { constructCoreHeadersFeature, coreHeadersFeature } from "./core/headers/coreHeadersFeature.js";
|
|
5
|
-
import { constructCoreRowModelsFeature, coreRowModelsFeature } from "./core/row-models/coreRowModelsFeature.js";
|
|
6
|
-
import { constructCoreRowsFeature, coreRowsFeature } from "./core/rows/coreRowsFeature.js";
|
|
7
|
-
import { constructCoreTablesFeature, coreTablesFeature } from "./core/table/coreTablesFeature.js";
|
|
2
|
+
import { CoreCellsFeatureConstructors, constructCoreCellsFeature, coreCellsFeature } from "./core/cells/coreCellsFeature.js";
|
|
3
|
+
import { CoreColumnsFeatureConstructors, constructCoreColumnsFeature, coreColumnsFeature } from "./core/columns/coreColumnsFeature.js";
|
|
4
|
+
import { CoreHeadersFeatureConstructors, constructCoreHeadersFeature, coreHeadersFeature } from "./core/headers/coreHeadersFeature.js";
|
|
5
|
+
import { CoreRowModelsFeatureConstructors, constructCoreRowModelsFeature, coreRowModelsFeature } from "./core/row-models/coreRowModelsFeature.js";
|
|
6
|
+
import { CoreRowsFeatureConstructors, constructCoreRowsFeature, coreRowsFeature } from "./core/rows/coreRowsFeature.js";
|
|
7
|
+
import { CoreTablesFeatureConstructors, constructCoreTablesFeature, coreTablesFeature } from "./core/table/coreTablesFeature.js";
|
|
8
8
|
import { CoreFeatures, coreFeatures } from "./core/coreFeatures.js";
|
|
9
9
|
import { BuiltInSortFn, reSplitAlphaNumeric, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns } from "./fns/sortFns.js";
|
|
10
10
|
import { CachedRowModel_Sorted, ColumnDef_RowSorting, ColumnSort, Column_RowSorting, CreateRowModel_Sorted, CustomSortFns, RowModelFns_RowSorting, SortDirection, SortFn, SortFnOption, SortFns, SortingState, TableOptions_RowSorting, TableState_RowSorting, Table_RowModels_Sorted, Table_RowSorting } from "./features/row-sorting/rowSortingFeature.types.js";
|
|
@@ -34,22 +34,22 @@ import { CachedRowModel_All, CachedRowModels, CachedRowModels_Plugins, CreateRow
|
|
|
34
34
|
import { TableState, TableState_All, TableState_Plugins } from "./types/TableState.js";
|
|
35
35
|
import { Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, ExternalAtoms, ExternalAtoms_All, TableMeta, TableOptions_Table, Table_CoreProperties, Table_Table } from "./core/table/coreTablesFeature.types.js";
|
|
36
36
|
import { DebugOptions, TableOptions, TableOptions_All, TableOptions_Core, TableOptions_Plugins } from "./types/TableOptions.js";
|
|
37
|
-
import { columnFacetingFeature, constructColumnFacetingFeature } from "./features/column-faceting/columnFacetingFeature.js";
|
|
38
|
-
import { columnFilteringFeature, constructColumnFilteringFeature } from "./features/column-filtering/columnFilteringFeature.js";
|
|
39
|
-
import { columnGroupingFeature, constructColumnGroupingFeature } from "./features/column-grouping/columnGroupingFeature.js";
|
|
40
|
-
import { columnOrderingFeature, constructColumnOrderingFeature } from "./features/column-ordering/columnOrderingFeature.js";
|
|
41
|
-
import { columnPinningFeature, constructColumnPinningFeature } from "./features/column-pinning/columnPinningFeature.js";
|
|
42
|
-
import { columnResizingFeature, constructColumnResizingFeature } from "./features/column-resizing/columnResizingFeature.js";
|
|
43
|
-
import { columnSizingFeature, constructColumnSizingFeature } from "./features/column-sizing/columnSizingFeature.js";
|
|
44
|
-
import { columnVisibilityFeature, constructColumnVisibilityFeature } from "./features/column-visibility/columnVisibilityFeature.js";
|
|
45
|
-
import { constructGlobalFilteringFeature, globalFilteringFeature } from "./features/global-filtering/globalFilteringFeature.js";
|
|
46
|
-
import { constructRowExpandingFeature, rowExpandingFeature } from "./features/row-expanding/rowExpandingFeature.js";
|
|
47
|
-
import { constructRowPaginationFeature, rowPaginationFeature } from "./features/row-pagination/rowPaginationFeature.js";
|
|
48
|
-
import { constructRowPinningFeature, rowPinningFeature } from "./features/row-pinning/rowPinningFeature.js";
|
|
49
|
-
import { constructRowSelectionFeature, rowSelectionFeature } from "./features/row-selection/rowSelectionFeature.js";
|
|
50
|
-
import { constructRowSortingFeature, rowSortingFeature } from "./features/row-sorting/rowSortingFeature.js";
|
|
37
|
+
import { ColumnFacetingFeatureConstructors, columnFacetingFeature, constructColumnFacetingFeature } from "./features/column-faceting/columnFacetingFeature.js";
|
|
38
|
+
import { ColumnFilteringFeatureConstructors, columnFilteringFeature, constructColumnFilteringFeature } from "./features/column-filtering/columnFilteringFeature.js";
|
|
39
|
+
import { ColumnGroupingFeatureConstructors, columnGroupingFeature, constructColumnGroupingFeature } from "./features/column-grouping/columnGroupingFeature.js";
|
|
40
|
+
import { ColumnOrderingFeatureConstructors, columnOrderingFeature, constructColumnOrderingFeature } from "./features/column-ordering/columnOrderingFeature.js";
|
|
41
|
+
import { ColumnPinningFeatureConstructors, columnPinningFeature, constructColumnPinningFeature } from "./features/column-pinning/columnPinningFeature.js";
|
|
42
|
+
import { ColumnResizingFeatureConstructors, columnResizingFeature, constructColumnResizingFeature } from "./features/column-resizing/columnResizingFeature.js";
|
|
43
|
+
import { ColumnSizingFeatureConstructors, columnSizingFeature, constructColumnSizingFeature } from "./features/column-sizing/columnSizingFeature.js";
|
|
44
|
+
import { ColumnVisibilityFeatureConstructors, columnVisibilityFeature, constructColumnVisibilityFeature } from "./features/column-visibility/columnVisibilityFeature.js";
|
|
45
|
+
import { GlobalFilteringFeatureConstructors, constructGlobalFilteringFeature, globalFilteringFeature } from "./features/global-filtering/globalFilteringFeature.js";
|
|
46
|
+
import { RowExpandingFeatureConstructors, constructRowExpandingFeature, rowExpandingFeature } from "./features/row-expanding/rowExpandingFeature.js";
|
|
47
|
+
import { RowPaginationFeatureConstructors, constructRowPaginationFeature, rowPaginationFeature } from "./features/row-pagination/rowPaginationFeature.js";
|
|
48
|
+
import { RowPinningFeatureConstructors, constructRowPinningFeature, rowPinningFeature } from "./features/row-pinning/rowPinningFeature.js";
|
|
49
|
+
import { RowSelectionFeatureConstructors, constructRowSelectionFeature, rowSelectionFeature } from "./features/row-selection/rowSelectionFeature.js";
|
|
50
|
+
import { RowSortingFeatureConstructors, constructRowSortingFeature, rowSortingFeature } from "./features/row-sorting/rowSortingFeature.js";
|
|
51
51
|
import { StockFeatures, stockFeatures } from "./features/stockFeatures.js";
|
|
52
|
-
import { AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, ConstructTableAPIs, ExtractFeatureTypes, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, InitRowInstanceData, Plugins, TableFeature, TableFeatures } from "./types/TableFeatures.js";
|
|
52
|
+
import { AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, ConstructTableAPIs, ExtractFeatureTypes, FeatureConstructors, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, InitRowInstanceData, Plugins, TableFeature, TableFeatures } from "./types/TableFeatures.js";
|
|
53
53
|
import { CachedRowModel_Faceted, Column_ColumnFaceting, CreateRowModel_Faceted, Table_ColumnFaceting, Table_RowModels_Faceted } from "./features/column-faceting/columnFacetingFeature.types.js";
|
|
54
54
|
import { Table, Table_Core, Table_Internal, Table_Plugins } from "./types/Table.js";
|
|
55
55
|
import { CachedRowModel_Core, CachedRowModel_Plugins, CreateRowModel_Core, CreateRowModel_Plugins, RowModel, Table_RowModels, Table_RowModels_Core } from "./core/row-models/coreRowModelsFeature.types.js";
|
|
@@ -67,7 +67,7 @@ import { constructHeader } from "./core/headers/constructHeader.js";
|
|
|
67
67
|
import { constructRow } from "./core/rows/constructRow.js";
|
|
68
68
|
import { createCoreRowModel } from "./core/row-models/createCoreRowModel.js";
|
|
69
69
|
import { constructTable, getInitialTableState } from "./core/table/constructTable.js";
|
|
70
|
-
import { constructReactivityFeature } from "./features/table-reactivity/tableReactivityFeature.js";
|
|
70
|
+
import { TableReactivityFeatureConstructors, constructReactivityFeature } from "./features/table-reactivity/tableReactivityFeature.js";
|
|
71
71
|
import { createFacetedMinMaxValues } from "./features/column-faceting/createFacetedMinMaxValues.js";
|
|
72
72
|
import { createFacetedRowModel } from "./features/column-faceting/createFacetedRowModel.js";
|
|
73
73
|
import { createFacetedUniqueValues } from "./features/column-faceting/createFacetedUniqueValues.js";
|
|
@@ -76,4 +76,4 @@ import { createGroupedRowModel } from "./features/column-grouping/createGroupedR
|
|
|
76
76
|
import { createExpandedRowModel, expandRows } from "./features/row-expanding/createExpandedRowModel.js";
|
|
77
77
|
import { createPaginatedRowModel } from "./features/row-pagination/createPaginatedRowModel.js";
|
|
78
78
|
import { createSortedRowModel } from "./features/row-sorting/createSortedRowModel.js";
|
|
79
|
-
export { $internalMemoFnMeta, API, APIObject, AccessorColumnDef, AccessorFn, AccessorFnColumnDef, AccessorFnColumnDefBase, AccessorKeyColumnDef, AccessorKeyColumnDefBase, AggregationFn, AggregationFnOption, AggregationFns, AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, BuiltInAggregationFn, BuiltInFilterFn, BuiltInSortFn, CachedRowModel_All, CachedRowModel_Core, CachedRowModel_Expanded, CachedRowModel_Faceted, CachedRowModel_Filtered, CachedRowModel_Grouped, CachedRowModel_Paginated, CachedRowModel_Plugins, CachedRowModel_Sorted, CachedRowModels, CachedRowModels_Plugins, Cell, CellContext, CellData, Cell_Cell, Cell_ColumnGrouping, Cell_Core, Cell_CoreProperties, Cell_Plugins, Column, ColumnDef, ColumnDefBase, ColumnDefBase_All, ColumnDefResolved, ColumnDefTemplate, ColumnDef_ColumnFiltering, ColumnDef_ColumnGrouping, ColumnDef_ColumnPinning, ColumnDef_ColumnResizing, ColumnDef_ColumnSizing, ColumnDef_ColumnVisibility, ColumnDef_GlobalFiltering, ColumnDef_Plugins, ColumnDef_RowSorting, ColumnDefaultOptions, ColumnFilter, ColumnFilterAutoRemoveTestFn, ColumnFiltersState, ColumnHelper, ColumnMeta, ColumnOrderDefaultOptions, ColumnOrderState, ColumnPinningDefaultOptions, ColumnPinningPosition, ColumnPinningState, ColumnResizeDirection, ColumnResizeMode, ColumnResizingDefaultOptions, ColumnSizingDefaultOptions, ColumnSizingState, ColumnSort, ColumnVisibilityState, Column_Column, Column_ColumnFaceting, Column_ColumnFiltering, Column_ColumnGrouping, Column_ColumnOrdering, Column_ColumnPinning, Column_ColumnResizing, Column_ColumnSizing, Column_ColumnVisibility, Column_Core, Column_CoreProperties, Column_GlobalFiltering, Column_Internal, Column_Plugins, Column_RowSorting, ConstructTableAPIs, CoreFeatures, CreateRowModel_Core, CreateRowModel_Expanded, CreateRowModel_Faceted, CreateRowModel_Filtered, CreateRowModel_Grouped, CreateRowModel_Paginated, CreateRowModel_Plugins, CreateRowModel_Sorted, CreateRowModels, CreateRowModels_All, CreateRowModels_Plugins, CustomAggregationFns, CustomFilterFns, CustomSortFns, DebugOptions, DeepKeys, DeepValue, DisplayColumnDef, ExpandedState, ExpandedStateList, ExternalAtoms, ExternalAtoms_All, ExtractFeatureTypes, FilterFn, FilterFnOption, FilterFns, FilterMeta, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, Getter, GroupColumnDef, GroupingColumnMode, GroupingState, Header, HeaderContext, HeaderGroup, HeaderGroup_Core, HeaderGroup_Header, HeaderGroup_Plugins, Header_ColumnResizing, Header_ColumnSizing, Header_Core, Header_CoreProperties, Header_Header, Header_Plugins, IdIdentifier, IdentifiedColumnDef, InitRowInstanceData, MemoFnMeta, NoInfer, OnChangeFn, PaginationDefaultOptions, PaginationState, PartialKeys, Plugins, Prettify, PrototypeAPI, PrototypeAPIObject, RequiredKeys, ResolvedColumnFilter, Row, RowData, RowModel, RowModelFns, RowModelFns_All, RowModelFns_ColumnFiltering, RowModelFns_ColumnGrouping, RowModelFns_Core, RowModelFns_Plugins, RowModelFns_RowSorting, RowPinningDefaultOptions, RowPinningPosition, RowPinningState, RowSelectionState, Row_ColumnFiltering, Row_ColumnGrouping, Row_ColumnPinning, Row_ColumnVisibility, Row_Core, Row_CoreProperties, Row_Plugins, Row_Row, Row_RowExpanding, Row_RowPinning, Row_RowSelection, SortDirection, SortFn, SortFnOption, SortFns, SortingState, StockFeatures, StringHeaderIdentifier, StringOrTemplateHeader, Table, TableFeature, TableFeatures, TableMeta, TableOptions, TableOptions_All, TableOptions_Cell, TableOptions_ColumnFiltering, TableOptions_ColumnGrouping, TableOptions_ColumnOrdering, TableOptions_ColumnPinning, TableOptions_ColumnResizing, TableOptions_ColumnSizing, TableOptions_ColumnVisibility, TableOptions_Columns, TableOptions_Core, TableOptions_GlobalFiltering, TableOptions_Plugins, TableOptions_RowExpanding, TableOptions_RowPagination, TableOptions_RowPinning, TableOptions_RowSelection, TableOptions_RowSorting, TableOptions_Rows, TableOptions_Table, TableState, TableState_All, TableState_ColumnFiltering, TableState_ColumnGrouping, TableState_ColumnOrdering, TableState_ColumnPinning, TableState_ColumnResizing, TableState_ColumnSizing, TableState_ColumnVisibility, TableState_GlobalFiltering, TableState_Plugins, TableState_RowExpanding, TableState_RowPagination, TableState_RowPinning, TableState_RowSelection, TableState_RowSorting, Table_ColumnFaceting, Table_ColumnFiltering, Table_ColumnGrouping, Table_ColumnOrdering, Table_ColumnPinning, Table_ColumnResizing, Table_ColumnSizing, Table_ColumnVisibility, Table_Columns, Table_Core, Table_CoreProperties, Table_GlobalFiltering, Table_Headers, Table_Internal, Table_Plugins, Table_RowExpanding, Table_RowModels, Table_RowModels_Core, Table_RowModels_Expanded, Table_RowModels_Faceted, Table_RowModels_Filtered, Table_RowModels_Grouped, Table_RowModels_Paginated, Table_RowModels_Sorted, Table_RowPagination, Table_RowPinning, Table_RowSelection, Table_RowSorting, Table_Rows, Table_Table, TransformFilterValueFn, UnionToIntersection, Updater, VisibilityDefaultOptions, aggregationFn_count, aggregationFn_extent, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, aggregationFns, assignPrototypeAPIs, assignTableAPIs, buildHeaderGroups, callMemoOrStaticFn, cloneState, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnResizingState, columnSizingFeature, columnVisibilityFeature, constructCell, constructColumn, constructColumnFacetingFeature, constructColumnFilteringFeature, constructColumnGroupingFeature, constructColumnOrderingFeature, constructColumnPinningFeature, constructColumnResizingFeature, constructColumnSizingFeature, constructColumnVisibilityFeature, constructCoreCellsFeature, constructCoreColumnsFeature, constructCoreHeadersFeature, constructCoreRowModelsFeature, constructCoreRowsFeature, constructCoreTablesFeature, constructGlobalFilteringFeature, constructHeader, constructReactivityFeature, constructRow, constructRowExpandingFeature, constructRowPaginationFeature, constructRowPinningFeature, constructRowSelectionFeature, constructRowSortingFeature, constructTable, coreCellsFeature, coreColumnsFeature, coreFeatures, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createColumnHelper, createCoreRowModel, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, expandRows, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_weakEquals, filterFns, flattenBy, functionalUpdate, getFunctionNameInfo, getInitialTableState, getMemoFnMeta, globalFilteringFeature, isFunction, isNumberArray, makeStateUpdater, memo, noop, reSplitAlphaNumeric, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns, stockFeatures, tableFeatures, tableMemo, tableOptions };
|
|
79
|
+
export { $internalMemoFnMeta, API, APIObject, AccessorColumnDef, AccessorFn, AccessorFnColumnDef, AccessorFnColumnDefBase, AccessorKeyColumnDef, AccessorKeyColumnDefBase, AggregationFn, AggregationFnOption, AggregationFns, AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, BuiltInAggregationFn, BuiltInFilterFn, BuiltInSortFn, CachedRowModel_All, CachedRowModel_Core, CachedRowModel_Expanded, CachedRowModel_Faceted, CachedRowModel_Filtered, CachedRowModel_Grouped, CachedRowModel_Paginated, CachedRowModel_Plugins, CachedRowModel_Sorted, CachedRowModels, CachedRowModels_Plugins, Cell, CellContext, CellData, Cell_Cell, Cell_ColumnGrouping, Cell_Core, Cell_CoreProperties, Cell_Plugins, Column, ColumnDef, ColumnDefBase, ColumnDefBase_All, ColumnDefResolved, ColumnDefTemplate, ColumnDef_ColumnFiltering, ColumnDef_ColumnGrouping, ColumnDef_ColumnPinning, ColumnDef_ColumnResizing, ColumnDef_ColumnSizing, ColumnDef_ColumnVisibility, ColumnDef_GlobalFiltering, ColumnDef_Plugins, ColumnDef_RowSorting, ColumnDefaultOptions, ColumnFacetingFeatureConstructors, ColumnFilter, ColumnFilterAutoRemoveTestFn, ColumnFilteringFeatureConstructors, ColumnFiltersState, ColumnGroupingFeatureConstructors, ColumnHelper, ColumnMeta, ColumnOrderDefaultOptions, ColumnOrderState, ColumnOrderingFeatureConstructors, ColumnPinningDefaultOptions, ColumnPinningFeatureConstructors, ColumnPinningPosition, ColumnPinningState, ColumnResizeDirection, ColumnResizeMode, ColumnResizingDefaultOptions, ColumnResizingFeatureConstructors, ColumnSizingDefaultOptions, ColumnSizingFeatureConstructors, ColumnSizingState, ColumnSort, ColumnVisibilityFeatureConstructors, ColumnVisibilityState, Column_Column, Column_ColumnFaceting, Column_ColumnFiltering, Column_ColumnGrouping, Column_ColumnOrdering, Column_ColumnPinning, Column_ColumnResizing, Column_ColumnSizing, Column_ColumnVisibility, Column_Core, Column_CoreProperties, Column_GlobalFiltering, Column_Internal, Column_Plugins, Column_RowSorting, ConstructTableAPIs, CoreCellsFeatureConstructors, CoreColumnsFeatureConstructors, CoreFeatures, CoreHeadersFeatureConstructors, CoreRowModelsFeatureConstructors, CoreRowsFeatureConstructors, CoreTablesFeatureConstructors, CreateRowModel_Core, CreateRowModel_Expanded, CreateRowModel_Faceted, CreateRowModel_Filtered, CreateRowModel_Grouped, CreateRowModel_Paginated, CreateRowModel_Plugins, CreateRowModel_Sorted, CreateRowModels, CreateRowModels_All, CreateRowModels_Plugins, CustomAggregationFns, CustomFilterFns, CustomSortFns, DebugOptions, DeepKeys, DeepValue, DisplayColumnDef, ExpandedState, ExpandedStateList, ExternalAtoms, ExternalAtoms_All, ExtractFeatureTypes, FeatureConstructors, FilterFn, FilterFnOption, FilterFns, FilterMeta, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, Getter, GlobalFilteringFeatureConstructors, GroupColumnDef, GroupingColumnMode, GroupingState, Header, HeaderContext, HeaderGroup, HeaderGroup_Core, HeaderGroup_Header, HeaderGroup_Plugins, Header_ColumnResizing, Header_ColumnSizing, Header_Core, Header_CoreProperties, Header_Header, Header_Plugins, IdIdentifier, IdentifiedColumnDef, InitRowInstanceData, MemoFnMeta, NoInfer, OnChangeFn, PaginationDefaultOptions, PaginationState, PartialKeys, Plugins, Prettify, PrototypeAPI, PrototypeAPIObject, RequiredKeys, ResolvedColumnFilter, Row, RowData, RowExpandingFeatureConstructors, RowModel, RowModelFns, RowModelFns_All, RowModelFns_ColumnFiltering, RowModelFns_ColumnGrouping, RowModelFns_Core, RowModelFns_Plugins, RowModelFns_RowSorting, RowPaginationFeatureConstructors, RowPinningDefaultOptions, RowPinningFeatureConstructors, RowPinningPosition, RowPinningState, RowSelectionFeatureConstructors, RowSelectionState, RowSortingFeatureConstructors, Row_ColumnFiltering, Row_ColumnGrouping, Row_ColumnPinning, Row_ColumnVisibility, Row_Core, Row_CoreProperties, Row_Plugins, Row_Row, Row_RowExpanding, Row_RowPinning, Row_RowSelection, SortDirection, SortFn, SortFnOption, SortFns, SortingState, StockFeatures, StringHeaderIdentifier, StringOrTemplateHeader, Table, TableFeature, TableFeatures, TableMeta, TableOptions, TableOptions_All, TableOptions_Cell, TableOptions_ColumnFiltering, TableOptions_ColumnGrouping, TableOptions_ColumnOrdering, TableOptions_ColumnPinning, TableOptions_ColumnResizing, TableOptions_ColumnSizing, TableOptions_ColumnVisibility, TableOptions_Columns, TableOptions_Core, TableOptions_GlobalFiltering, TableOptions_Plugins, TableOptions_RowExpanding, TableOptions_RowPagination, TableOptions_RowPinning, TableOptions_RowSelection, TableOptions_RowSorting, TableOptions_Rows, TableOptions_Table, TableReactivityFeatureConstructors, TableState, TableState_All, TableState_ColumnFiltering, TableState_ColumnGrouping, TableState_ColumnOrdering, TableState_ColumnPinning, TableState_ColumnResizing, TableState_ColumnSizing, TableState_ColumnVisibility, TableState_GlobalFiltering, TableState_Plugins, TableState_RowExpanding, TableState_RowPagination, TableState_RowPinning, TableState_RowSelection, TableState_RowSorting, Table_ColumnFaceting, Table_ColumnFiltering, Table_ColumnGrouping, Table_ColumnOrdering, Table_ColumnPinning, Table_ColumnResizing, Table_ColumnSizing, Table_ColumnVisibility, Table_Columns, Table_Core, Table_CoreProperties, Table_GlobalFiltering, Table_Headers, Table_Internal, Table_Plugins, Table_RowExpanding, Table_RowModels, Table_RowModels_Core, Table_RowModels_Expanded, Table_RowModels_Faceted, Table_RowModels_Filtered, Table_RowModels_Grouped, Table_RowModels_Paginated, Table_RowModels_Sorted, Table_RowPagination, Table_RowPinning, Table_RowSelection, Table_RowSorting, Table_Rows, Table_Table, TransformFilterValueFn, UnionToIntersection, Updater, VisibilityDefaultOptions, aggregationFn_count, aggregationFn_extent, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, aggregationFns, assignPrototypeAPIs, assignTableAPIs, buildHeaderGroups, callMemoOrStaticFn, cloneState, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnResizingState, columnSizingFeature, columnVisibilityFeature, constructCell, constructColumn, constructColumnFacetingFeature, constructColumnFilteringFeature, constructColumnGroupingFeature, constructColumnOrderingFeature, constructColumnPinningFeature, constructColumnResizingFeature, constructColumnSizingFeature, constructColumnVisibilityFeature, constructCoreCellsFeature, constructCoreColumnsFeature, constructCoreHeadersFeature, constructCoreRowModelsFeature, constructCoreRowsFeature, constructCoreTablesFeature, constructGlobalFilteringFeature, constructHeader, constructReactivityFeature, constructRow, constructRowExpandingFeature, constructRowPaginationFeature, constructRowPinningFeature, constructRowSelectionFeature, constructRowSortingFeature, constructTable, coreCellsFeature, coreColumnsFeature, coreFeatures, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createColumnHelper, createCoreRowModel, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, expandRows, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_weakEquals, filterFns, flattenBy, functionalUpdate, getFunctionNameInfo, getInitialTableState, getMemoFnMeta, globalFilteringFeature, isFunction, isNumberArray, makeStateUpdater, memo, noop, reSplitAlphaNumeric, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns, stockFeatures, tableFeatures, tableMemo, tableOptions };
|
|
@@ -73,5 +73,5 @@ interface TableFeature<TConstructors extends FeatureConstructors> {
|
|
|
73
73
|
initRowInstanceData?: InitRowInstanceData<TConstructors>;
|
|
74
74
|
}
|
|
75
75
|
//#endregion
|
|
76
|
-
export { AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, ConstructTableAPIs, ExtractFeatureTypes, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, InitRowInstanceData, Plugins, TableFeature, TableFeatures };
|
|
76
|
+
export { AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, ConstructTableAPIs, ExtractFeatureTypes, FeatureConstructors, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, InitRowInstanceData, Plugins, TableFeature, TableFeatures };
|
|
77
77
|
//# sourceMappingURL=TableFeatures.d.cts.map
|
|
@@ -73,5 +73,5 @@ interface TableFeature<TConstructors extends FeatureConstructors> {
|
|
|
73
73
|
initRowInstanceData?: InitRowInstanceData<TConstructors>;
|
|
74
74
|
}
|
|
75
75
|
//#endregion
|
|
76
|
-
export { AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, ConstructTableAPIs, ExtractFeatureTypes, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, InitRowInstanceData, Plugins, TableFeature, TableFeatures };
|
|
76
|
+
export { AssignCellPrototype, AssignColumnPrototype, AssignHeaderPrototype, AssignRowPrototype, ConstructTableAPIs, ExtractFeatureTypes, FeatureConstructors, GetDefaultColumnDef, GetDefaultStateSelector, GetDefaultTableOptions, GetInitialState, InitRowInstanceData, Plugins, TableFeature, TableFeatures };
|
|
77
77
|
//# sourceMappingURL=TableFeatures.d.ts.map
|
package/dist/utils.cjs
CHANGED
|
@@ -175,7 +175,7 @@ function assignPrototypeAPIs(feature, prototype, table, apis) {
|
|
|
175
175
|
if (!this[memoKey]) {
|
|
176
176
|
const self = this;
|
|
177
177
|
this[memoKey] = tableMemo({
|
|
178
|
-
memoDeps: () => memoDeps(self),
|
|
178
|
+
memoDeps: (depArgs) => memoDeps(self, depArgs),
|
|
179
179
|
fn: (...deps) => fn(self, ...deps),
|
|
180
180
|
fnName,
|
|
181
181
|
objectId: self.id,
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table, Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = {}\n\n for (const key of Object.keys(value)) {\n copy[key] = cloneState((value as Record<string, unknown>)[key])\n }\n\n return copy as T\n }\n\n return value\n}\n\nexport function noop() {}\n\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(key: K, instance: Table<TFeatures, any>) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\nexport function isNumberArray(d: any): d is Array<number> {\n return Array.isArray(d) && d.every((val) => typeof val === 'number')\n}\n\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<TNode>) => {\n subArr.forEach((item) => {\n flat.push(item)\n const children = getChildren(item)\n if (children.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\nexport const $internalMemoFnMeta = Symbol('memoFnMeta')\nexport type MemoFnMeta = { originalArgsLength?: number }\n\n/**\n * @internal\n */\nfunction setMemoFnMeta(fn: Function, meta: MemoFnMeta) {\n Object.defineProperty(fn, $internalMemoFnMeta, { value: meta })\n}\n\n/**\n * @internal\n */\nexport function getMemoFnMeta(fn: any): MemoFnMeta | null {\n return (typeof fn === 'function' && fn[$internalMemoFnMeta]) ?? null\n}\n\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n const depsChanged =\n !newDeps ||\n newDeps.length !== deps?.length ||\n newDeps.some((dep: any, index: number) => deps?.[index] !== dep)\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n setMemoFnMeta(memoizedFn, { originalArgsLength: fn.length })\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n}\n\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugCache: _debugCache, debugAll } = table.options\n debugCache = _debugCache\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n queueMicrotask(() => onAfterUpdate?.())\n },\n }\n : {\n onAfterUpdate: () => {\n queueMicrotask(() => onAfterUpdate?.())\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: () => memoDeps(self),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n\n setMemoFnMeta(prototype[fnKey], { originalArgsLength: fn.length })\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TStaticFn extends AnyFunction,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: TStaticFn,\n ...args: Parameters<TStaticFn> extends [any, ...infer Rest] ? Rest : never\n): ReturnType<TStaticFn> {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";;AAKA,SAAgB,iBAAoB,SAAqB,OAAa;AACpE,QAAO,OAAO,YAAY,aACrB,QAAwB,MAAM,GAC/B;;AAGN,SAAgB,WAAc,OAAa;AACzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,WAAW;AAG9B,KAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,QAAQ,OAAO,eAAe,MAAM;AAE1C,MAAI,UAAU,OAAO,aAAa,UAAU,KAC1C,QAAO;EAGT,MAAM,OAAgC,EAAE;AAExC,OAAK,MAAM,OAAO,OAAO,KAAK,MAAM,CAClC,MAAK,OAAO,WAAY,MAAkC,KAAK;AAGjE,SAAO;;AAGT,QAAO;;AAGT,SAAgB,OAAO;AAEvB,SAAgB,iBAGd,KAAQ,UAAiC;AACzC,SAAQ,YAAiE;;AAGvE,cAFsB,SAAS,QAAgB,uDAAQ,SACnB,SAAS,UAAkB,MACpD,KAAK,QAAa,iBAAiB,SAAS,IAAI,CAAC;;;AA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;AAEJ,WAAO,KAAK,SAAS,GAAG,KAAK;;QAI/B,WAAU,SAAS,SAAqB,GAAG,MAAkB;AAC3D,UAAO,GAAG,MAAM,GAAG,KAAK;;AAI5B,gBAAc,UAAU,QAAQ,EAAE,oBAAoB,GAAG,QAAQ,CAAC;;;;;;AAOtE,SAAgB,mBAId,KACA,OACA,UACA,GAAG,MACoB;;AACvB,uBACG,IAAI,0EAAkC,GAAG,KAAK,KAAI,SAAS,KAAK,GAAG,KAAK"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table, Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = {}\n\n for (const key of Object.keys(value)) {\n copy[key] = cloneState((value as Record<string, unknown>)[key])\n }\n\n return copy as T\n }\n\n return value\n}\n\nexport function noop() {}\n\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(key: K, instance: Table<TFeatures, any>) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\nexport function isNumberArray(d: any): d is Array<number> {\n return Array.isArray(d) && d.every((val) => typeof val === 'number')\n}\n\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<TNode>) => {\n subArr.forEach((item) => {\n flat.push(item)\n const children = getChildren(item)\n if (children.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\nexport const $internalMemoFnMeta = Symbol('memoFnMeta')\nexport type MemoFnMeta = { originalArgsLength?: number }\n\n/**\n * @internal\n */\nfunction setMemoFnMeta(fn: Function, meta: MemoFnMeta) {\n Object.defineProperty(fn, $internalMemoFnMeta, { value: meta })\n}\n\n/**\n * @internal\n */\nexport function getMemoFnMeta(fn: any): MemoFnMeta | null {\n return (typeof fn === 'function' && fn[$internalMemoFnMeta]) ?? null\n}\n\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n const depsChanged =\n !newDeps ||\n newDeps.length !== deps?.length ||\n newDeps.some((dep: any, index: number) => deps?.[index] !== dep)\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n setMemoFnMeta(memoizedFn, { originalArgsLength: fn.length })\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n}\n\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugCache: _debugCache, debugAll } = table.options\n debugCache = _debugCache\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n queueMicrotask(() => onAfterUpdate?.())\n },\n }\n : {\n onAfterUpdate: () => {\n queueMicrotask(() => onAfterUpdate?.())\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: (depArgs) => memoDeps(self, depArgs),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n\n setMemoFnMeta(prototype[fnKey], { originalArgsLength: fn.length })\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TStaticFn extends AnyFunction,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: TStaticFn,\n ...args: Parameters<TStaticFn> extends [any, ...infer Rest] ? Rest : never\n): ReturnType<TStaticFn> {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";;AAKA,SAAgB,iBAAoB,SAAqB,OAAa;AACpE,QAAO,OAAO,YAAY,aACrB,QAAwB,MAAM,GAC/B;;AAGN,SAAgB,WAAc,OAAa;AACzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,WAAW;AAG9B,KAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,QAAQ,OAAO,eAAe,MAAM;AAE1C,MAAI,UAAU,OAAO,aAAa,UAAU,KAC1C,QAAO;EAGT,MAAM,OAAgC,EAAE;AAExC,OAAK,MAAM,OAAO,OAAO,KAAK,MAAM,CAClC,MAAK,OAAO,WAAY,MAAkC,KAAK;AAGjE,SAAO;;AAGT,QAAO;;AAGT,SAAgB,OAAO;AAEvB,SAAgB,iBAGd,KAAQ,UAAiC;AACzC,SAAQ,YAAiE;;AAGvE,cAFsB,SAAS,QAAgB,uDAAQ,SACnB,SAAS,UAAkB,MACpD,KAAK,QAAa,iBAAiB,SAAS,IAAI,CAAC;;;AAMhE,SAAgB,WAAkC,GAAgB;AAChE,QAAO,aAAa;;AAGtB,SAAgB,cAAc,GAA4B;AACxD,QAAO,MAAM,QAAQ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,UAAO,GAAG,MAAM,GAAG,KAAK;;AAI5B,gBAAc,UAAU,QAAQ,EAAE,oBAAoB,GAAG,QAAQ,CAAC;;;;;;AAOtE,SAAgB,mBAId,KACA,OACA,UACA,GAAG,MACoB;;AACvB,uBACG,IAAI,0EAAkC,GAAG,KAAK,KAAI,SAAS,KAAK,GAAG,KAAK"}
|
package/dist/utils.js
CHANGED
|
@@ -174,7 +174,7 @@ function assignPrototypeAPIs(feature, prototype, table, apis) {
|
|
|
174
174
|
if (!this[memoKey]) {
|
|
175
175
|
const self = this;
|
|
176
176
|
this[memoKey] = tableMemo({
|
|
177
|
-
memoDeps: () => memoDeps(self),
|
|
177
|
+
memoDeps: (depArgs) => memoDeps(self, depArgs),
|
|
178
178
|
fn: (...deps) => fn(self, ...deps),
|
|
179
179
|
fnName,
|
|
180
180
|
objectId: self.id,
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table, Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = {}\n\n for (const key of Object.keys(value)) {\n copy[key] = cloneState((value as Record<string, unknown>)[key])\n }\n\n return copy as T\n }\n\n return value\n}\n\nexport function noop() {}\n\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(key: K, instance: Table<TFeatures, any>) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\nexport function isNumberArray(d: any): d is Array<number> {\n return Array.isArray(d) && d.every((val) => typeof val === 'number')\n}\n\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<TNode>) => {\n subArr.forEach((item) => {\n flat.push(item)\n const children = getChildren(item)\n if (children.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\nexport const $internalMemoFnMeta = Symbol('memoFnMeta')\nexport type MemoFnMeta = { originalArgsLength?: number }\n\n/**\n * @internal\n */\nfunction setMemoFnMeta(fn: Function, meta: MemoFnMeta) {\n Object.defineProperty(fn, $internalMemoFnMeta, { value: meta })\n}\n\n/**\n * @internal\n */\nexport function getMemoFnMeta(fn: any): MemoFnMeta | null {\n return (typeof fn === 'function' && fn[$internalMemoFnMeta]) ?? null\n}\n\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n const depsChanged =\n !newDeps ||\n newDeps.length !== deps?.length ||\n newDeps.some((dep: any, index: number) => deps?.[index] !== dep)\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n setMemoFnMeta(memoizedFn, { originalArgsLength: fn.length })\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n}\n\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugCache: _debugCache, debugAll } = table.options\n debugCache = _debugCache\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n queueMicrotask(() => onAfterUpdate?.())\n },\n }\n : {\n onAfterUpdate: () => {\n queueMicrotask(() => onAfterUpdate?.())\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: () => memoDeps(self),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n\n setMemoFnMeta(prototype[fnKey], { originalArgsLength: fn.length })\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TStaticFn extends AnyFunction,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: TStaticFn,\n ...args: Parameters<TStaticFn> extends [any, ...infer Rest] ? Rest : never\n): ReturnType<TStaticFn> {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";AAKA,SAAgB,iBAAoB,SAAqB,OAAa;AACpE,QAAO,OAAO,YAAY,aACrB,QAAwB,MAAM,GAC/B;;AAGN,SAAgB,WAAc,OAAa;AACzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,WAAW;AAG9B,KAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,QAAQ,OAAO,eAAe,MAAM;AAE1C,MAAI,UAAU,OAAO,aAAa,UAAU,KAC1C,QAAO;EAGT,MAAM,OAAgC,EAAE;AAExC,OAAK,MAAM,OAAO,OAAO,KAAK,MAAM,CAClC,MAAK,OAAO,WAAY,MAAkC,KAAK;AAGjE,SAAO;;AAGT,QAAO;;AAGT,SAAgB,OAAO;AAEvB,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,MAAM,OAAO;AACb,UAAK,WAAW,UAAU;MACxB,gBAAgB,SAAS,KAAK;MAC9B,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK;MAClC;MACA,UAAU,KAAK;MACf;MACA;MACD,CAAC;;AAEJ,WAAO,KAAK,SAAS,GAAG,KAAK;;QAI/B,WAAU,SAAS,SAAqB,GAAG,MAAkB;AAC3D,UAAO,GAAG,MAAM,GAAG,KAAK;;AAI5B,gBAAc,UAAU,QAAQ,EAAE,oBAAoB,GAAG,QAAQ,CAAC;;;;;;AAOtE,SAAgB,mBAId,KACA,OACA,UACA,GAAG,MACoB;;AACvB,uBACG,IAAI,0EAAkC,GAAG,KAAK,KAAI,SAAS,KAAK,GAAG,KAAK"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table, Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = {}\n\n for (const key of Object.keys(value)) {\n copy[key] = cloneState((value as Record<string, unknown>)[key])\n }\n\n return copy as T\n }\n\n return value\n}\n\nexport function noop() {}\n\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(key: K, instance: Table<TFeatures, any>) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\nexport function isNumberArray(d: any): d is Array<number> {\n return Array.isArray(d) && d.every((val) => typeof val === 'number')\n}\n\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<TNode>) => {\n subArr.forEach((item) => {\n flat.push(item)\n const children = getChildren(item)\n if (children.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\nexport const $internalMemoFnMeta = Symbol('memoFnMeta')\nexport type MemoFnMeta = { originalArgsLength?: number }\n\n/**\n * @internal\n */\nfunction setMemoFnMeta(fn: Function, meta: MemoFnMeta) {\n Object.defineProperty(fn, $internalMemoFnMeta, { value: meta })\n}\n\n/**\n * @internal\n */\nexport function getMemoFnMeta(fn: any): MemoFnMeta | null {\n return (typeof fn === 'function' && fn[$internalMemoFnMeta]) ?? null\n}\n\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n const depsChanged =\n !newDeps ||\n newDeps.length !== deps?.length ||\n newDeps.some((dep: any, index: number) => deps?.[index] !== dep)\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n setMemoFnMeta(memoizedFn, { originalArgsLength: fn.length })\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n}\n\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugCache: _debugCache, debugAll } = table.options\n debugCache = _debugCache\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n queueMicrotask(() => onAfterUpdate?.())\n },\n }\n : {\n onAfterUpdate: () => {\n queueMicrotask(() => onAfterUpdate?.())\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: (depArgs) => memoDeps(self, depArgs),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n\n setMemoFnMeta(prototype[fnKey], { originalArgsLength: fn.length })\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TStaticFn extends AnyFunction,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: TStaticFn,\n ...args: Parameters<TStaticFn> extends [any, ...infer Rest] ? Rest : never\n): ReturnType<TStaticFn> {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";AAKA,SAAgB,iBAAoB,SAAqB,OAAa;AACpE,QAAO,OAAO,YAAY,aACrB,QAAwB,MAAM,GAC/B;;AAGN,SAAgB,WAAc,OAAa;AACzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,WAAW;AAG9B,KAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,QAAQ,OAAO,eAAe,MAAM;AAE1C,MAAI,UAAU,OAAO,aAAa,UAAU,KAC1C,QAAO;EAGT,MAAM,OAAgC,EAAE;AAExC,OAAK,MAAM,OAAO,OAAO,KAAK,MAAM,CAClC,MAAK,OAAO,WAAY,MAAkC,KAAK;AAGjE,SAAO;;AAGT,QAAO;;AAGT,SAAgB,OAAO;AAEvB,SAAgB,iBAGd,KAAQ,UAAiC;AACzC,SAAQ,YAAiE;;AAGvE,cAFsB,SAAS,QAAgB,uDAAQ,SACnB,SAAS,U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AAG,MAAM,GAAG,KAAK;MAClC;MACA,UAAU,KAAK;MACf;MACA;MACD,CAAC;;AAEJ,WAAO,KAAK,SAAS,GAAG,KAAK;;QAI/B,WAAU,SAAS,SAAqB,GAAG,MAAkB;AAC3D,UAAO,GAAG,MAAM,GAAG,KAAK;;AAI5B,gBAAc,UAAU,QAAQ,EAAE,oBAAoB,GAAG,QAAQ,CAAC;;;;;;AAOtE,SAAgB,mBAId,KACA,OACA,UACA,GAAG,MACoB;;AACvB,uBACG,IAAI,0EAAkC,GAAG,KAAK,KAAI,SAAS,KAAK,GAAG,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.39",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for TS/JS.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"test:eslint": "eslint ./src",
|
|
62
62
|
"test:lib": "vitest",
|
|
63
63
|
"test:lib:dev": "pnpm test:lib --watch",
|
|
64
|
-
"test:types": "tsc",
|
|
64
|
+
"test:types": "tsc && tsc -p tests/tsconfig.declaration-emit.json",
|
|
65
65
|
"test:build": "publint --strict",
|
|
66
66
|
"build": "tsdown"
|
|
67
67
|
}
|
|
@@ -8,7 +8,7 @@ import type { RowData } from '../../types/type-utils'
|
|
|
8
8
|
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
9
9
|
// import type { Cell_Cell, TableOptions_Cell } from './coreCellsFeature.types'
|
|
10
10
|
|
|
11
|
-
interface CoreCellsFeatureConstructors<
|
|
11
|
+
export interface CoreCellsFeatureConstructors<
|
|
12
12
|
TFeatures extends TableFeatures,
|
|
13
13
|
TData extends RowData,
|
|
14
14
|
> {
|
|
@@ -17,7 +17,7 @@ import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
|
17
17
|
// Table_Columns,
|
|
18
18
|
// } from './coreColumnsFeature.types'
|
|
19
19
|
|
|
20
|
-
interface CoreColumnsFeatureConstructors<
|
|
20
|
+
export interface CoreColumnsFeatureConstructors<
|
|
21
21
|
TFeatures extends TableFeatures,
|
|
22
22
|
TData extends RowData,
|
|
23
23
|
> {
|
|
@@ -20,7 +20,7 @@ import type { RowData } from '../../types/type-utils'
|
|
|
20
20
|
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
21
21
|
// import type { Header_Header, Table_Headers } from './coreHeadersFeature.types'
|
|
22
22
|
|
|
23
|
-
interface CoreHeadersFeatureConstructors<
|
|
23
|
+
export interface CoreHeadersFeatureConstructors<
|
|
24
24
|
TFeatures extends TableFeatures,
|
|
25
25
|
TData extends RowData,
|
|
26
26
|
> {
|
|
@@ -17,7 +17,7 @@ import type { RowData } from '../../types/type-utils'
|
|
|
17
17
|
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
18
18
|
// import type { Table_RowModels } from './coreRowModelsFeature.types'
|
|
19
19
|
|
|
20
|
-
interface CoreRowModelsFeatureConstructors<
|
|
20
|
+
export interface CoreRowModelsFeatureConstructors<
|
|
21
21
|
TFeatures extends TableFeatures,
|
|
22
22
|
TData extends RowData,
|
|
23
23
|
> {
|
|
@@ -19,7 +19,7 @@ import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
|
19
19
|
// Table_Rows,
|
|
20
20
|
// } from './coreRowsFeature.types'
|
|
21
21
|
|
|
22
|
-
interface CoreRowsFeatureConstructors<
|
|
22
|
+
export interface CoreRowsFeatureConstructors<
|
|
23
23
|
TFeatures extends TableFeatures,
|
|
24
24
|
TData extends RowData,
|
|
25
25
|
> {
|
|
@@ -4,7 +4,7 @@ import type { RowData } from '../../types/type-utils'
|
|
|
4
4
|
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
5
5
|
// import type { TableOptions_Table, Table_Table } from './coreTablesFeature.types'
|
|
6
6
|
|
|
7
|
-
interface CoreTablesFeatureConstructors<
|
|
7
|
+
export interface CoreTablesFeatureConstructors<
|
|
8
8
|
TFeatures extends TableFeatures,
|
|
9
9
|
TData extends RowData,
|
|
10
10
|
> {
|
|
@@ -20,7 +20,7 @@ import type { Column_Internal } from '../../types/Column'
|
|
|
20
20
|
// CreateRowModel_Faceted,
|
|
21
21
|
// } from './columnFacetingFeature.types'
|
|
22
22
|
|
|
23
|
-
interface ColumnFacetingFeatureConstructors<
|
|
23
|
+
export interface ColumnFacetingFeatureConstructors<
|
|
24
24
|
TFeatures extends TableFeatures,
|
|
25
25
|
TData extends RowData,
|
|
26
26
|
> {
|
|
@@ -29,7 +29,7 @@ import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
|
29
29
|
// Table_ColumnFiltering,
|
|
30
30
|
// } from './columnFilteringFeature.types'
|
|
31
31
|
|
|
32
|
-
interface ColumnFilteringFeatureConstructors<
|
|
32
|
+
export interface ColumnFilteringFeatureConstructors<
|
|
33
33
|
TFeatures extends TableFeatures,
|
|
34
34
|
TData extends RowData,
|
|
35
35
|
> {
|
|
@@ -35,7 +35,7 @@ import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
|
35
35
|
// Table_ColumnGrouping,
|
|
36
36
|
// } from './columnGroupingFeature.types'
|
|
37
37
|
|
|
38
|
-
interface ColumnGroupingFeatureConstructors<
|
|
38
|
+
export interface ColumnGroupingFeatureConstructors<
|
|
39
39
|
TFeatures extends TableFeatures,
|
|
40
40
|
TData extends RowData,
|
|
41
41
|
> {
|
|
@@ -21,7 +21,7 @@ import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
|
21
21
|
// Table_ColumnOrdering,
|
|
22
22
|
// } from './columnOrderingFeature.types'
|
|
23
23
|
|
|
24
|
-
interface ColumnOrderingFeatureConstructors<
|
|
24
|
+
export interface ColumnOrderingFeatureConstructors<
|
|
25
25
|
TFeatures extends TableFeatures,
|
|
26
26
|
TData extends RowData,
|
|
27
27
|
> {
|
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
table_getLeftLeafColumns,
|
|
28
28
|
table_getLeftLeafHeaders,
|
|
29
29
|
table_getLeftVisibleLeafColumns,
|
|
30
|
+
table_getPinnedLeafColumns,
|
|
31
|
+
table_getPinnedVisibleLeafColumns,
|
|
30
32
|
table_getRightFlatHeaders,
|
|
31
33
|
table_getRightFooterGroups,
|
|
32
34
|
table_getRightHeaderGroups,
|
|
@@ -47,7 +49,7 @@ import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
|
|
|
47
49
|
// Table_ColumnPinning,
|
|
48
50
|
// } from './columnPinningFeature.types'
|
|
49
51
|
|
|
50
|
-
interface ColumnPinningFeatureConstructors<
|
|
52
|
+
export interface ColumnPinningFeatureConstructors<
|
|
51
53
|
TFeatures extends TableFeatures,
|
|
52
54
|
TData extends RowData,
|
|
53
55
|
> {
|
|
@@ -292,6 +294,14 @@ export function constructColumnPinningFeature<
|
|
|
292
294
|
table.atoms.columnPinning?.get(),
|
|
293
295
|
],
|
|
294
296
|
},
|
|
297
|
+
table_getPinnedLeafColumns: {
|
|
298
|
+
fn: (position) => table_getPinnedLeafColumns(table, position),
|
|
299
|
+
memoDeps: (position) => [
|
|
300
|
+
position,
|
|
301
|
+
table.options.columns,
|
|
302
|
+
table.atoms.columnPinning?.get(),
|
|
303
|
+
],
|
|
304
|
+
},
|
|
295
305
|
// visible leaf columns
|
|
296
306
|
table_getLeftVisibleLeafColumns: {
|
|
297
307
|
fn: () => table_getLeftVisibleLeafColumns(table),
|
|
@@ -317,6 +327,15 @@ export function constructColumnPinningFeature<
|
|
|
317
327
|
table.atoms.columnVisibility?.get(),
|
|
318
328
|
],
|
|
319
329
|
},
|
|
330
|
+
table_getPinnedVisibleLeafColumns: {
|
|
331
|
+
fn: (position) => table_getPinnedVisibleLeafColumns(table, position),
|
|
332
|
+
memoDeps: (position) => [
|
|
333
|
+
position,
|
|
334
|
+
table.options.columns,
|
|
335
|
+
table.atoms.columnPinning?.get(),
|
|
336
|
+
table.atoms.columnVisibility?.get(),
|
|
337
|
+
],
|
|
338
|
+
},
|
|
320
339
|
})
|
|
321
340
|
},
|
|
322
341
|
}
|