@tanstack/table-core 9.0.0-alpha.47 → 9.0.0-alpha.48
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/README.md +10 -0
- package/dist/core/cells/coreCellsFeature.utils.cjs +11 -8
- package/dist/core/cells/coreCellsFeature.utils.cjs.map +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.cts +11 -8
- package/dist/core/cells/coreCellsFeature.utils.d.ts +11 -8
- package/dist/core/cells/coreCellsFeature.utils.js +11 -8
- package/dist/core/cells/coreCellsFeature.utils.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.types.d.cts +7 -6
- package/dist/core/columns/coreColumnsFeature.types.d.ts +7 -6
- package/dist/core/columns/coreColumnsFeature.utils.cjs +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.cts +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.js +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.types.d.cts +6 -4
- package/dist/core/headers/coreHeadersFeature.types.d.ts +6 -4
- package/dist/core/headers/coreHeadersFeature.utils.cjs +23 -18
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +23 -18
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +23 -18
- package/dist/core/headers/coreHeadersFeature.utils.js +23 -18
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.js +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
- package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
- package/dist/core/rows/coreRowsFeature.utils.cjs +34 -28
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +34 -28
- package/dist/core/rows/coreRowsFeature.utils.d.ts +34 -28
- package/dist/core/rows/coreRowsFeature.utils.js +34 -28
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +6 -2
- package/dist/core/table/coreTablesFeature.types.d.ts +6 -2
- package/dist/core/table/coreTablesFeature.utils.cjs +2 -2
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +2 -2
- package/dist/core/table/coreTablesFeature.utils.d.ts +2 -2
- package/dist/core/table/coreTablesFeature.utils.js +2 -2
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +16 -10
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +16 -10
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.js +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +21 -11
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +21 -11
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +18 -14
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +18 -14
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +14 -5
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +14 -5
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +43 -31
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +43 -31
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +111 -91
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +111 -91
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +111 -91
- package/dist/features/column-pinning/columnPinningFeature.utils.js +111 -91
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.types.d.cts +9 -9
- package/dist/features/column-resizing/columnResizingFeature.types.d.ts +9 -9
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.js +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.cts +19 -12
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +19 -12
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.js +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +16 -13
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +16 -13
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +54 -42
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +54 -42
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +54 -42
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +54 -42
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +10 -5
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +10 -5
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +16 -15
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +16 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +19 -12
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +19 -12
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.types.d.cts +12 -8
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +12 -8
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.js +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +30 -24
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +30 -24
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.js +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +10 -8
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +10 -8
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.js +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/fns/aggregationFns.cjs +33 -9
- package/dist/fns/aggregationFns.cjs.map +1 -1
- package/dist/fns/aggregationFns.d.cts +33 -9
- package/dist/fns/aggregationFns.d.ts +33 -9
- package/dist/fns/aggregationFns.js +33 -9
- package/dist/fns/aggregationFns.js.map +1 -1
- package/dist/fns/filterFns.cjs +48 -17
- package/dist/fns/filterFns.cjs.map +1 -1
- package/dist/fns/filterFns.d.cts +42 -15
- package/dist/fns/filterFns.d.ts +42 -15
- package/dist/fns/filterFns.js +48 -17
- package/dist/fns/filterFns.js.map +1 -1
- package/dist/helpers/columnHelper.cjs +9 -4
- package/dist/helpers/columnHelper.cjs.map +1 -1
- package/dist/helpers/columnHelper.d.cts +9 -4
- package/dist/helpers/columnHelper.d.ts +9 -4
- package/dist/helpers/columnHelper.js +9 -4
- package/dist/helpers/columnHelper.js.map +1 -1
- package/dist/helpers/tableOptions.cjs.map +1 -1
- package/dist/helpers/tableOptions.d.cts +12 -9
- package/dist/helpers/tableOptions.d.ts +12 -9
- package/dist/helpers/tableOptions.js.map +1 -1
- package/dist/types/ColumnDef.d.cts +38 -0
- package/dist/types/ColumnDef.d.ts +38 -0
- package/dist/types/TableOptions.d.cts +15 -0
- package/dist/types/TableOptions.d.ts +15 -0
- package/dist/types/TableState.d.cts +12 -0
- package/dist/types/TableState.d.ts +12 -0
- package/package.json +5 -3
- package/skills/column-definitions/SKILL.md +333 -0
- package/skills/column-layout/SKILL.md +328 -0
- package/skills/column-layout/references/subsystems.md +220 -0
- package/skills/customizing-feature-behavior/SKILL.md +416 -0
- package/skills/filtering/SKILL.md +357 -0
- package/skills/filtering/references/faceting-and-fuzzy.md +191 -0
- package/skills/grouping/SKILL.md +448 -0
- package/skills/migrate-v8-to-v9/SKILL.md +495 -0
- package/skills/pagination/SKILL.md +385 -0
- package/skills/row-expanding/SKILL.md +348 -0
- package/skills/row-pinning/SKILL.md +269 -0
- package/skills/row-selection/SKILL.md +391 -0
- package/skills/setup/SKILL.md +400 -0
- package/skills/sorting/SKILL.md +344 -0
- package/skills/state-management/SKILL.md +388 -0
- package/src/core/cells/coreCellsFeature.utils.ts +11 -8
- package/src/core/columns/coreColumnsFeature.types.ts +7 -6
- package/src/core/columns/coreColumnsFeature.utils.ts +37 -27
- package/src/core/headers/coreHeadersFeature.types.ts +6 -4
- package/src/core/headers/coreHeadersFeature.utils.ts +23 -18
- package/src/core/row-models/coreRowModelsFeature.utils.ts +48 -36
- package/src/core/rows/coreRowsFeature.types.ts +4 -4
- package/src/core/rows/coreRowsFeature.utils.ts +34 -28
- package/src/core/table/coreTablesFeature.types.ts +6 -2
- package/src/core/table/coreTablesFeature.utils.ts +2 -2
- package/src/features/column-faceting/columnFacetingFeature.types.ts +16 -10
- package/src/features/column-faceting/columnFacetingFeature.utils.ts +26 -18
- package/src/features/column-filtering/columnFilteringFeature.types.ts +21 -11
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +39 -28
- package/src/features/column-grouping/columnGroupingFeature.types.ts +18 -14
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +55 -43
- package/src/features/column-ordering/columnOrderingFeature.types.ts +14 -5
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +30 -23
- package/src/features/column-pinning/columnPinningFeature.types.ts +43 -31
- package/src/features/column-pinning/columnPinningFeature.utils.ts +111 -91
- package/src/features/column-resizing/columnResizingFeature.types.ts +9 -9
- package/src/features/column-resizing/columnResizingFeature.utils.ts +28 -19
- package/src/features/column-sizing/columnSizingFeature.types.ts +19 -12
- package/src/features/column-sizing/columnSizingFeature.utils.ts +52 -41
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +16 -13
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +54 -42
- package/src/features/global-filtering/globalFilteringFeature.types.ts +10 -5
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +20 -14
- package/src/features/row-expanding/rowExpandingFeature.types.ts +16 -15
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +56 -41
- package/src/features/row-pagination/rowPaginationFeature.types.ts +19 -12
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +49 -32
- package/src/features/row-pinning/rowPinningFeature.types.ts +12 -8
- package/src/features/row-pinning/rowPinningFeature.utils.ts +39 -29
- package/src/features/row-selection/rowSelectionFeature.types.ts +30 -24
- package/src/features/row-selection/rowSelectionFeature.utils.ts +89 -69
- package/src/features/row-sorting/rowSortingFeature.types.ts +10 -8
- package/src/features/row-sorting/rowSortingFeature.utils.ts +61 -44
- package/src/fns/aggregationFns.ts +33 -9
- package/src/fns/filterFns.ts +48 -17
- package/src/helpers/columnHelper.ts +9 -4
- package/src/helpers/tableOptions.ts +12 -9
- package/src/types/ColumnDef.ts +38 -0
- package/src/types/TableOptions.ts +15 -0
- package/src/types/TableState.ts +12 -0
|
@@ -3,39 +3,41 @@ const require_columnPinningFeature_utils = require('../column-pinning/columnPinn
|
|
|
3
3
|
|
|
4
4
|
//#region src/features/column-ordering/columnOrderingFeature.utils.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Creates the default column order state.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* The feature default is an empty array, meaning leaf columns keep their natural
|
|
9
|
+
* definition order. Reset APIs use this value when `defaultState` is `true`.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
* ```ts
|
|
12
|
-
* const
|
|
13
|
+
* const order = getDefaultColumnOrderState()
|
|
13
14
|
* ```
|
|
14
15
|
*/
|
|
15
16
|
function getDefaultColumnOrderState() {
|
|
16
17
|
return [];
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* Finds this column's index within a visible pinning region.
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
+
* Pass `'left'`, `'center'`, or `'right'` to search that region; omit the
|
|
23
|
+
* position to search the full visible leaf column list.
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
24
26
|
* ```ts
|
|
25
|
-
* const
|
|
27
|
+
* const index = column_getIndex(column, 'center')
|
|
26
28
|
* ```
|
|
27
29
|
*/
|
|
28
30
|
function column_getIndex(column, position) {
|
|
29
31
|
return require_columnPinningFeature_utils.table_getPinnedVisibleLeafColumns(column.table, position).findIndex((d) => d.id === column.id);
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Checks whether this column is the first visible column in a pinning region.
|
|
33
35
|
*
|
|
34
|
-
*
|
|
36
|
+
* The same `position` semantics as `column_getIndex` apply.
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
37
39
|
* ```ts
|
|
38
|
-
* const
|
|
40
|
+
* const isFirst = column_getIsFirstColumn(column, 'left')
|
|
39
41
|
* ```
|
|
40
42
|
*/
|
|
41
43
|
function column_getIsFirstColumn(column, position) {
|
|
@@ -43,13 +45,13 @@ function column_getIsFirstColumn(column, position) {
|
|
|
43
45
|
return ((_columns$ = require_columnPinningFeature_utils.table_getPinnedVisibleLeafColumns(column.table, position)[0]) === null || _columns$ === void 0 ? void 0 : _columns$.id) === column.id;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
48
|
+
* Checks whether this column is the last visible column in a pinning region.
|
|
47
49
|
*
|
|
48
|
-
*
|
|
50
|
+
* The same `position` semantics as `column_getIndex` apply.
|
|
49
51
|
*
|
|
50
52
|
* @example
|
|
51
53
|
* ```ts
|
|
52
|
-
* const
|
|
54
|
+
* const isLast = column_getIsLastColumn(column, 'right')
|
|
53
55
|
* ```
|
|
54
56
|
*/
|
|
55
57
|
function column_getIsLastColumn(column, position) {
|
|
@@ -58,13 +60,14 @@ function column_getIsLastColumn(column, position) {
|
|
|
58
60
|
return ((_columns = columns[columns.length - 1]) === null || _columns === void 0 ? void 0 : _columns.id) === column.id;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
|
-
*
|
|
63
|
+
* Routes a column order updater through the table's column-order change handler.
|
|
62
64
|
*
|
|
63
|
-
* The updater
|
|
65
|
+
* The updater may be a next ordered id array or a function of the previous
|
|
66
|
+
* array, matching the instance `table.setColumnOrder` behavior.
|
|
64
67
|
*
|
|
65
68
|
* @example
|
|
66
69
|
* ```ts
|
|
67
|
-
* table_setColumnOrder(table,
|
|
70
|
+
* table_setColumnOrder(table, ['firstName', 'lastName', 'age'])
|
|
68
71
|
* ```
|
|
69
72
|
*/
|
|
70
73
|
function table_setColumnOrder(table, updater) {
|
|
@@ -72,9 +75,10 @@ function table_setColumnOrder(table, updater) {
|
|
|
72
75
|
(_table$options$onColu = (_table$options = table.options).onColumnOrderChange) === null || _table$options$onColu === void 0 || _table$options$onColu.call(_table$options, updater);
|
|
73
76
|
}
|
|
74
77
|
/**
|
|
75
|
-
* Resets the
|
|
78
|
+
* Resets `columnOrder` to the configured initial state or feature default.
|
|
76
79
|
*
|
|
77
|
-
*
|
|
80
|
+
* With no argument, the reset clones `table.initialState.columnOrder` when it
|
|
81
|
+
* exists. Passing `true` ignores initial state and resets to `[]`.
|
|
78
82
|
*
|
|
79
83
|
* @example
|
|
80
84
|
* ```ts
|
|
@@ -86,13 +90,14 @@ function table_resetColumnOrder(table, defaultState) {
|
|
|
86
90
|
table_setColumnOrder(table, defaultState ? [] : require_utils.cloneState(table.initialState.columnOrder ?? []));
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
|
-
*
|
|
93
|
+
* Creates the ordering function used to arrange leaf columns.
|
|
90
94
|
*
|
|
91
|
-
*
|
|
95
|
+
* The returned function applies `state.columnOrder`, preserves unspecified
|
|
96
|
+
* columns in their original order, then delegates to grouping rules.
|
|
92
97
|
*
|
|
93
98
|
* @example
|
|
94
99
|
* ```ts
|
|
95
|
-
* const
|
|
100
|
+
* const orderColumnsForTable = table_getOrderColumnsFn(table)
|
|
96
101
|
* ```
|
|
97
102
|
*/
|
|
98
103
|
function table_getOrderColumnsFn(table) {
|
|
@@ -124,13 +129,15 @@ function table_getOrderColumnsFn(table) {
|
|
|
124
129
|
};
|
|
125
130
|
}
|
|
126
131
|
/**
|
|
127
|
-
*
|
|
132
|
+
* Applies grouped-column placement rules to an already ordered leaf-column list.
|
|
128
133
|
*
|
|
129
|
-
*
|
|
134
|
+
* `groupedColumnMode: 'remove'` drops grouped columns from the list.
|
|
135
|
+
* `groupedColumnMode: 'reorder'` moves grouped columns to the front in grouping
|
|
136
|
+
* state order.
|
|
130
137
|
*
|
|
131
138
|
* @example
|
|
132
139
|
* ```ts
|
|
133
|
-
* const orderedColumns = orderColumns(
|
|
140
|
+
* const orderedColumns = orderColumns(table, leafColumns)
|
|
134
141
|
* ```
|
|
135
142
|
*/
|
|
136
143
|
function orderColumns(table, leafColumns) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnOrderingFeature.utils.cjs","names":["table_getPinnedVisibleLeafColumns","cloneState"],"sources":["../../../src/features/column-ordering/columnOrderingFeature.utils.ts"],"sourcesContent":["import { table_getPinnedVisibleLeafColumns } from '../column-pinning/columnPinningFeature.utils'\nimport { cloneState } from '../../utils'\nimport type { GroupingState } from '../column-grouping/columnGroupingFeature.types'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'\nimport type { ColumnOrderState } from './columnOrderingFeature.types'\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"columnOrderingFeature.utils.cjs","names":["table_getPinnedVisibleLeafColumns","cloneState"],"sources":["../../../src/features/column-ordering/columnOrderingFeature.utils.ts"],"sourcesContent":["import { table_getPinnedVisibleLeafColumns } from '../column-pinning/columnPinningFeature.utils'\nimport { cloneState } from '../../utils'\nimport type { GroupingState } from '../column-grouping/columnGroupingFeature.types'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'\nimport type { ColumnOrderState } from './columnOrderingFeature.types'\n\n/**\n * Creates the default column order state.\n *\n * The feature default is an empty array, meaning leaf columns keep their natural\n * definition order. Reset APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const order = getDefaultColumnOrderState()\n * ```\n */\nexport function getDefaultColumnOrderState(): ColumnOrderState {\n return []\n}\n\n/**\n * Finds this column's index within a visible pinning region.\n *\n * Pass `'left'`, `'center'`, or `'right'` to search that region; omit the\n * position to search the full visible leaf column list.\n *\n * @example\n * ```ts\n * const index = column_getIndex(column, 'center')\n * ```\n */\nexport function column_getIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns.findIndex((d) => d.id === column.id)\n}\n\n/**\n * Checks whether this column is the first visible column in a pinning region.\n *\n * The same `position` semantics as `column_getIndex` apply.\n *\n * @example\n * ```ts\n * const isFirst = column_getIsFirstColumn(column, 'left')\n * ```\n */\nexport function column_getIsFirstColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[0]?.id === column.id\n}\n\n/**\n * Checks whether this column is the last visible column in a pinning region.\n *\n * The same `position` semantics as `column_getIndex` apply.\n *\n * @example\n * ```ts\n * const isLast = column_getIsLastColumn(column, 'right')\n * ```\n */\nexport function column_getIsLastColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[columns.length - 1]?.id === column.id\n}\n\n/**\n * Routes a column order updater through the table's column-order change handler.\n *\n * The updater may be a next ordered id array or a function of the previous\n * array, matching the instance `table.setColumnOrder` behavior.\n *\n * @example\n * ```ts\n * table_setColumnOrder(table, ['firstName', 'lastName', 'age'])\n * ```\n */\nexport function table_setColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnOrderState>) {\n table.options.onColumnOrderChange?.(updater)\n}\n\n/**\n * Resets `columnOrder` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.columnOrder` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetColumnOrder(table)\n * table_resetColumnOrder(table, true)\n * ```\n */\nexport function table_resetColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnOrder(\n table,\n defaultState ? [] : cloneState(table.initialState.columnOrder ?? []),\n )\n}\n\n/**\n * Creates the ordering function used to arrange leaf columns.\n *\n * The returned function applies `state.columnOrder`, preserves unspecified\n * columns in their original order, then delegates to grouping rules.\n *\n * @example\n * ```ts\n * const orderColumnsForTable = table_getOrderColumnsFn(table)\n * ```\n */\nexport function table_getOrderColumnsFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const columnOrder = table.atoms.columnOrder?.get()\n\n return (columns: Array<Column_Internal<TFeatures, TData, unknown>>) => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n // Index columns by id for O(1) lookup\n const remaining = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n remaining.set(column.id, column)\n }\n\n // Place columns in the requested order, removing each as it's used\n // (handles duplicates and unknown ids in columnOrder)\n for (let i = 0; i < columnOrder.length; i++) {\n const id = columnOrder[i]!\n const column = remaining.get(id)\n if (column) {\n orderedColumns.push(column)\n remaining.delete(id)\n }\n }\n\n // Append leftover columns in their original order\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n if (remaining.has(column.id)) orderedColumns.push(column)\n }\n }\n\n return orderColumns(table, orderedColumns)\n }\n}\n\n/**\n * Applies grouped-column placement rules to an already ordered leaf-column list.\n *\n * `groupedColumnMode: 'remove'` drops grouped columns from the list.\n * `groupedColumnMode: 'reorder'` moves grouped columns to the front in grouping\n * state order.\n *\n * @example\n * ```ts\n * const orderedColumns = orderColumns(table, leafColumns)\n * ```\n */\nexport function orderColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n leafColumns: Array<Column_Internal<TFeatures, TData, unknown>>,\n) {\n const grouping = table.atoms.grouping?.get() ?? ([] as GroupingState)\n const { groupedColumnMode } = table.options\n\n if (!grouping.length || !groupedColumnMode) {\n return leafColumns\n }\n\n const nonGroupingColumns = leafColumns.filter(\n (col) => !grouping.includes(col.id),\n )\n\n if (groupedColumnMode === 'remove') {\n return nonGroupingColumns\n }\n\n const leafColumnsById = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (let i = 0; i < leafColumns.length; i++) {\n const col = leafColumns[i]!\n leafColumnsById.set(col.id, col)\n }\n\n const groupingColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n for (let i = 0; i < grouping.length; i++) {\n const col = leafColumnsById.get(grouping[i]!)\n if (col) groupingColumns.push(col)\n }\n\n return [...groupingColumns, ...nonGroupingColumns]\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,6BAA+C;CAC7D,OAAO,EAAE;;;;;;;;;;;;;AAcX,SAAgB,gBAKd,QACA,UACA;CAEA,OADgBA,qEAAkC,OAAO,OAAO,SAClD,CAAC,WAAW,MAAM,EAAE,OAAO,OAAO,GAAG;;;;;;;;;;;;AAarD,SAAgB,wBAKd,QACA,UACA;;CAEA,qBADgBA,qEAAkC,OAAO,OAAO,SAClD,CAAC,0DAAI,QAAO,OAAO;;;;;;;;;;;;AAanC,SAAgB,uBAKd,QACA,UACA;;CACA,MAAM,UAAUA,qEAAkC,OAAO,OAAO,SAAS;CACzE,oBAAO,QAAQ,QAAQ,SAAS,wDAAI,QAAO,OAAO;;;;;;;;;;;;;AAcpD,SAAgB,qBAGd,OAAyC,SAAoC;;CAC7E,iDAAM,SAAQ,gHAAsB,QAAQ;;;;;;;;;;;;;;AAe9C,SAAgB,uBAGd,OAAyC,cAAwB;CACjE,qBACE,OACA,eAAe,EAAE,GAAGC,yBAAW,MAAM,aAAa,eAAe,EAAE,CAAC,CACrE;;;;;;;;;;;;;AAcH,SAAgB,wBAGd,OAAyC;;CACzC,MAAM,uCAAc,MAAM,MAAM,2FAAa,KAAK;CAElD,QAAQ,YAA+D;EAGrE,IAAI,iBAAoE,EAAE;EAG1E,IAAI,4DAAC,YAAa,SAChB,iBAAiB;OACZ;GAEL,MAAM,4BAAY,IAAI,KAGnB;GACH,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;IACvC,MAAM,SAAS,QAAQ;IACvB,UAAU,IAAI,OAAO,IAAI,OAAO;;GAKlC,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;IAC3C,MAAM,KAAK,YAAY;IACvB,MAAM,SAAS,UAAU,IAAI,GAAG;IAChC,IAAI,QAAQ;KACV,eAAe,KAAK,OAAO;KAC3B,UAAU,OAAO,GAAG;;;GAKxB,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;IACvC,MAAM,SAAS,QAAQ;IACvB,IAAI,UAAU,IAAI,OAAO,GAAG,EAAE,eAAe,KAAK,OAAO;;;EAI7D,OAAO,aAAa,OAAO,eAAe;;;;;;;;;;;;;;;AAgB9C,SAAgB,aAId,OACA,aACA;;CACA,MAAM,qCAAW,MAAM,MAAM,wFAAU,KAAK,KAAK,EAAE;CACnD,MAAM,EAAE,sBAAsB,MAAM;CAEpC,IAAI,CAAC,SAAS,UAAU,CAAC,mBACvB,OAAO;CAGT,MAAM,qBAAqB,YAAY,QACpC,QAAQ,CAAC,SAAS,SAAS,IAAI,GAAG,CACpC;CAED,IAAI,sBAAsB,UACxB,OAAO;CAGT,MAAM,kCAAkB,IAAI,KAGzB;CACH,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,MAAM,YAAY;EACxB,gBAAgB,IAAI,IAAI,IAAI,IAAI;;CAGlC,MAAM,kBAAqE,EAAE;CAC7E,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,MAAM,gBAAgB,IAAI,SAAS,GAAI;EAC7C,IAAI,KAAK,gBAAgB,KAAK,IAAI;;CAGpC,OAAO,CAAC,GAAG,iBAAiB,GAAG,mBAAmB"}
|
|
@@ -7,64 +7,68 @@ import { Table_Internal } from "../../types/Table.cjs";
|
|
|
7
7
|
|
|
8
8
|
//#region src/features/column-ordering/columnOrderingFeature.utils.d.ts
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Creates the default column order state.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* The feature default is an empty array, meaning leaf columns keep their natural
|
|
13
|
+
* definition order. Reset APIs use this value when `defaultState` is `true`.
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* ```ts
|
|
16
|
-
* const
|
|
17
|
+
* const order = getDefaultColumnOrderState()
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
20
|
declare function getDefaultColumnOrderState(): ColumnOrderState;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Finds this column's index within a visible pinning region.
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
+
* Pass `'left'`, `'center'`, or `'right'` to search that region; omit the
|
|
25
|
+
* position to search the full visible leaf column list.
|
|
24
26
|
*
|
|
25
27
|
* @example
|
|
26
28
|
* ```ts
|
|
27
|
-
* const
|
|
29
|
+
* const index = column_getIndex(column, 'center')
|
|
28
30
|
* ```
|
|
29
31
|
*/
|
|
30
32
|
declare function column_getIndex<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>, position?: ColumnPinningPosition | 'center'): number;
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Checks whether this column is the first visible column in a pinning region.
|
|
33
35
|
*
|
|
34
|
-
*
|
|
36
|
+
* The same `position` semantics as `column_getIndex` apply.
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
37
39
|
* ```ts
|
|
38
|
-
* const
|
|
40
|
+
* const isFirst = column_getIsFirstColumn(column, 'left')
|
|
39
41
|
* ```
|
|
40
42
|
*/
|
|
41
43
|
declare function column_getIsFirstColumn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>, position?: ColumnPinningPosition | 'center'): boolean;
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
45
|
+
* Checks whether this column is the last visible column in a pinning region.
|
|
44
46
|
*
|
|
45
|
-
*
|
|
47
|
+
* The same `position` semantics as `column_getIndex` apply.
|
|
46
48
|
*
|
|
47
49
|
* @example
|
|
48
50
|
* ```ts
|
|
49
|
-
* const
|
|
51
|
+
* const isLast = column_getIsLastColumn(column, 'right')
|
|
50
52
|
* ```
|
|
51
53
|
*/
|
|
52
54
|
declare function column_getIsLastColumn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>, position?: ColumnPinningPosition | 'center'): boolean;
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
56
|
+
* Routes a column order updater through the table's column-order change handler.
|
|
55
57
|
*
|
|
56
|
-
* The updater
|
|
58
|
+
* The updater may be a next ordered id array or a function of the previous
|
|
59
|
+
* array, matching the instance `table.setColumnOrder` behavior.
|
|
57
60
|
*
|
|
58
61
|
* @example
|
|
59
62
|
* ```ts
|
|
60
|
-
* table_setColumnOrder(table,
|
|
63
|
+
* table_setColumnOrder(table, ['firstName', 'lastName', 'age'])
|
|
61
64
|
* ```
|
|
62
65
|
*/
|
|
63
66
|
declare function table_setColumnOrder<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnOrderState>): void;
|
|
64
67
|
/**
|
|
65
|
-
* Resets the
|
|
68
|
+
* Resets `columnOrder` to the configured initial state or feature default.
|
|
66
69
|
*
|
|
67
|
-
*
|
|
70
|
+
* With no argument, the reset clones `table.initialState.columnOrder` when it
|
|
71
|
+
* exists. Passing `true` ignores initial state and resets to `[]`.
|
|
68
72
|
*
|
|
69
73
|
* @example
|
|
70
74
|
* ```ts
|
|
@@ -74,24 +78,27 @@ declare function table_setColumnOrder<TFeatures extends TableFeatures, TData ext
|
|
|
74
78
|
*/
|
|
75
79
|
declare function table_resetColumnOrder<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
|
|
76
80
|
/**
|
|
77
|
-
*
|
|
81
|
+
* Creates the ordering function used to arrange leaf columns.
|
|
78
82
|
*
|
|
79
|
-
*
|
|
83
|
+
* The returned function applies `state.columnOrder`, preserves unspecified
|
|
84
|
+
* columns in their original order, then delegates to grouping rules.
|
|
80
85
|
*
|
|
81
86
|
* @example
|
|
82
87
|
* ```ts
|
|
83
|
-
* const
|
|
88
|
+
* const orderColumnsForTable = table_getOrderColumnsFn(table)
|
|
84
89
|
* ```
|
|
85
90
|
*/
|
|
86
91
|
declare function table_getOrderColumnsFn<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): (columns: Array<Column_Internal<TFeatures, TData, unknown>>) => Column_Internal<TFeatures, TData, unknown>[];
|
|
87
92
|
/**
|
|
88
|
-
*
|
|
93
|
+
* Applies grouped-column placement rules to an already ordered leaf-column list.
|
|
89
94
|
*
|
|
90
|
-
*
|
|
95
|
+
* `groupedColumnMode: 'remove'` drops grouped columns from the list.
|
|
96
|
+
* `groupedColumnMode: 'reorder'` moves grouped columns to the front in grouping
|
|
97
|
+
* state order.
|
|
91
98
|
*
|
|
92
99
|
* @example
|
|
93
100
|
* ```ts
|
|
94
|
-
* const orderedColumns = orderColumns(
|
|
101
|
+
* const orderedColumns = orderColumns(table, leafColumns)
|
|
95
102
|
* ```
|
|
96
103
|
*/
|
|
97
104
|
declare function orderColumns<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, leafColumns: Array<Column_Internal<TFeatures, TData, unknown>>): Column_Internal<TFeatures, TData, unknown>[];
|
|
@@ -7,64 +7,68 @@ import { Table_Internal } from "../../types/Table.js";
|
|
|
7
7
|
|
|
8
8
|
//#region src/features/column-ordering/columnOrderingFeature.utils.d.ts
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Creates the default column order state.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* The feature default is an empty array, meaning leaf columns keep their natural
|
|
13
|
+
* definition order. Reset APIs use this value when `defaultState` is `true`.
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* ```ts
|
|
16
|
-
* const
|
|
17
|
+
* const order = getDefaultColumnOrderState()
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
20
|
declare function getDefaultColumnOrderState(): ColumnOrderState;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Finds this column's index within a visible pinning region.
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
+
* Pass `'left'`, `'center'`, or `'right'` to search that region; omit the
|
|
25
|
+
* position to search the full visible leaf column list.
|
|
24
26
|
*
|
|
25
27
|
* @example
|
|
26
28
|
* ```ts
|
|
27
|
-
* const
|
|
29
|
+
* const index = column_getIndex(column, 'center')
|
|
28
30
|
* ```
|
|
29
31
|
*/
|
|
30
32
|
declare function column_getIndex<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>, position?: ColumnPinningPosition | 'center'): number;
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Checks whether this column is the first visible column in a pinning region.
|
|
33
35
|
*
|
|
34
|
-
*
|
|
36
|
+
* The same `position` semantics as `column_getIndex` apply.
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
37
39
|
* ```ts
|
|
38
|
-
* const
|
|
40
|
+
* const isFirst = column_getIsFirstColumn(column, 'left')
|
|
39
41
|
* ```
|
|
40
42
|
*/
|
|
41
43
|
declare function column_getIsFirstColumn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>, position?: ColumnPinningPosition | 'center'): boolean;
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
45
|
+
* Checks whether this column is the last visible column in a pinning region.
|
|
44
46
|
*
|
|
45
|
-
*
|
|
47
|
+
* The same `position` semantics as `column_getIndex` apply.
|
|
46
48
|
*
|
|
47
49
|
* @example
|
|
48
50
|
* ```ts
|
|
49
|
-
* const
|
|
51
|
+
* const isLast = column_getIsLastColumn(column, 'right')
|
|
50
52
|
* ```
|
|
51
53
|
*/
|
|
52
54
|
declare function column_getIsLastColumn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>, position?: ColumnPinningPosition | 'center'): boolean;
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
56
|
+
* Routes a column order updater through the table's column-order change handler.
|
|
55
57
|
*
|
|
56
|
-
* The updater
|
|
58
|
+
* The updater may be a next ordered id array or a function of the previous
|
|
59
|
+
* array, matching the instance `table.setColumnOrder` behavior.
|
|
57
60
|
*
|
|
58
61
|
* @example
|
|
59
62
|
* ```ts
|
|
60
|
-
* table_setColumnOrder(table,
|
|
63
|
+
* table_setColumnOrder(table, ['firstName', 'lastName', 'age'])
|
|
61
64
|
* ```
|
|
62
65
|
*/
|
|
63
66
|
declare function table_setColumnOrder<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnOrderState>): void;
|
|
64
67
|
/**
|
|
65
|
-
* Resets the
|
|
68
|
+
* Resets `columnOrder` to the configured initial state or feature default.
|
|
66
69
|
*
|
|
67
|
-
*
|
|
70
|
+
* With no argument, the reset clones `table.initialState.columnOrder` when it
|
|
71
|
+
* exists. Passing `true` ignores initial state and resets to `[]`.
|
|
68
72
|
*
|
|
69
73
|
* @example
|
|
70
74
|
* ```ts
|
|
@@ -74,24 +78,27 @@ declare function table_setColumnOrder<TFeatures extends TableFeatures, TData ext
|
|
|
74
78
|
*/
|
|
75
79
|
declare function table_resetColumnOrder<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
|
|
76
80
|
/**
|
|
77
|
-
*
|
|
81
|
+
* Creates the ordering function used to arrange leaf columns.
|
|
78
82
|
*
|
|
79
|
-
*
|
|
83
|
+
* The returned function applies `state.columnOrder`, preserves unspecified
|
|
84
|
+
* columns in their original order, then delegates to grouping rules.
|
|
80
85
|
*
|
|
81
86
|
* @example
|
|
82
87
|
* ```ts
|
|
83
|
-
* const
|
|
88
|
+
* const orderColumnsForTable = table_getOrderColumnsFn(table)
|
|
84
89
|
* ```
|
|
85
90
|
*/
|
|
86
91
|
declare function table_getOrderColumnsFn<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): (columns: Array<Column_Internal<TFeatures, TData, unknown>>) => Column_Internal<TFeatures, TData, unknown>[];
|
|
87
92
|
/**
|
|
88
|
-
*
|
|
93
|
+
* Applies grouped-column placement rules to an already ordered leaf-column list.
|
|
89
94
|
*
|
|
90
|
-
*
|
|
95
|
+
* `groupedColumnMode: 'remove'` drops grouped columns from the list.
|
|
96
|
+
* `groupedColumnMode: 'reorder'` moves grouped columns to the front in grouping
|
|
97
|
+
* state order.
|
|
91
98
|
*
|
|
92
99
|
* @example
|
|
93
100
|
* ```ts
|
|
94
|
-
* const orderedColumns = orderColumns(
|
|
101
|
+
* const orderedColumns = orderColumns(table, leafColumns)
|
|
95
102
|
* ```
|
|
96
103
|
*/
|
|
97
104
|
declare function orderColumns<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, leafColumns: Array<Column_Internal<TFeatures, TData, unknown>>): Column_Internal<TFeatures, TData, unknown>[];
|
|
@@ -3,39 +3,41 @@ import { table_getPinnedVisibleLeafColumns } from "../column-pinning/columnPinni
|
|
|
3
3
|
|
|
4
4
|
//#region src/features/column-ordering/columnOrderingFeature.utils.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Creates the default column order state.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* The feature default is an empty array, meaning leaf columns keep their natural
|
|
9
|
+
* definition order. Reset APIs use this value when `defaultState` is `true`.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
* ```ts
|
|
12
|
-
* const
|
|
13
|
+
* const order = getDefaultColumnOrderState()
|
|
13
14
|
* ```
|
|
14
15
|
*/
|
|
15
16
|
function getDefaultColumnOrderState() {
|
|
16
17
|
return [];
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* Finds this column's index within a visible pinning region.
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
+
* Pass `'left'`, `'center'`, or `'right'` to search that region; omit the
|
|
23
|
+
* position to search the full visible leaf column list.
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
24
26
|
* ```ts
|
|
25
|
-
* const
|
|
27
|
+
* const index = column_getIndex(column, 'center')
|
|
26
28
|
* ```
|
|
27
29
|
*/
|
|
28
30
|
function column_getIndex(column, position) {
|
|
29
31
|
return table_getPinnedVisibleLeafColumns(column.table, position).findIndex((d) => d.id === column.id);
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Checks whether this column is the first visible column in a pinning region.
|
|
33
35
|
*
|
|
34
|
-
*
|
|
36
|
+
* The same `position` semantics as `column_getIndex` apply.
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
37
39
|
* ```ts
|
|
38
|
-
* const
|
|
40
|
+
* const isFirst = column_getIsFirstColumn(column, 'left')
|
|
39
41
|
* ```
|
|
40
42
|
*/
|
|
41
43
|
function column_getIsFirstColumn(column, position) {
|
|
@@ -43,13 +45,13 @@ function column_getIsFirstColumn(column, position) {
|
|
|
43
45
|
return ((_columns$ = table_getPinnedVisibleLeafColumns(column.table, position)[0]) === null || _columns$ === void 0 ? void 0 : _columns$.id) === column.id;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
48
|
+
* Checks whether this column is the last visible column in a pinning region.
|
|
47
49
|
*
|
|
48
|
-
*
|
|
50
|
+
* The same `position` semantics as `column_getIndex` apply.
|
|
49
51
|
*
|
|
50
52
|
* @example
|
|
51
53
|
* ```ts
|
|
52
|
-
* const
|
|
54
|
+
* const isLast = column_getIsLastColumn(column, 'right')
|
|
53
55
|
* ```
|
|
54
56
|
*/
|
|
55
57
|
function column_getIsLastColumn(column, position) {
|
|
@@ -58,13 +60,14 @@ function column_getIsLastColumn(column, position) {
|
|
|
58
60
|
return ((_columns = columns[columns.length - 1]) === null || _columns === void 0 ? void 0 : _columns.id) === column.id;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
|
-
*
|
|
63
|
+
* Routes a column order updater through the table's column-order change handler.
|
|
62
64
|
*
|
|
63
|
-
* The updater
|
|
65
|
+
* The updater may be a next ordered id array or a function of the previous
|
|
66
|
+
* array, matching the instance `table.setColumnOrder` behavior.
|
|
64
67
|
*
|
|
65
68
|
* @example
|
|
66
69
|
* ```ts
|
|
67
|
-
* table_setColumnOrder(table,
|
|
70
|
+
* table_setColumnOrder(table, ['firstName', 'lastName', 'age'])
|
|
68
71
|
* ```
|
|
69
72
|
*/
|
|
70
73
|
function table_setColumnOrder(table, updater) {
|
|
@@ -72,9 +75,10 @@ function table_setColumnOrder(table, updater) {
|
|
|
72
75
|
(_table$options$onColu = (_table$options = table.options).onColumnOrderChange) === null || _table$options$onColu === void 0 || _table$options$onColu.call(_table$options, updater);
|
|
73
76
|
}
|
|
74
77
|
/**
|
|
75
|
-
* Resets the
|
|
78
|
+
* Resets `columnOrder` to the configured initial state or feature default.
|
|
76
79
|
*
|
|
77
|
-
*
|
|
80
|
+
* With no argument, the reset clones `table.initialState.columnOrder` when it
|
|
81
|
+
* exists. Passing `true` ignores initial state and resets to `[]`.
|
|
78
82
|
*
|
|
79
83
|
* @example
|
|
80
84
|
* ```ts
|
|
@@ -86,13 +90,14 @@ function table_resetColumnOrder(table, defaultState) {
|
|
|
86
90
|
table_setColumnOrder(table, defaultState ? [] : cloneState(table.initialState.columnOrder ?? []));
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
|
-
*
|
|
93
|
+
* Creates the ordering function used to arrange leaf columns.
|
|
90
94
|
*
|
|
91
|
-
*
|
|
95
|
+
* The returned function applies `state.columnOrder`, preserves unspecified
|
|
96
|
+
* columns in their original order, then delegates to grouping rules.
|
|
92
97
|
*
|
|
93
98
|
* @example
|
|
94
99
|
* ```ts
|
|
95
|
-
* const
|
|
100
|
+
* const orderColumnsForTable = table_getOrderColumnsFn(table)
|
|
96
101
|
* ```
|
|
97
102
|
*/
|
|
98
103
|
function table_getOrderColumnsFn(table) {
|
|
@@ -124,13 +129,15 @@ function table_getOrderColumnsFn(table) {
|
|
|
124
129
|
};
|
|
125
130
|
}
|
|
126
131
|
/**
|
|
127
|
-
*
|
|
132
|
+
* Applies grouped-column placement rules to an already ordered leaf-column list.
|
|
128
133
|
*
|
|
129
|
-
*
|
|
134
|
+
* `groupedColumnMode: 'remove'` drops grouped columns from the list.
|
|
135
|
+
* `groupedColumnMode: 'reorder'` moves grouped columns to the front in grouping
|
|
136
|
+
* state order.
|
|
130
137
|
*
|
|
131
138
|
* @example
|
|
132
139
|
* ```ts
|
|
133
|
-
* const orderedColumns = orderColumns(
|
|
140
|
+
* const orderedColumns = orderColumns(table, leafColumns)
|
|
134
141
|
* ```
|
|
135
142
|
*/
|
|
136
143
|
function orderColumns(table, leafColumns) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnOrderingFeature.utils.js","names":[],"sources":["../../../src/features/column-ordering/columnOrderingFeature.utils.ts"],"sourcesContent":["import { table_getPinnedVisibleLeafColumns } from '../column-pinning/columnPinningFeature.utils'\nimport { cloneState } from '../../utils'\nimport type { GroupingState } from '../column-grouping/columnGroupingFeature.types'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'\nimport type { ColumnOrderState } from './columnOrderingFeature.types'\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"columnOrderingFeature.utils.js","names":[],"sources":["../../../src/features/column-ordering/columnOrderingFeature.utils.ts"],"sourcesContent":["import { table_getPinnedVisibleLeafColumns } from '../column-pinning/columnPinningFeature.utils'\nimport { cloneState } from '../../utils'\nimport type { GroupingState } from '../column-grouping/columnGroupingFeature.types'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'\nimport type { ColumnOrderState } from './columnOrderingFeature.types'\n\n/**\n * Creates the default column order state.\n *\n * The feature default is an empty array, meaning leaf columns keep their natural\n * definition order. Reset APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const order = getDefaultColumnOrderState()\n * ```\n */\nexport function getDefaultColumnOrderState(): ColumnOrderState {\n return []\n}\n\n/**\n * Finds this column's index within a visible pinning region.\n *\n * Pass `'left'`, `'center'`, or `'right'` to search that region; omit the\n * position to search the full visible leaf column list.\n *\n * @example\n * ```ts\n * const index = column_getIndex(column, 'center')\n * ```\n */\nexport function column_getIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns.findIndex((d) => d.id === column.id)\n}\n\n/**\n * Checks whether this column is the first visible column in a pinning region.\n *\n * The same `position` semantics as `column_getIndex` apply.\n *\n * @example\n * ```ts\n * const isFirst = column_getIsFirstColumn(column, 'left')\n * ```\n */\nexport function column_getIsFirstColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[0]?.id === column.id\n}\n\n/**\n * Checks whether this column is the last visible column in a pinning region.\n *\n * The same `position` semantics as `column_getIndex` apply.\n *\n * @example\n * ```ts\n * const isLast = column_getIsLastColumn(column, 'right')\n * ```\n */\nexport function column_getIsLastColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[columns.length - 1]?.id === column.id\n}\n\n/**\n * Routes a column order updater through the table's column-order change handler.\n *\n * The updater may be a next ordered id array or a function of the previous\n * array, matching the instance `table.setColumnOrder` behavior.\n *\n * @example\n * ```ts\n * table_setColumnOrder(table, ['firstName', 'lastName', 'age'])\n * ```\n */\nexport function table_setColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnOrderState>) {\n table.options.onColumnOrderChange?.(updater)\n}\n\n/**\n * Resets `columnOrder` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.columnOrder` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetColumnOrder(table)\n * table_resetColumnOrder(table, true)\n * ```\n */\nexport function table_resetColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnOrder(\n table,\n defaultState ? [] : cloneState(table.initialState.columnOrder ?? []),\n )\n}\n\n/**\n * Creates the ordering function used to arrange leaf columns.\n *\n * The returned function applies `state.columnOrder`, preserves unspecified\n * columns in their original order, then delegates to grouping rules.\n *\n * @example\n * ```ts\n * const orderColumnsForTable = table_getOrderColumnsFn(table)\n * ```\n */\nexport function table_getOrderColumnsFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const columnOrder = table.atoms.columnOrder?.get()\n\n return (columns: Array<Column_Internal<TFeatures, TData, unknown>>) => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n // Index columns by id for O(1) lookup\n const remaining = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n remaining.set(column.id, column)\n }\n\n // Place columns in the requested order, removing each as it's used\n // (handles duplicates and unknown ids in columnOrder)\n for (let i = 0; i < columnOrder.length; i++) {\n const id = columnOrder[i]!\n const column = remaining.get(id)\n if (column) {\n orderedColumns.push(column)\n remaining.delete(id)\n }\n }\n\n // Append leftover columns in their original order\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n if (remaining.has(column.id)) orderedColumns.push(column)\n }\n }\n\n return orderColumns(table, orderedColumns)\n }\n}\n\n/**\n * Applies grouped-column placement rules to an already ordered leaf-column list.\n *\n * `groupedColumnMode: 'remove'` drops grouped columns from the list.\n * `groupedColumnMode: 'reorder'` moves grouped columns to the front in grouping\n * state order.\n *\n * @example\n * ```ts\n * const orderedColumns = orderColumns(table, leafColumns)\n * ```\n */\nexport function orderColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n leafColumns: Array<Column_Internal<TFeatures, TData, unknown>>,\n) {\n const grouping = table.atoms.grouping?.get() ?? ([] as GroupingState)\n const { groupedColumnMode } = table.options\n\n if (!grouping.length || !groupedColumnMode) {\n return leafColumns\n }\n\n const nonGroupingColumns = leafColumns.filter(\n (col) => !grouping.includes(col.id),\n )\n\n if (groupedColumnMode === 'remove') {\n return nonGroupingColumns\n }\n\n const leafColumnsById = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (let i = 0; i < leafColumns.length; i++) {\n const col = leafColumns[i]!\n leafColumnsById.set(col.id, col)\n }\n\n const groupingColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n for (let i = 0; i < grouping.length; i++) {\n const col = leafColumnsById.get(grouping[i]!)\n if (col) groupingColumns.push(col)\n }\n\n return [...groupingColumns, ...nonGroupingColumns]\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,6BAA+C;CAC7D,OAAO,EAAE;;;;;;;;;;;;;AAcX,SAAgB,gBAKd,QACA,UACA;CAEA,OADgB,kCAAkC,OAAO,OAAO,SAClD,CAAC,WAAW,MAAM,EAAE,OAAO,OAAO,GAAG;;;;;;;;;;;;AAarD,SAAgB,wBAKd,QACA,UACA;;CAEA,qBADgB,kCAAkC,OAAO,OAAO,SAClD,CAAC,0DAAI,QAAO,OAAO;;;;;;;;;;;;AAanC,SAAgB,uBAKd,QACA,UACA;;CACA,MAAM,UAAU,kCAAkC,OAAO,OAAO,SAAS;CACzE,oBAAO,QAAQ,QAAQ,SAAS,wDAAI,QAAO,OAAO;;;;;;;;;;;;;AAcpD,SAAgB,qBAGd,OAAyC,SAAoC;;CAC7E,iDAAM,SAAQ,gHAAsB,QAAQ;;;;;;;;;;;;;;AAe9C,SAAgB,uBAGd,OAAyC,cAAwB;CACjE,qBACE,OACA,eAAe,EAAE,GAAG,WAAW,MAAM,aAAa,eAAe,EAAE,CAAC,CACrE;;;;;;;;;;;;;AAcH,SAAgB,wBAGd,OAAyC;;CACzC,MAAM,uCAAc,MAAM,MAAM,2FAAa,KAAK;CAElD,QAAQ,YAA+D;EAGrE,IAAI,iBAAoE,EAAE;EAG1E,IAAI,4DAAC,YAAa,SAChB,iBAAiB;OACZ;GAEL,MAAM,4BAAY,IAAI,KAGnB;GACH,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;IACvC,MAAM,SAAS,QAAQ;IACvB,UAAU,IAAI,OAAO,IAAI,OAAO;;GAKlC,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;IAC3C,MAAM,KAAK,YAAY;IACvB,MAAM,SAAS,UAAU,IAAI,GAAG;IAChC,IAAI,QAAQ;KACV,eAAe,KAAK,OAAO;KAC3B,UAAU,OAAO,GAAG;;;GAKxB,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;IACvC,MAAM,SAAS,QAAQ;IACvB,IAAI,UAAU,IAAI,OAAO,GAAG,EAAE,eAAe,KAAK,OAAO;;;EAI7D,OAAO,aAAa,OAAO,eAAe;;;;;;;;;;;;;;;AAgB9C,SAAgB,aAId,OACA,aACA;;CACA,MAAM,qCAAW,MAAM,MAAM,wFAAU,KAAK,KAAK,EAAE;CACnD,MAAM,EAAE,sBAAsB,MAAM;CAEpC,IAAI,CAAC,SAAS,UAAU,CAAC,mBACvB,OAAO;CAGT,MAAM,qBAAqB,YAAY,QACpC,QAAQ,CAAC,SAAS,SAAS,IAAI,GAAG,CACpC;CAED,IAAI,sBAAsB,UACxB,OAAO;CAGT,MAAM,kCAAkB,IAAI,KAGzB;CACH,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,MAAM,YAAY;EACxB,gBAAgB,IAAI,IAAI,IAAI,IAAI;;CAGlC,MAAM,kBAAqE,EAAE;CAC7E,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,MAAM,gBAAgB,IAAI,SAAS,GAAI;EAC7C,IAAI,KAAK,gBAAgB,KAAK,IAAI;;CAGpC,OAAO,CAAC,GAAG,iBAAiB,GAAG,mBAAmB"}
|