@tanstack/table-core 9.0.0-beta.27 → 9.0.0-beta.28

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.
@@ -41,9 +41,12 @@ interface Table_RowModels_Faceted<in out TFeatures extends TableFeatures, in out
41
41
  getFacetedUniqueValues: () => Map<any, number>;
42
42
  }
43
43
  interface CachedRowModel_Faceted<in out TFeatures extends TableFeatures, in out TData extends RowData> {
44
- facetedRowModel?: (columnId: string) => () => RowModel<TFeatures, TData>;
45
- facetedMinMaxValues?: (columnId: string) => [number, number];
46
- facetedUniqueValues?: (columnId: string) => Map<any, number>;
44
+ facetedRowModels?: Record<string, () => RowModel<TFeatures, TData>>;
45
+ facetedMinMaxValues?: Record<string, () => undefined | [number, number]>;
46
+ facetedUniqueValues?: Record<string, () => Map<any, number>>;
47
+ globalFacetedRowModel?: () => RowModel<TFeatures, TData>;
48
+ globalFacetedMinMaxValues?: () => undefined | [number, number];
49
+ globalFacetedUniqueValues?: () => Map<any, number>;
47
50
  }
48
51
  interface Table_ColumnFaceting<in out TFeatures extends TableFeatures, in out TData extends RowData> {
49
52
  /**
@@ -41,9 +41,12 @@ interface Table_RowModels_Faceted<in out TFeatures extends TableFeatures, in out
41
41
  getFacetedUniqueValues: () => Map<any, number>;
42
42
  }
43
43
  interface CachedRowModel_Faceted<in out TFeatures extends TableFeatures, in out TData extends RowData> {
44
- facetedRowModel?: (columnId: string) => () => RowModel<TFeatures, TData>;
45
- facetedMinMaxValues?: (columnId: string) => [number, number];
46
- facetedUniqueValues?: (columnId: string) => Map<any, number>;
44
+ facetedRowModels?: Record<string, () => RowModel<TFeatures, TData>>;
45
+ facetedMinMaxValues?: Record<string, () => undefined | [number, number]>;
46
+ facetedUniqueValues?: Record<string, () => Map<any, number>>;
47
+ globalFacetedRowModel?: () => RowModel<TFeatures, TData>;
48
+ globalFacetedMinMaxValues?: () => undefined | [number, number];
49
+ globalFacetedUniqueValues?: () => Map<any, number>;
47
50
  }
48
51
  interface Table_ColumnFaceting<in out TFeatures extends TableFeatures, in out TData extends RowData> {
49
52
  /**
@@ -1,3 +1,4 @@
1
+ const require_utils = require('../../utils.cjs');
1
2
 
2
3
  //#region src/features/column-faceting/columnFacetingFeature.utils.ts
3
4
  /**
@@ -12,8 +13,13 @@
12
13
  * ```
13
14
  */
14
15
  function column_getFacetedMinMaxValues(column, table) {
15
- var _table$options$featur, _table$options$featur2;
16
- return (((_table$options$featur = (_table$options$featur2 = table.options.features).facetedMinMaxValues) === null || _table$options$featur === void 0 ? void 0 : _table$options$featur.call(_table$options$featur2, table, column.id)) ?? (() => void 0))();
16
+ const facetedMinMaxValues = table._rowModels.facetedMinMaxValues ??= require_utils.makeObjectMap();
17
+ let facetedMinMaxValuesFn = facetedMinMaxValues[column.id];
18
+ if (!facetedMinMaxValuesFn) {
19
+ var _table$options$featur, _table$options$featur2;
20
+ facetedMinMaxValuesFn = facetedMinMaxValues[column.id] = ((_table$options$featur = (_table$options$featur2 = table.options.features).facetedMinMaxValues) === null || _table$options$featur === void 0 ? void 0 : _table$options$featur.call(_table$options$featur2, table, column.id)) ?? (() => void 0);
21
+ }
22
+ return facetedMinMaxValuesFn();
17
23
  }
18
24
  /**
19
25
  * Computes the row model used to derive one column's facet values.
@@ -28,8 +34,14 @@ function column_getFacetedMinMaxValues(column, table) {
28
34
  * ```
29
35
  */
30
36
  function column_getFacetedRowModel(column, table) {
31
- var _table$options$featur3, _table$options$featur4;
32
- return (((_table$options$featur3 = (_table$options$featur4 = table.options.features).facetedRowModel) === null || _table$options$featur3 === void 0 ? void 0 : _table$options$featur3.call(_table$options$featur4, table, (column === null || column === void 0 ? void 0 : column.id) ?? "")) ?? (() => table.getPreFilteredRowModel()))();
37
+ const columnId = (column === null || column === void 0 ? void 0 : column.id) ?? "";
38
+ const facetedRowModels = table._rowModels.facetedRowModels ??= require_utils.makeObjectMap();
39
+ let facetedRowModelFn = facetedRowModels[columnId];
40
+ if (!facetedRowModelFn) {
41
+ var _table$options$featur3, _table$options$featur4;
42
+ facetedRowModelFn = facetedRowModels[columnId] = ((_table$options$featur3 = (_table$options$featur4 = table.options.features).facetedRowModel) === null || _table$options$featur3 === void 0 ? void 0 : _table$options$featur3.call(_table$options$featur4, table, columnId)) ?? (() => table.getPreFilteredRowModel());
43
+ }
44
+ return facetedRowModelFn();
33
45
  }
34
46
  /**
35
47
  * Computes unique facet values and their occurrence counts for one column.
@@ -43,8 +55,13 @@ function column_getFacetedRowModel(column, table) {
43
55
  * ```
44
56
  */
45
57
  function column_getFacetedUniqueValues(column, table) {
46
- var _table$options$featur5, _table$options$featur6;
47
- return (((_table$options$featur5 = (_table$options$featur6 = table.options.features).facetedUniqueValues) === null || _table$options$featur5 === void 0 ? void 0 : _table$options$featur5.call(_table$options$featur6, table, column.id)) ?? (() => /* @__PURE__ */ new Map()))();
58
+ const facetedUniqueValues = table._rowModels.facetedUniqueValues ??= require_utils.makeObjectMap();
59
+ let facetedUniqueValuesFn = facetedUniqueValues[column.id];
60
+ if (!facetedUniqueValuesFn) {
61
+ var _table$options$featur5, _table$options$featur6;
62
+ facetedUniqueValuesFn = facetedUniqueValues[column.id] = ((_table$options$featur5 = (_table$options$featur6 = table.options.features).facetedUniqueValues) === null || _table$options$featur5 === void 0 ? void 0 : _table$options$featur5.call(_table$options$featur6, table, column.id)) ?? (() => /* @__PURE__ */ new Map());
63
+ }
64
+ return facetedUniqueValuesFn();
48
65
  }
49
66
  /**
50
67
  * Computes min and max numeric facet values for the global filter context.
@@ -58,8 +75,12 @@ function column_getFacetedUniqueValues(column, table) {
58
75
  * ```
59
76
  */
60
77
  function table_getGlobalFacetedMinMaxValues(table) {
61
- var _table$options$featur7, _table$options$featur8;
62
- return (((_table$options$featur7 = (_table$options$featur8 = table.options.features).facetedMinMaxValues) === null || _table$options$featur7 === void 0 ? void 0 : _table$options$featur7.call(_table$options$featur8, table, "__global__")) ?? (() => void 0))();
78
+ if (!table._rowModels.globalFacetedMinMaxValues) {
79
+ var _table$options$featur7, _table$options$featur8;
80
+ table._rowModels.globalFacetedMinMaxValues = ((_table$options$featur7 = (_table$options$featur8 = table.options.features).facetedMinMaxValues) === null || _table$options$featur7 === void 0 ? void 0 : _table$options$featur7.call(_table$options$featur8, table, "__global__")) ?? (() => void 0);
81
+ }
82
+ const facetedMinMaxValuesFn = table._rowModels.globalFacetedMinMaxValues;
83
+ return facetedMinMaxValuesFn();
63
84
  }
64
85
  /**
65
86
  * Computes the row model used to derive global facet values.
@@ -74,8 +95,12 @@ function table_getGlobalFacetedMinMaxValues(table) {
74
95
  * ```
75
96
  */
76
97
  function table_getGlobalFacetedRowModel(table) {
77
- var _table$options$featur9, _table$options$featur10;
78
- return (((_table$options$featur9 = (_table$options$featur10 = table.options.features).facetedRowModel) === null || _table$options$featur9 === void 0 ? void 0 : _table$options$featur9.call(_table$options$featur10, table, "__global__")) ?? (() => table.getPreFilteredRowModel()))();
98
+ if (!table._rowModels.globalFacetedRowModel) {
99
+ var _table$options$featur9, _table$options$featur10;
100
+ table._rowModels.globalFacetedRowModel = ((_table$options$featur9 = (_table$options$featur10 = table.options.features).facetedRowModel) === null || _table$options$featur9 === void 0 ? void 0 : _table$options$featur9.call(_table$options$featur10, table, "__global__")) ?? (() => table.getPreFilteredRowModel());
101
+ }
102
+ const facetedRowModelFn = table._rowModels.globalFacetedRowModel;
103
+ return facetedRowModelFn();
79
104
  }
80
105
  /**
81
106
  * Computes unique values and occurrence counts for the global filter context.
@@ -89,8 +114,12 @@ function table_getGlobalFacetedRowModel(table) {
89
114
  * ```
90
115
  */
91
116
  function table_getGlobalFacetedUniqueValues(table) {
92
- var _table$options$featur11, _table$options$featur12;
93
- return (((_table$options$featur11 = (_table$options$featur12 = table.options.features).facetedUniqueValues) === null || _table$options$featur11 === void 0 ? void 0 : _table$options$featur11.call(_table$options$featur12, table, "__global__")) ?? (() => /* @__PURE__ */ new Map()))();
117
+ if (!table._rowModels.globalFacetedUniqueValues) {
118
+ var _table$options$featur11, _table$options$featur12;
119
+ table._rowModels.globalFacetedUniqueValues = ((_table$options$featur11 = (_table$options$featur12 = table.options.features).facetedUniqueValues) === null || _table$options$featur11 === void 0 ? void 0 : _table$options$featur11.call(_table$options$featur12, table, "__global__")) ?? (() => /* @__PURE__ */ new Map());
120
+ }
121
+ const facetedUniqueValuesFn = table._rowModels.globalFacetedUniqueValues;
122
+ return facetedUniqueValuesFn();
94
123
  }
95
124
 
96
125
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"columnFacetingFeature.utils.cjs","names":[],"sources":["../../../src/features/column-faceting/columnFacetingFeature.utils.ts"],"sourcesContent":["import type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\n\n/**\n * Computes min and max numeric facet values for one column.\n *\n * The configured `facetedMinMaxValues` row-model factory owns the calculation.\n * If no factory is registered, the result is `undefined`.\n *\n * @example\n * ```ts\n * const range = column_getFacetedMinMaxValues(column, table)\n * ```\n */\nexport function column_getFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n table: Table_Internal<TFeatures, TData>,\n): [number, number] | undefined {\n const facetedMinMaxValuesFn =\n table.options.features.facetedMinMaxValues?.(table, column.id) ??\n (() => undefined)\n return facetedMinMaxValuesFn()\n}\n\n/**\n * Computes the row model used to derive one column's facet values.\n *\n * The faceted row model normally applies every other active filter while\n * excluding this column's own filter. If no factory is registered, the\n * pre-filtered row model is returned.\n *\n * @example\n * ```ts\n * const rows = column_getFacetedRowModel(column, table)\n * ```\n */\nexport function column_getFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue> | undefined,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const facetedRowModelFn =\n table.options.features.facetedRowModel?.(table, column?.id ?? '') ??\n (() => table.getPreFilteredRowModel())\n return facetedRowModelFn()\n}\n\n/**\n * Computes unique facet values and their occurrence counts for one column.\n *\n * The configured `facetedUniqueValues` row-model factory owns the calculation.\n * If no factory is registered, an empty `Map` is returned.\n *\n * @example\n * ```ts\n * const values = column_getFacetedUniqueValues(column, table)\n * ```\n */\nexport function column_getFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n table: Table_Internal<TFeatures, TData>,\n): Map<any, number> {\n const facetedUniqueValuesFn =\n table.options.features.facetedUniqueValues?.(table, column.id) ??\n (() => new Map<any, number>())\n return facetedUniqueValuesFn()\n}\n\n/**\n * Computes min and max numeric facet values for the global filter context.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no factory is registered, the result is `undefined`.\n *\n * @example\n * ```ts\n * const range = table_getGlobalFacetedMinMaxValues(table)\n * ```\n */\nexport function table_getGlobalFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): undefined | [number, number] {\n const facetedMinMaxValuesFn =\n table.options.features.facetedMinMaxValues?.(table, '__global__') ??\n (() => undefined)\n return facetedMinMaxValuesFn()\n}\n\n/**\n * Computes the row model used to derive global facet values.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no faceted row-model factory is registered, the pre-filtered row model is\n * returned.\n *\n * @example\n * ```ts\n * const rows = table_getGlobalFacetedRowModel(table)\n * ```\n */\nexport function table_getGlobalFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const facetedRowModelFn =\n table.options.features.facetedRowModel?.(table, '__global__') ??\n (() => table.getPreFilteredRowModel())\n return facetedRowModelFn()\n}\n\n/**\n * Computes unique values and occurrence counts for the global filter context.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no factory is registered, an empty `Map` is returned.\n *\n * @example\n * ```ts\n * const values = table_getGlobalFacetedUniqueValues(table)\n * ```\n */\nexport function table_getGlobalFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): Map<any, number> {\n const facetedUniqueValuesFn =\n table.options.features.facetedUniqueValues?.(table, '__global__') ??\n (() => new Map())\n return facetedUniqueValuesFn()\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,SAAgB,8BAKd,QACA,OAC8B;;CAI9B,4DAFE,MAAM,QAAQ,UAAS,gIAAsB,OAAO,OAAO,EAAE,aACtD,QACmB,CAAC;AAC/B;;;;;;;;;;;;;AAcA,SAAgB,0BAKd,QACA,OAC4B;;CAI5B,6DAFE,MAAM,QAAQ,UAAS,8HAAkB,wDAAO,OAAQ,OAAM,EAAE,aACzD,MAAM,uBAAuB,GACd,CAAC;AAC3B;;;;;;;;;;;;AAaA,SAAgB,8BAKd,QACA,OACkB;;CAIlB,6DAFE,MAAM,QAAQ,UAAS,kIAAsB,OAAO,OAAO,EAAE,6BACtD,IAAI,IAAiB,GACF,CAAC;AAC/B;;;;;;;;;;;;AAaA,SAAgB,mCAGd,OAAuE;;CAIvE,6DAFE,MAAM,QAAQ,UAAS,kIAAsB,OAAO,YAAY,aACzD,QACmB,CAAC;AAC/B;;;;;;;;;;;;;AAcA,SAAgB,+BAGd,OAAqE;;CAIrE,8DAFE,MAAM,QAAQ,UAAS,+HAAkB,OAAO,YAAY,aACrD,MAAM,uBAAuB,GACd,CAAC;AAC3B;;;;;;;;;;;;AAaA,SAAgB,mCAGd,OAA2D;;CAI3D,+DAFE,MAAM,QAAQ,UAAS,qIAAsB,OAAO,YAAY,6BACzD,IAAI,IAAI,GACW,CAAC;AAC/B"}
1
+ {"version":3,"file":"columnFacetingFeature.utils.cjs","names":["makeObjectMap"],"sources":["../../../src/features/column-faceting/columnFacetingFeature.utils.ts"],"sourcesContent":["import { makeObjectMap } from '../../utils'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\n\n/**\n * Computes min and max numeric facet values for one column.\n *\n * The configured `facetedMinMaxValues` row-model factory owns the calculation.\n * If no factory is registered, the result is `undefined`.\n *\n * @example\n * ```ts\n * const range = column_getFacetedMinMaxValues(column, table)\n * ```\n */\nexport function column_getFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n table: Table_Internal<TFeatures, TData>,\n): [number, number] | undefined {\n const facetedMinMaxValues = (table._rowModels.facetedMinMaxValues ??=\n makeObjectMap())\n let facetedMinMaxValuesFn = facetedMinMaxValues[column.id]\n\n if (!facetedMinMaxValuesFn) {\n facetedMinMaxValuesFn = facetedMinMaxValues[column.id] =\n table.options.features.facetedMinMaxValues?.(table, column.id) ??\n (() => undefined)\n }\n\n return facetedMinMaxValuesFn()\n}\n\n/**\n * Computes the row model used to derive one column's facet values.\n *\n * The faceted row model normally applies every other active filter while\n * excluding this column's own filter. If no factory is registered, the\n * pre-filtered row model is returned.\n *\n * @example\n * ```ts\n * const rows = column_getFacetedRowModel(column, table)\n * ```\n */\nexport function column_getFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue> | undefined,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const columnId = column?.id ?? ''\n const facetedRowModels = (table._rowModels.facetedRowModels ??=\n makeObjectMap())\n let facetedRowModelFn = facetedRowModels[columnId]\n\n if (!facetedRowModelFn) {\n facetedRowModelFn = facetedRowModels[columnId] =\n table.options.features.facetedRowModel?.(table, columnId) ??\n (() => table.getPreFilteredRowModel())\n }\n\n return facetedRowModelFn()\n}\n\n/**\n * Computes unique facet values and their occurrence counts for one column.\n *\n * The configured `facetedUniqueValues` row-model factory owns the calculation.\n * If no factory is registered, an empty `Map` is returned.\n *\n * @example\n * ```ts\n * const values = column_getFacetedUniqueValues(column, table)\n * ```\n */\nexport function column_getFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n table: Table_Internal<TFeatures, TData>,\n): Map<any, number> {\n const facetedUniqueValues = (table._rowModels.facetedUniqueValues ??=\n makeObjectMap())\n let facetedUniqueValuesFn = facetedUniqueValues[column.id]\n\n if (!facetedUniqueValuesFn) {\n facetedUniqueValuesFn = facetedUniqueValues[column.id] =\n table.options.features.facetedUniqueValues?.(table, column.id) ??\n (() => new Map<any, number>())\n }\n\n return facetedUniqueValuesFn()\n}\n\n/**\n * Computes min and max numeric facet values for the global filter context.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no factory is registered, the result is `undefined`.\n *\n * @example\n * ```ts\n * const range = table_getGlobalFacetedMinMaxValues(table)\n * ```\n */\nexport function table_getGlobalFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): undefined | [number, number] {\n if (!table._rowModels.globalFacetedMinMaxValues) {\n table._rowModels.globalFacetedMinMaxValues =\n table.options.features.facetedMinMaxValues?.(table, '__global__') ??\n (() => undefined)\n }\n\n const facetedMinMaxValuesFn = table._rowModels.globalFacetedMinMaxValues\n return facetedMinMaxValuesFn()\n}\n\n/**\n * Computes the row model used to derive global facet values.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no faceted row-model factory is registered, the pre-filtered row model is\n * returned.\n *\n * @example\n * ```ts\n * const rows = table_getGlobalFacetedRowModel(table)\n * ```\n */\nexport function table_getGlobalFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n if (!table._rowModels.globalFacetedRowModel) {\n table._rowModels.globalFacetedRowModel =\n table.options.features.facetedRowModel?.(table, '__global__') ??\n (() => table.getPreFilteredRowModel())\n }\n\n const facetedRowModelFn = table._rowModels.globalFacetedRowModel\n return facetedRowModelFn()\n}\n\n/**\n * Computes unique values and occurrence counts for the global filter context.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no factory is registered, an empty `Map` is returned.\n *\n * @example\n * ```ts\n * const values = table_getGlobalFacetedUniqueValues(table)\n * ```\n */\nexport function table_getGlobalFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): Map<any, number> {\n if (!table._rowModels.globalFacetedUniqueValues) {\n table._rowModels.globalFacetedUniqueValues =\n table.options.features.facetedUniqueValues?.(table, '__global__') ??\n (() => new Map())\n }\n\n const facetedUniqueValuesFn = table._rowModels.globalFacetedUniqueValues\n return facetedUniqueValuesFn()\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAgB,8BAKd,QACA,OAC8B;CAC9B,MAAM,sBAAuB,MAAM,WAAW,wBAC5CA,4BAAc;CAChB,IAAI,wBAAwB,oBAAoB,OAAO;CAEvD,IAAI,CAAC,uBAAuB;;EAC1B,wBAAwB,oBAAoB,OAAO,0DACjD,MAAM,QAAQ,UAAS,gIAAsB,OAAO,OAAO,EAAE,aACtD;CACX;CAEA,OAAO,sBAAsB;AAC/B;;;;;;;;;;;;;AAcA,SAAgB,0BAKd,QACA,OAC4B;CAC5B,MAAM,4DAAW,OAAQ,OAAM;CAC/B,MAAM,mBAAoB,MAAM,WAAW,qBACzCA,4BAAc;CAChB,IAAI,oBAAoB,iBAAiB;CAEzC,IAAI,CAAC,mBAAmB;;EACtB,oBAAoB,iBAAiB,iEACnC,MAAM,QAAQ,UAAS,8HAAkB,OAAO,QAAQ,aACjD,MAAM,uBAAuB;CACxC;CAEA,OAAO,kBAAkB;AAC3B;;;;;;;;;;;;AAaA,SAAgB,8BAKd,QACA,OACkB;CAClB,MAAM,sBAAuB,MAAM,WAAW,wBAC5CA,4BAAc;CAChB,IAAI,wBAAwB,oBAAoB,OAAO;CAEvD,IAAI,CAAC,uBAAuB;;EAC1B,wBAAwB,oBAAoB,OAAO,2DACjD,MAAM,QAAQ,UAAS,kIAAsB,OAAO,OAAO,EAAE,6BACtD,IAAI,IAAiB;CAChC;CAEA,OAAO,sBAAsB;AAC/B;;;;;;;;;;;;AAaA,SAAgB,mCAGd,OAAuE;CACvE,IAAI,CAAC,MAAM,WAAW,2BAA2B;;EAC/C,MAAM,WAAW,iFACf,MAAM,QAAQ,UAAS,kIAAsB,OAAO,YAAY,aACzD;CACX;CAEA,MAAM,wBAAwB,MAAM,WAAW;CAC/C,OAAO,sBAAsB;AAC/B;;;;;;;;;;;;;AAcA,SAAgB,+BAGd,OAAqE;CACrE,IAAI,CAAC,MAAM,WAAW,uBAAuB;;EAC3C,MAAM,WAAW,8EACf,MAAM,QAAQ,UAAS,+HAAkB,OAAO,YAAY,aACrD,MAAM,uBAAuB;CACxC;CAEA,MAAM,oBAAoB,MAAM,WAAW;CAC3C,OAAO,kBAAkB;AAC3B;;;;;;;;;;;;AAaA,SAAgB,mCAGd,OAA2D;CAC3D,IAAI,CAAC,MAAM,WAAW,2BAA2B;;EAC/C,MAAM,WAAW,mFACf,MAAM,QAAQ,UAAS,qIAAsB,OAAO,YAAY,6BACzD,IAAI,IAAI;CACnB;CAEA,MAAM,wBAAwB,MAAM,WAAW;CAC/C,OAAO,sBAAsB;AAC/B"}
@@ -1,3 +1,5 @@
1
+ import { makeObjectMap } from "../../utils.js";
2
+
1
3
  //#region src/features/column-faceting/columnFacetingFeature.utils.ts
2
4
  /**
3
5
  * Computes min and max numeric facet values for one column.
@@ -11,8 +13,13 @@
11
13
  * ```
12
14
  */
13
15
  function column_getFacetedMinMaxValues(column, table) {
14
- var _table$options$featur, _table$options$featur2;
15
- return (((_table$options$featur = (_table$options$featur2 = table.options.features).facetedMinMaxValues) === null || _table$options$featur === void 0 ? void 0 : _table$options$featur.call(_table$options$featur2, table, column.id)) ?? (() => void 0))();
16
+ const facetedMinMaxValues = table._rowModels.facetedMinMaxValues ??= makeObjectMap();
17
+ let facetedMinMaxValuesFn = facetedMinMaxValues[column.id];
18
+ if (!facetedMinMaxValuesFn) {
19
+ var _table$options$featur, _table$options$featur2;
20
+ facetedMinMaxValuesFn = facetedMinMaxValues[column.id] = ((_table$options$featur = (_table$options$featur2 = table.options.features).facetedMinMaxValues) === null || _table$options$featur === void 0 ? void 0 : _table$options$featur.call(_table$options$featur2, table, column.id)) ?? (() => void 0);
21
+ }
22
+ return facetedMinMaxValuesFn();
16
23
  }
17
24
  /**
18
25
  * Computes the row model used to derive one column's facet values.
@@ -27,8 +34,14 @@ function column_getFacetedMinMaxValues(column, table) {
27
34
  * ```
28
35
  */
29
36
  function column_getFacetedRowModel(column, table) {
30
- var _table$options$featur3, _table$options$featur4;
31
- return (((_table$options$featur3 = (_table$options$featur4 = table.options.features).facetedRowModel) === null || _table$options$featur3 === void 0 ? void 0 : _table$options$featur3.call(_table$options$featur4, table, (column === null || column === void 0 ? void 0 : column.id) ?? "")) ?? (() => table.getPreFilteredRowModel()))();
37
+ const columnId = (column === null || column === void 0 ? void 0 : column.id) ?? "";
38
+ const facetedRowModels = table._rowModels.facetedRowModels ??= makeObjectMap();
39
+ let facetedRowModelFn = facetedRowModels[columnId];
40
+ if (!facetedRowModelFn) {
41
+ var _table$options$featur3, _table$options$featur4;
42
+ facetedRowModelFn = facetedRowModels[columnId] = ((_table$options$featur3 = (_table$options$featur4 = table.options.features).facetedRowModel) === null || _table$options$featur3 === void 0 ? void 0 : _table$options$featur3.call(_table$options$featur4, table, columnId)) ?? (() => table.getPreFilteredRowModel());
43
+ }
44
+ return facetedRowModelFn();
32
45
  }
33
46
  /**
34
47
  * Computes unique facet values and their occurrence counts for one column.
@@ -42,8 +55,13 @@ function column_getFacetedRowModel(column, table) {
42
55
  * ```
43
56
  */
44
57
  function column_getFacetedUniqueValues(column, table) {
45
- var _table$options$featur5, _table$options$featur6;
46
- return (((_table$options$featur5 = (_table$options$featur6 = table.options.features).facetedUniqueValues) === null || _table$options$featur5 === void 0 ? void 0 : _table$options$featur5.call(_table$options$featur6, table, column.id)) ?? (() => /* @__PURE__ */ new Map()))();
58
+ const facetedUniqueValues = table._rowModels.facetedUniqueValues ??= makeObjectMap();
59
+ let facetedUniqueValuesFn = facetedUniqueValues[column.id];
60
+ if (!facetedUniqueValuesFn) {
61
+ var _table$options$featur5, _table$options$featur6;
62
+ facetedUniqueValuesFn = facetedUniqueValues[column.id] = ((_table$options$featur5 = (_table$options$featur6 = table.options.features).facetedUniqueValues) === null || _table$options$featur5 === void 0 ? void 0 : _table$options$featur5.call(_table$options$featur6, table, column.id)) ?? (() => /* @__PURE__ */ new Map());
63
+ }
64
+ return facetedUniqueValuesFn();
47
65
  }
48
66
  /**
49
67
  * Computes min and max numeric facet values for the global filter context.
@@ -57,8 +75,12 @@ function column_getFacetedUniqueValues(column, table) {
57
75
  * ```
58
76
  */
59
77
  function table_getGlobalFacetedMinMaxValues(table) {
60
- var _table$options$featur7, _table$options$featur8;
61
- return (((_table$options$featur7 = (_table$options$featur8 = table.options.features).facetedMinMaxValues) === null || _table$options$featur7 === void 0 ? void 0 : _table$options$featur7.call(_table$options$featur8, table, "__global__")) ?? (() => void 0))();
78
+ if (!table._rowModels.globalFacetedMinMaxValues) {
79
+ var _table$options$featur7, _table$options$featur8;
80
+ table._rowModels.globalFacetedMinMaxValues = ((_table$options$featur7 = (_table$options$featur8 = table.options.features).facetedMinMaxValues) === null || _table$options$featur7 === void 0 ? void 0 : _table$options$featur7.call(_table$options$featur8, table, "__global__")) ?? (() => void 0);
81
+ }
82
+ const facetedMinMaxValuesFn = table._rowModels.globalFacetedMinMaxValues;
83
+ return facetedMinMaxValuesFn();
62
84
  }
63
85
  /**
64
86
  * Computes the row model used to derive global facet values.
@@ -73,8 +95,12 @@ function table_getGlobalFacetedMinMaxValues(table) {
73
95
  * ```
74
96
  */
75
97
  function table_getGlobalFacetedRowModel(table) {
76
- var _table$options$featur9, _table$options$featur10;
77
- return (((_table$options$featur9 = (_table$options$featur10 = table.options.features).facetedRowModel) === null || _table$options$featur9 === void 0 ? void 0 : _table$options$featur9.call(_table$options$featur10, table, "__global__")) ?? (() => table.getPreFilteredRowModel()))();
98
+ if (!table._rowModels.globalFacetedRowModel) {
99
+ var _table$options$featur9, _table$options$featur10;
100
+ table._rowModels.globalFacetedRowModel = ((_table$options$featur9 = (_table$options$featur10 = table.options.features).facetedRowModel) === null || _table$options$featur9 === void 0 ? void 0 : _table$options$featur9.call(_table$options$featur10, table, "__global__")) ?? (() => table.getPreFilteredRowModel());
101
+ }
102
+ const facetedRowModelFn = table._rowModels.globalFacetedRowModel;
103
+ return facetedRowModelFn();
78
104
  }
79
105
  /**
80
106
  * Computes unique values and occurrence counts for the global filter context.
@@ -88,8 +114,12 @@ function table_getGlobalFacetedRowModel(table) {
88
114
  * ```
89
115
  */
90
116
  function table_getGlobalFacetedUniqueValues(table) {
91
- var _table$options$featur11, _table$options$featur12;
92
- return (((_table$options$featur11 = (_table$options$featur12 = table.options.features).facetedUniqueValues) === null || _table$options$featur11 === void 0 ? void 0 : _table$options$featur11.call(_table$options$featur12, table, "__global__")) ?? (() => /* @__PURE__ */ new Map()))();
117
+ if (!table._rowModels.globalFacetedUniqueValues) {
118
+ var _table$options$featur11, _table$options$featur12;
119
+ table._rowModels.globalFacetedUniqueValues = ((_table$options$featur11 = (_table$options$featur12 = table.options.features).facetedUniqueValues) === null || _table$options$featur11 === void 0 ? void 0 : _table$options$featur11.call(_table$options$featur12, table, "__global__")) ?? (() => /* @__PURE__ */ new Map());
120
+ }
121
+ const facetedUniqueValuesFn = table._rowModels.globalFacetedUniqueValues;
122
+ return facetedUniqueValuesFn();
93
123
  }
94
124
 
95
125
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"columnFacetingFeature.utils.js","names":[],"sources":["../../../src/features/column-faceting/columnFacetingFeature.utils.ts"],"sourcesContent":["import type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\n\n/**\n * Computes min and max numeric facet values for one column.\n *\n * The configured `facetedMinMaxValues` row-model factory owns the calculation.\n * If no factory is registered, the result is `undefined`.\n *\n * @example\n * ```ts\n * const range = column_getFacetedMinMaxValues(column, table)\n * ```\n */\nexport function column_getFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n table: Table_Internal<TFeatures, TData>,\n): [number, number] | undefined {\n const facetedMinMaxValuesFn =\n table.options.features.facetedMinMaxValues?.(table, column.id) ??\n (() => undefined)\n return facetedMinMaxValuesFn()\n}\n\n/**\n * Computes the row model used to derive one column's facet values.\n *\n * The faceted row model normally applies every other active filter while\n * excluding this column's own filter. If no factory is registered, the\n * pre-filtered row model is returned.\n *\n * @example\n * ```ts\n * const rows = column_getFacetedRowModel(column, table)\n * ```\n */\nexport function column_getFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue> | undefined,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const facetedRowModelFn =\n table.options.features.facetedRowModel?.(table, column?.id ?? '') ??\n (() => table.getPreFilteredRowModel())\n return facetedRowModelFn()\n}\n\n/**\n * Computes unique facet values and their occurrence counts for one column.\n *\n * The configured `facetedUniqueValues` row-model factory owns the calculation.\n * If no factory is registered, an empty `Map` is returned.\n *\n * @example\n * ```ts\n * const values = column_getFacetedUniqueValues(column, table)\n * ```\n */\nexport function column_getFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n table: Table_Internal<TFeatures, TData>,\n): Map<any, number> {\n const facetedUniqueValuesFn =\n table.options.features.facetedUniqueValues?.(table, column.id) ??\n (() => new Map<any, number>())\n return facetedUniqueValuesFn()\n}\n\n/**\n * Computes min and max numeric facet values for the global filter context.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no factory is registered, the result is `undefined`.\n *\n * @example\n * ```ts\n * const range = table_getGlobalFacetedMinMaxValues(table)\n * ```\n */\nexport function table_getGlobalFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): undefined | [number, number] {\n const facetedMinMaxValuesFn =\n table.options.features.facetedMinMaxValues?.(table, '__global__') ??\n (() => undefined)\n return facetedMinMaxValuesFn()\n}\n\n/**\n * Computes the row model used to derive global facet values.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no faceted row-model factory is registered, the pre-filtered row model is\n * returned.\n *\n * @example\n * ```ts\n * const rows = table_getGlobalFacetedRowModel(table)\n * ```\n */\nexport function table_getGlobalFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const facetedRowModelFn =\n table.options.features.facetedRowModel?.(table, '__global__') ??\n (() => table.getPreFilteredRowModel())\n return facetedRowModelFn()\n}\n\n/**\n * Computes unique values and occurrence counts for the global filter context.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no factory is registered, an empty `Map` is returned.\n *\n * @example\n * ```ts\n * const values = table_getGlobalFacetedUniqueValues(table)\n * ```\n */\nexport function table_getGlobalFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): Map<any, number> {\n const facetedUniqueValuesFn =\n table.options.features.facetedUniqueValues?.(table, '__global__') ??\n (() => new Map())\n return facetedUniqueValuesFn()\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,8BAKd,QACA,OAC8B;;CAI9B,4DAFE,MAAM,QAAQ,UAAS,gIAAsB,OAAO,OAAO,EAAE,aACtD,QACmB,CAAC;AAC/B;;;;;;;;;;;;;AAcA,SAAgB,0BAKd,QACA,OAC4B;;CAI5B,6DAFE,MAAM,QAAQ,UAAS,8HAAkB,wDAAO,OAAQ,OAAM,EAAE,aACzD,MAAM,uBAAuB,GACd,CAAC;AAC3B;;;;;;;;;;;;AAaA,SAAgB,8BAKd,QACA,OACkB;;CAIlB,6DAFE,MAAM,QAAQ,UAAS,kIAAsB,OAAO,OAAO,EAAE,6BACtD,IAAI,IAAiB,GACF,CAAC;AAC/B;;;;;;;;;;;;AAaA,SAAgB,mCAGd,OAAuE;;CAIvE,6DAFE,MAAM,QAAQ,UAAS,kIAAsB,OAAO,YAAY,aACzD,QACmB,CAAC;AAC/B;;;;;;;;;;;;;AAcA,SAAgB,+BAGd,OAAqE;;CAIrE,8DAFE,MAAM,QAAQ,UAAS,+HAAkB,OAAO,YAAY,aACrD,MAAM,uBAAuB,GACd,CAAC;AAC3B;;;;;;;;;;;;AAaA,SAAgB,mCAGd,OAA2D;;CAI3D,+DAFE,MAAM,QAAQ,UAAS,qIAAsB,OAAO,YAAY,6BACzD,IAAI,IAAI,GACW,CAAC;AAC/B"}
1
+ {"version":3,"file":"columnFacetingFeature.utils.js","names":[],"sources":["../../../src/features/column-faceting/columnFacetingFeature.utils.ts"],"sourcesContent":["import { makeObjectMap } from '../../utils'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\n\n/**\n * Computes min and max numeric facet values for one column.\n *\n * The configured `facetedMinMaxValues` row-model factory owns the calculation.\n * If no factory is registered, the result is `undefined`.\n *\n * @example\n * ```ts\n * const range = column_getFacetedMinMaxValues(column, table)\n * ```\n */\nexport function column_getFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n table: Table_Internal<TFeatures, TData>,\n): [number, number] | undefined {\n const facetedMinMaxValues = (table._rowModels.facetedMinMaxValues ??=\n makeObjectMap())\n let facetedMinMaxValuesFn = facetedMinMaxValues[column.id]\n\n if (!facetedMinMaxValuesFn) {\n facetedMinMaxValuesFn = facetedMinMaxValues[column.id] =\n table.options.features.facetedMinMaxValues?.(table, column.id) ??\n (() => undefined)\n }\n\n return facetedMinMaxValuesFn()\n}\n\n/**\n * Computes the row model used to derive one column's facet values.\n *\n * The faceted row model normally applies every other active filter while\n * excluding this column's own filter. If no factory is registered, the\n * pre-filtered row model is returned.\n *\n * @example\n * ```ts\n * const rows = column_getFacetedRowModel(column, table)\n * ```\n */\nexport function column_getFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue> | undefined,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const columnId = column?.id ?? ''\n const facetedRowModels = (table._rowModels.facetedRowModels ??=\n makeObjectMap())\n let facetedRowModelFn = facetedRowModels[columnId]\n\n if (!facetedRowModelFn) {\n facetedRowModelFn = facetedRowModels[columnId] =\n table.options.features.facetedRowModel?.(table, columnId) ??\n (() => table.getPreFilteredRowModel())\n }\n\n return facetedRowModelFn()\n}\n\n/**\n * Computes unique facet values and their occurrence counts for one column.\n *\n * The configured `facetedUniqueValues` row-model factory owns the calculation.\n * If no factory is registered, an empty `Map` is returned.\n *\n * @example\n * ```ts\n * const values = column_getFacetedUniqueValues(column, table)\n * ```\n */\nexport function column_getFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n table: Table_Internal<TFeatures, TData>,\n): Map<any, number> {\n const facetedUniqueValues = (table._rowModels.facetedUniqueValues ??=\n makeObjectMap())\n let facetedUniqueValuesFn = facetedUniqueValues[column.id]\n\n if (!facetedUniqueValuesFn) {\n facetedUniqueValuesFn = facetedUniqueValues[column.id] =\n table.options.features.facetedUniqueValues?.(table, column.id) ??\n (() => new Map<any, number>())\n }\n\n return facetedUniqueValuesFn()\n}\n\n/**\n * Computes min and max numeric facet values for the global filter context.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no factory is registered, the result is `undefined`.\n *\n * @example\n * ```ts\n * const range = table_getGlobalFacetedMinMaxValues(table)\n * ```\n */\nexport function table_getGlobalFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): undefined | [number, number] {\n if (!table._rowModels.globalFacetedMinMaxValues) {\n table._rowModels.globalFacetedMinMaxValues =\n table.options.features.facetedMinMaxValues?.(table, '__global__') ??\n (() => undefined)\n }\n\n const facetedMinMaxValuesFn = table._rowModels.globalFacetedMinMaxValues\n return facetedMinMaxValuesFn()\n}\n\n/**\n * Computes the row model used to derive global facet values.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no faceted row-model factory is registered, the pre-filtered row model is\n * returned.\n *\n * @example\n * ```ts\n * const rows = table_getGlobalFacetedRowModel(table)\n * ```\n */\nexport function table_getGlobalFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n if (!table._rowModels.globalFacetedRowModel) {\n table._rowModels.globalFacetedRowModel =\n table.options.features.facetedRowModel?.(table, '__global__') ??\n (() => table.getPreFilteredRowModel())\n }\n\n const facetedRowModelFn = table._rowModels.globalFacetedRowModel\n return facetedRowModelFn()\n}\n\n/**\n * Computes unique values and occurrence counts for the global filter context.\n *\n * The global context is requested with the internal `__global__` column id. If\n * no factory is registered, an empty `Map` is returned.\n *\n * @example\n * ```ts\n * const values = table_getGlobalFacetedUniqueValues(table)\n * ```\n */\nexport function table_getGlobalFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): Map<any, number> {\n if (!table._rowModels.globalFacetedUniqueValues) {\n table._rowModels.globalFacetedUniqueValues =\n table.options.features.facetedUniqueValues?.(table, '__global__') ??\n (() => new Map())\n }\n\n const facetedUniqueValuesFn = table._rowModels.globalFacetedUniqueValues\n return facetedUniqueValuesFn()\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAgB,8BAKd,QACA,OAC8B;CAC9B,MAAM,sBAAuB,MAAM,WAAW,wBAC5C,cAAc;CAChB,IAAI,wBAAwB,oBAAoB,OAAO;CAEvD,IAAI,CAAC,uBAAuB;;EAC1B,wBAAwB,oBAAoB,OAAO,0DACjD,MAAM,QAAQ,UAAS,gIAAsB,OAAO,OAAO,EAAE,aACtD;CACX;CAEA,OAAO,sBAAsB;AAC/B;;;;;;;;;;;;;AAcA,SAAgB,0BAKd,QACA,OAC4B;CAC5B,MAAM,4DAAW,OAAQ,OAAM;CAC/B,MAAM,mBAAoB,MAAM,WAAW,qBACzC,cAAc;CAChB,IAAI,oBAAoB,iBAAiB;CAEzC,IAAI,CAAC,mBAAmB;;EACtB,oBAAoB,iBAAiB,iEACnC,MAAM,QAAQ,UAAS,8HAAkB,OAAO,QAAQ,aACjD,MAAM,uBAAuB;CACxC;CAEA,OAAO,kBAAkB;AAC3B;;;;;;;;;;;;AAaA,SAAgB,8BAKd,QACA,OACkB;CAClB,MAAM,sBAAuB,MAAM,WAAW,wBAC5C,cAAc;CAChB,IAAI,wBAAwB,oBAAoB,OAAO;CAEvD,IAAI,CAAC,uBAAuB;;EAC1B,wBAAwB,oBAAoB,OAAO,2DACjD,MAAM,QAAQ,UAAS,kIAAsB,OAAO,OAAO,EAAE,6BACtD,IAAI,IAAiB;CAChC;CAEA,OAAO,sBAAsB;AAC/B;;;;;;;;;;;;AAaA,SAAgB,mCAGd,OAAuE;CACvE,IAAI,CAAC,MAAM,WAAW,2BAA2B;;EAC/C,MAAM,WAAW,iFACf,MAAM,QAAQ,UAAS,kIAAsB,OAAO,YAAY,aACzD;CACX;CAEA,MAAM,wBAAwB,MAAM,WAAW;CAC/C,OAAO,sBAAsB;AAC/B;;;;;;;;;;;;;AAcA,SAAgB,+BAGd,OAAqE;CACrE,IAAI,CAAC,MAAM,WAAW,uBAAuB;;EAC3C,MAAM,WAAW,8EACf,MAAM,QAAQ,UAAS,+HAAkB,OAAO,YAAY,aACrD,MAAM,uBAAuB;CACxC;CAEA,MAAM,oBAAoB,MAAM,WAAW;CAC3C,OAAO,kBAAkB;AAC3B;;;;;;;;;;;;AAaA,SAAgB,mCAGd,OAA2D;CAC3D,IAAI,CAAC,MAAM,WAAW,2BAA2B;;EAC/C,MAAM,WAAW,mFACf,MAAM,QAAQ,UAAS,qIAAsB,OAAO,YAAY,6BACzD,IAAI,IAAI;CACnB;CAEA,MAAM,wBAAwB,MAAM,WAAW;CAC/C,OAAO,sBAAsB;AAC/B"}
@@ -35,6 +35,7 @@ function _createFacetedRowModel(table, columnId, preRowModel, columnFilters, glo
35
35
  if (id !== columnId) filterableIds.push(id);
36
36
  }
37
37
  if (globalFilter) filterableIds.push("__global__");
38
+ if (!filterableIds.length) return preRowModel;
38
39
  const filterRowsImpl = (row) => {
39
40
  for (let i = 0; i < filterableIds.length; i++) {
40
41
  var _row$columnFilters;
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedRowModel.cjs","names":["tableMemo","filterRows"],"sources":["../../../src/features/column-faceting/createFacetedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { filterRows } from '../column-filtering/filterRowsUtils'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type {\n ColumnFiltersState,\n Row_ColumnFiltering,\n} from '../column-filtering/columnFilteringFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => RowModel<TFeatures, TData> {\n return (_table, columnId) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel(),\n ],\n fn: (preRowModel, columnFilters, globalFilter) =>\n _createFacetedRowModel(\n table,\n columnId,\n preRowModel,\n columnFilters,\n globalFilter,\n ),\n })\n }\n}\n\nfunction _createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n preRowModel: RowModel<TFeatures, TData>,\n columnFilters?: ColumnFiltersState,\n globalFilter?: string,\n) {\n if (!preRowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n return preRowModel\n }\n\n const filterableIds: Array<string> = []\n if (columnFilters) {\n for (let i = 0; i < columnFilters.length; i++) {\n const id = columnFilters[i]!.id\n if (id !== columnId) filterableIds.push(id)\n }\n }\n if (globalFilter) filterableIds.push('__global__')\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters?.[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,wBAMsB;CACpC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;EACd,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,uBAAuB;8BAC7B,MAAM,MAAM,6FAAe,IAAI;8BAC/B,MAAM,MAAM,4FAAc,IAAI;KAC9B,MAAM,oBAAoB;IAC5B;;GACA,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,YACF;EACJ,CAAC;CACH;AACF;AAEA,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;CACA,IAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,cAC1D,OAAO;CAGT,MAAM,gBAA+B,CAAC;CACtC,IAAI,eACF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;EAC7C,MAAM,KAAK,cAAc,EAAE,CAAE;EAC7B,IAAI,OAAO,UAAU,cAAc,KAAK,EAAE;CAC5C;CAEF,IAAI,cAAc,cAAc,KAAK,YAAY;CAEjD,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;;GAC7C,2BAAI,IAAI,uFAAgB,cAAc,SAAS,OAC7C,OAAO;EAEX;EACA,OAAO;CACT;CAEA,OAAOC,mCAAW,YAAY,MAAM,gBAAgB,KAAK;AAC3D"}
1
+ {"version":3,"file":"createFacetedRowModel.cjs","names":["tableMemo","filterRows"],"sources":["../../../src/features/column-faceting/createFacetedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { filterRows } from '../column-filtering/filterRowsUtils'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type {\n ColumnFiltersState,\n Row_ColumnFiltering,\n} from '../column-filtering/columnFilteringFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => RowModel<TFeatures, TData> {\n return (_table, columnId) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel(),\n ],\n fn: (preRowModel, columnFilters, globalFilter) =>\n _createFacetedRowModel(\n table,\n columnId,\n preRowModel,\n columnFilters,\n globalFilter,\n ),\n })\n }\n}\n\nfunction _createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n preRowModel: RowModel<TFeatures, TData>,\n columnFilters?: ColumnFiltersState,\n globalFilter?: string,\n) {\n if (!preRowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n return preRowModel\n }\n\n const filterableIds: Array<string> = []\n if (columnFilters) {\n for (let i = 0; i < columnFilters.length; i++) {\n const id = columnFilters[i]!.id\n if (id !== columnId) filterableIds.push(id)\n }\n }\n if (globalFilter) filterableIds.push('__global__')\n\n if (!filterableIds.length) {\n return preRowModel\n }\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters?.[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,wBAMsB;CACpC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;EACd,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,uBAAuB;8BAC7B,MAAM,MAAM,6FAAe,IAAI;8BAC/B,MAAM,MAAM,4FAAc,IAAI;KAC9B,MAAM,oBAAoB;IAC5B;;GACA,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,YACF;EACJ,CAAC;CACH;AACF;AAEA,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;CACA,IAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,cAC1D,OAAO;CAGT,MAAM,gBAA+B,CAAC;CACtC,IAAI,eACF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;EAC7C,MAAM,KAAK,cAAc,EAAE,CAAE;EAC7B,IAAI,OAAO,UAAU,cAAc,KAAK,EAAE;CAC5C;CAEF,IAAI,cAAc,cAAc,KAAK,YAAY;CAEjD,IAAI,CAAC,cAAc,QACjB,OAAO;CAGT,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;;GAC7C,2BAAI,IAAI,uFAAgB,cAAc,SAAS,OAC7C,OAAO;EAEX;EACA,OAAO;CACT;CAEA,OAAOC,mCAAW,YAAY,MAAM,gBAAgB,KAAK;AAC3D"}
@@ -35,6 +35,7 @@ function _createFacetedRowModel(table, columnId, preRowModel, columnFilters, glo
35
35
  if (id !== columnId) filterableIds.push(id);
36
36
  }
37
37
  if (globalFilter) filterableIds.push("__global__");
38
+ if (!filterableIds.length) return preRowModel;
38
39
  const filterRowsImpl = (row) => {
39
40
  for (let i = 0; i < filterableIds.length; i++) {
40
41
  var _row$columnFilters;
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedRowModel.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { filterRows } from '../column-filtering/filterRowsUtils'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type {\n ColumnFiltersState,\n Row_ColumnFiltering,\n} from '../column-filtering/columnFilteringFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => RowModel<TFeatures, TData> {\n return (_table, columnId) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel(),\n ],\n fn: (preRowModel, columnFilters, globalFilter) =>\n _createFacetedRowModel(\n table,\n columnId,\n preRowModel,\n columnFilters,\n globalFilter,\n ),\n })\n }\n}\n\nfunction _createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n preRowModel: RowModel<TFeatures, TData>,\n columnFilters?: ColumnFiltersState,\n globalFilter?: string,\n) {\n if (!preRowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n return preRowModel\n }\n\n const filterableIds: Array<string> = []\n if (columnFilters) {\n for (let i = 0; i < columnFilters.length; i++) {\n const id = columnFilters[i]!.id\n if (id !== columnId) filterableIds.push(id)\n }\n }\n if (globalFilter) filterableIds.push('__global__')\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters?.[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,wBAMsB;CACpC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;EACd,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,uBAAuB;8BAC7B,MAAM,MAAM,6FAAe,IAAI;8BAC/B,MAAM,MAAM,4FAAc,IAAI;KAC9B,MAAM,oBAAoB;IAC5B;;GACA,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,YACF;EACJ,CAAC;CACH;AACF;AAEA,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;CACA,IAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,cAC1D,OAAO;CAGT,MAAM,gBAA+B,CAAC;CACtC,IAAI,eACF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;EAC7C,MAAM,KAAK,cAAc,EAAE,CAAE;EAC7B,IAAI,OAAO,UAAU,cAAc,KAAK,EAAE;CAC5C;CAEF,IAAI,cAAc,cAAc,KAAK,YAAY;CAEjD,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;;GAC7C,2BAAI,IAAI,uFAAgB,cAAc,SAAS,OAC7C,OAAO;EAEX;EACA,OAAO;CACT;CAEA,OAAO,WAAW,YAAY,MAAM,gBAAgB,KAAK;AAC3D"}
1
+ {"version":3,"file":"createFacetedRowModel.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { filterRows } from '../column-filtering/filterRowsUtils'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type {\n ColumnFiltersState,\n Row_ColumnFiltering,\n} from '../column-filtering/columnFilteringFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => RowModel<TFeatures, TData> {\n return (_table, columnId) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel(),\n ],\n fn: (preRowModel, columnFilters, globalFilter) =>\n _createFacetedRowModel(\n table,\n columnId,\n preRowModel,\n columnFilters,\n globalFilter,\n ),\n })\n }\n}\n\nfunction _createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n preRowModel: RowModel<TFeatures, TData>,\n columnFilters?: ColumnFiltersState,\n globalFilter?: string,\n) {\n if (!preRowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n return preRowModel\n }\n\n const filterableIds: Array<string> = []\n if (columnFilters) {\n for (let i = 0; i < columnFilters.length; i++) {\n const id = columnFilters[i]!.id\n if (id !== columnId) filterableIds.push(id)\n }\n }\n if (globalFilter) filterableIds.push('__global__')\n\n if (!filterableIds.length) {\n return preRowModel\n }\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters?.[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,wBAMsB;CACpC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;EACd,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,uBAAuB;8BAC7B,MAAM,MAAM,6FAAe,IAAI;8BAC/B,MAAM,MAAM,4FAAc,IAAI;KAC9B,MAAM,oBAAoB;IAC5B;;GACA,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,YACF;EACJ,CAAC;CACH;AACF;AAEA,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;CACA,IAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,cAC1D,OAAO;CAGT,MAAM,gBAA+B,CAAC;CACtC,IAAI,eACF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;EAC7C,MAAM,KAAK,cAAc,EAAE,CAAE;EAC7B,IAAI,OAAO,UAAU,cAAc,KAAK,EAAE;CAC5C;CAEF,IAAI,cAAc,cAAc,KAAK,YAAY;CAEjD,IAAI,CAAC,cAAc,QACjB,OAAO;CAGT,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;;GAC7C,2BAAI,IAAI,uFAAgB,cAAc,SAAS,OAC7C,OAAO;EAEX;EACA,OAAO;CACT;CAEA,OAAO,WAAW,YAAY,MAAM,gBAAgB,KAAK;AAC3D"}
@@ -29,8 +29,8 @@ function _createFacetedUniqueValues(columnId, flatRows) {
29
29
  const values = flatRows[i].getUniqueValues(columnId);
30
30
  for (let j = 0; j < values.length; j++) {
31
31
  const value = values[j];
32
- if (facetedUniqueValues.has(value)) facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
33
- else facetedUniqueValues.set(value, 1);
32
+ const previousValue = facetedUniqueValues.get(value);
33
+ facetedUniqueValues.set(value, previousValue === void 0 ? 1 : previousValue + 1);
34
34
  }
35
35
  }
36
36
  return facetedUniqueValues;
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedUniqueValues.cjs","names":["tableMemo","callMemoOrStaticFn","column_getFacetedRowModel"],"sources":["../../../src/features/column-faceting/createFacetedUniqueValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted unique values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => Map<any, number> {\n return (_table, columnId) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'table.getFacetedUniqueValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n fn: (flatRows) => _createFacetedUniqueValues(columnId, flatRows),\n })\n }\n}\n\nfunction _createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(columnId: string, flatRows: Array<Row<TFeatures, TData>>): Map<any, number> {\n const facetedUniqueValues = new Map<any, number>()\n\n for (let i = 0; i < flatRows.length; i++) {\n const values = flatRows[i]!.getUniqueValues(columnId)\n\n for (let j = 0; j < values.length; j++) {\n const value = values[j]\n if (facetedUniqueValues.has(value)) {\n facetedUniqueValues.set(\n value,\n (facetedUniqueValues.get(value) ?? 0) + 1,\n )\n } else {\n facetedUniqueValues.set(value, 1)\n }\n }\n }\n\n return facetedUniqueValues\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMY;CAC1B,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;EACd,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,QAAQ;IACvC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,uBAAuB,CAAC,CAAC,QAAQ;IAC5D,OAAO,CACLC,iCACE,QACA,sBACAC,+DACA,KACF,CAAC,CAAC,QACJ;GACF;GACA,KAAK,aAAa,2BAA2B,UAAU,QAAQ;EACjE,CAAC;CACH;AACF;AAEA,SAAS,2BAGP,UAAkB,UAA0D;CAC5E,MAAM,sCAAsB,IAAI,IAAiB;CAEjD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,SAAS,SAAS,EAAE,CAAE,gBAAgB,QAAQ;EAEpD,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,QAAQ,OAAO;GACrB,IAAI,oBAAoB,IAAI,KAAK,GAC/B,oBAAoB,IAClB,QACC,oBAAoB,IAAI,KAAK,KAAK,KAAK,CAC1C;QAEA,oBAAoB,IAAI,OAAO,CAAC;EAEpC;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"createFacetedUniqueValues.cjs","names":["tableMemo","callMemoOrStaticFn","column_getFacetedRowModel"],"sources":["../../../src/features/column-faceting/createFacetedUniqueValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted unique values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => Map<any, number> {\n return (_table, columnId) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'table.getFacetedUniqueValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n fn: (flatRows) => _createFacetedUniqueValues(columnId, flatRows),\n })\n }\n}\n\nfunction _createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(columnId: string, flatRows: Array<Row<TFeatures, TData>>): Map<any, number> {\n const facetedUniqueValues = new Map<any, number>()\n\n for (let i = 0; i < flatRows.length; i++) {\n const values = flatRows[i]!.getUniqueValues(columnId)\n\n for (let j = 0; j < values.length; j++) {\n const value = values[j]\n const previousValue = facetedUniqueValues.get(value)\n facetedUniqueValues.set(\n value,\n previousValue === undefined ? 1 : previousValue + 1,\n )\n }\n }\n\n return facetedUniqueValues\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMY;CAC1B,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;EACd,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,QAAQ;IACvC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,uBAAuB,CAAC,CAAC,QAAQ;IAC5D,OAAO,CACLC,iCACE,QACA,sBACAC,+DACA,KACF,CAAC,CAAC,QACJ;GACF;GACA,KAAK,aAAa,2BAA2B,UAAU,QAAQ;EACjE,CAAC;CACH;AACF;AAEA,SAAS,2BAGP,UAAkB,UAA0D;CAC5E,MAAM,sCAAsB,IAAI,IAAiB;CAEjD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,SAAS,SAAS,EAAE,CAAE,gBAAgB,QAAQ;EAEpD,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,QAAQ,OAAO;GACrB,MAAM,gBAAgB,oBAAoB,IAAI,KAAK;GACnD,oBAAoB,IAClB,OACA,kBAAkB,SAAY,IAAI,gBAAgB,CACpD;EACF;CACF;CAEA,OAAO;AACT"}
@@ -29,8 +29,8 @@ function _createFacetedUniqueValues(columnId, flatRows) {
29
29
  const values = flatRows[i].getUniqueValues(columnId);
30
30
  for (let j = 0; j < values.length; j++) {
31
31
  const value = values[j];
32
- if (facetedUniqueValues.has(value)) facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
33
- else facetedUniqueValues.set(value, 1);
32
+ const previousValue = facetedUniqueValues.get(value);
33
+ facetedUniqueValues.set(value, previousValue === void 0 ? 1 : previousValue + 1);
34
34
  }
35
35
  }
36
36
  return facetedUniqueValues;
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedUniqueValues.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedUniqueValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted unique values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => Map<any, number> {\n return (_table, columnId) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'table.getFacetedUniqueValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n fn: (flatRows) => _createFacetedUniqueValues(columnId, flatRows),\n })\n }\n}\n\nfunction _createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(columnId: string, flatRows: Array<Row<TFeatures, TData>>): Map<any, number> {\n const facetedUniqueValues = new Map<any, number>()\n\n for (let i = 0; i < flatRows.length; i++) {\n const values = flatRows[i]!.getUniqueValues(columnId)\n\n for (let j = 0; j < values.length; j++) {\n const value = values[j]\n if (facetedUniqueValues.has(value)) {\n facetedUniqueValues.set(\n value,\n (facetedUniqueValues.get(value) ?? 0) + 1,\n )\n } else {\n facetedUniqueValues.set(value, 1)\n }\n }\n }\n\n return facetedUniqueValues\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMY;CAC1B,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;EACd,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,QAAQ;IACvC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,uBAAuB,CAAC,CAAC,QAAQ;IAC5D,OAAO,CACL,mBACE,QACA,sBACA,2BACA,KACF,CAAC,CAAC,QACJ;GACF;GACA,KAAK,aAAa,2BAA2B,UAAU,QAAQ;EACjE,CAAC;CACH;AACF;AAEA,SAAS,2BAGP,UAAkB,UAA0D;CAC5E,MAAM,sCAAsB,IAAI,IAAiB;CAEjD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,SAAS,SAAS,EAAE,CAAE,gBAAgB,QAAQ;EAEpD,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,QAAQ,OAAO;GACrB,IAAI,oBAAoB,IAAI,KAAK,GAC/B,oBAAoB,IAClB,QACC,oBAAoB,IAAI,KAAK,KAAK,KAAK,CAC1C;QAEA,oBAAoB,IAAI,OAAO,CAAC;EAEpC;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"createFacetedUniqueValues.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedUniqueValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted unique values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => Map<any, number> {\n return (_table, columnId) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'table.getFacetedUniqueValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n fn: (flatRows) => _createFacetedUniqueValues(columnId, flatRows),\n })\n }\n}\n\nfunction _createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(columnId: string, flatRows: Array<Row<TFeatures, TData>>): Map<any, number> {\n const facetedUniqueValues = new Map<any, number>()\n\n for (let i = 0; i < flatRows.length; i++) {\n const values = flatRows[i]!.getUniqueValues(columnId)\n\n for (let j = 0; j < values.length; j++) {\n const value = values[j]\n const previousValue = facetedUniqueValues.get(value)\n facetedUniqueValues.set(\n value,\n previousValue === undefined ? 1 : previousValue + 1,\n )\n }\n }\n\n return facetedUniqueValues\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMY;CAC1B,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;EACd,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,QAAQ;IACvC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,uBAAuB,CAAC,CAAC,QAAQ;IAC5D,OAAO,CACL,mBACE,QACA,sBACA,2BACA,KACF,CAAC,CAAC,QACJ;GACF;GACA,KAAK,aAAa,2BAA2B,UAAU,QAAQ;EACjE,CAAC;CACH;AACF;AAEA,SAAS,2BAGP,UAAkB,UAA0D;CAC5E,MAAM,sCAAsB,IAAI,IAAiB;CAEjD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,SAAS,SAAS,EAAE,CAAE,gBAAgB,QAAQ;EAEpD,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,QAAQ,OAAO;GACrB,MAAM,gBAAgB,oBAAoB,IAAI,KAAK;GACnD,oBAAoB,IAClB,OACA,kBAAkB,SAAY,IAAI,gBAAgB,CACpD;EACF;CACF;CAEA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
- "version": "9.0.0-beta.27",
3
+ "version": "9.0.0-beta.28",
4
4
  "description": "Headless UI for building powerful tables & datagrids for TS/JS.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -52,9 +52,12 @@ export interface CachedRowModel_Faceted<
52
52
  in out TFeatures extends TableFeatures,
53
53
  in out TData extends RowData,
54
54
  > {
55
- facetedRowModel?: (columnId: string) => () => RowModel<TFeatures, TData>
56
- facetedMinMaxValues?: (columnId: string) => [number, number]
57
- facetedUniqueValues?: (columnId: string) => Map<any, number>
55
+ facetedRowModels?: Record<string, () => RowModel<TFeatures, TData>>
56
+ facetedMinMaxValues?: Record<string, () => undefined | [number, number]>
57
+ facetedUniqueValues?: Record<string, () => Map<any, number>>
58
+ globalFacetedRowModel?: () => RowModel<TFeatures, TData>
59
+ globalFacetedMinMaxValues?: () => undefined | [number, number]
60
+ globalFacetedUniqueValues?: () => Map<any, number>
58
61
  }
59
62
 
60
63
  export interface Table_ColumnFaceting<
@@ -1,3 +1,4 @@
1
+ import { makeObjectMap } from '../../utils'
1
2
  import type { CellData, RowData } from '../../types/type-utils'
2
3
  import type { TableFeatures } from '../../types/TableFeatures'
3
4
  import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
@@ -23,9 +24,16 @@ export function column_getFacetedMinMaxValues<
23
24
  column: Column_Internal<TFeatures, TData, TValue>,
24
25
  table: Table_Internal<TFeatures, TData>,
25
26
  ): [number, number] | undefined {
26
- const facetedMinMaxValuesFn =
27
- table.options.features.facetedMinMaxValues?.(table, column.id) ??
28
- (() => undefined)
27
+ const facetedMinMaxValues = (table._rowModels.facetedMinMaxValues ??=
28
+ makeObjectMap())
29
+ let facetedMinMaxValuesFn = facetedMinMaxValues[column.id]
30
+
31
+ if (!facetedMinMaxValuesFn) {
32
+ facetedMinMaxValuesFn = facetedMinMaxValues[column.id] =
33
+ table.options.features.facetedMinMaxValues?.(table, column.id) ??
34
+ (() => undefined)
35
+ }
36
+
29
37
  return facetedMinMaxValuesFn()
30
38
  }
31
39
 
@@ -49,9 +57,17 @@ export function column_getFacetedRowModel<
49
57
  column: Column_Internal<TFeatures, TData, TValue> | undefined,
50
58
  table: Table_Internal<TFeatures, TData>,
51
59
  ): RowModel<TFeatures, TData> {
52
- const facetedRowModelFn =
53
- table.options.features.facetedRowModel?.(table, column?.id ?? '') ??
54
- (() => table.getPreFilteredRowModel())
60
+ const columnId = column?.id ?? ''
61
+ const facetedRowModels = (table._rowModels.facetedRowModels ??=
62
+ makeObjectMap())
63
+ let facetedRowModelFn = facetedRowModels[columnId]
64
+
65
+ if (!facetedRowModelFn) {
66
+ facetedRowModelFn = facetedRowModels[columnId] =
67
+ table.options.features.facetedRowModel?.(table, columnId) ??
68
+ (() => table.getPreFilteredRowModel())
69
+ }
70
+
55
71
  return facetedRowModelFn()
56
72
  }
57
73
 
@@ -74,9 +90,16 @@ export function column_getFacetedUniqueValues<
74
90
  column: Column_Internal<TFeatures, TData, TValue>,
75
91
  table: Table_Internal<TFeatures, TData>,
76
92
  ): Map<any, number> {
77
- const facetedUniqueValuesFn =
78
- table.options.features.facetedUniqueValues?.(table, column.id) ??
79
- (() => new Map<any, number>())
93
+ const facetedUniqueValues = (table._rowModels.facetedUniqueValues ??=
94
+ makeObjectMap())
95
+ let facetedUniqueValuesFn = facetedUniqueValues[column.id]
96
+
97
+ if (!facetedUniqueValuesFn) {
98
+ facetedUniqueValuesFn = facetedUniqueValues[column.id] =
99
+ table.options.features.facetedUniqueValues?.(table, column.id) ??
100
+ (() => new Map<any, number>())
101
+ }
102
+
80
103
  return facetedUniqueValuesFn()
81
104
  }
82
105
 
@@ -95,9 +118,13 @@ export function table_getGlobalFacetedMinMaxValues<
95
118
  TFeatures extends TableFeatures,
96
119
  TData extends RowData,
97
120
  >(table: Table_Internal<TFeatures, TData>): undefined | [number, number] {
98
- const facetedMinMaxValuesFn =
99
- table.options.features.facetedMinMaxValues?.(table, '__global__') ??
100
- (() => undefined)
121
+ if (!table._rowModels.globalFacetedMinMaxValues) {
122
+ table._rowModels.globalFacetedMinMaxValues =
123
+ table.options.features.facetedMinMaxValues?.(table, '__global__') ??
124
+ (() => undefined)
125
+ }
126
+
127
+ const facetedMinMaxValuesFn = table._rowModels.globalFacetedMinMaxValues
101
128
  return facetedMinMaxValuesFn()
102
129
  }
103
130
 
@@ -117,9 +144,13 @@ export function table_getGlobalFacetedRowModel<
117
144
  TFeatures extends TableFeatures,
118
145
  TData extends RowData,
119
146
  >(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {
120
- const facetedRowModelFn =
121
- table.options.features.facetedRowModel?.(table, '__global__') ??
122
- (() => table.getPreFilteredRowModel())
147
+ if (!table._rowModels.globalFacetedRowModel) {
148
+ table._rowModels.globalFacetedRowModel =
149
+ table.options.features.facetedRowModel?.(table, '__global__') ??
150
+ (() => table.getPreFilteredRowModel())
151
+ }
152
+
153
+ const facetedRowModelFn = table._rowModels.globalFacetedRowModel
123
154
  return facetedRowModelFn()
124
155
  }
125
156
 
@@ -138,8 +169,12 @@ export function table_getGlobalFacetedUniqueValues<
138
169
  TFeatures extends TableFeatures,
139
170
  TData extends RowData,
140
171
  >(table: Table_Internal<TFeatures, TData>): Map<any, number> {
141
- const facetedUniqueValuesFn =
142
- table.options.features.facetedUniqueValues?.(table, '__global__') ??
143
- (() => new Map())
172
+ if (!table._rowModels.globalFacetedUniqueValues) {
173
+ table._rowModels.globalFacetedUniqueValues =
174
+ table.options.features.facetedUniqueValues?.(table, '__global__') ??
175
+ (() => new Map())
176
+ }
177
+
178
+ const facetedUniqueValuesFn = table._rowModels.globalFacetedUniqueValues
144
179
  return facetedUniqueValuesFn()
145
180
  }
@@ -69,6 +69,10 @@ function _createFacetedRowModel<
69
69
  }
70
70
  if (globalFilter) filterableIds.push('__global__')
71
71
 
72
+ if (!filterableIds.length) {
73
+ return preRowModel
74
+ }
75
+
72
76
  const filterRowsImpl = (
73
77
  row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,
74
78
  ) => {
@@ -51,14 +51,11 @@ function _createFacetedUniqueValues<
51
51
 
52
52
  for (let j = 0; j < values.length; j++) {
53
53
  const value = values[j]
54
- if (facetedUniqueValues.has(value)) {
55
- facetedUniqueValues.set(
56
- value,
57
- (facetedUniqueValues.get(value) ?? 0) + 1,
58
- )
59
- } else {
60
- facetedUniqueValues.set(value, 1)
61
- }
54
+ const previousValue = facetedUniqueValues.get(value)
55
+ facetedUniqueValues.set(
56
+ value,
57
+ previousValue === undefined ? 1 : previousValue + 1,
58
+ )
62
59
  }
63
60
  }
64
61