@tanstack/table-core 9.0.0-alpha.33 → 9.0.0-alpha.34

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.
Files changed (182) hide show
  1. package/dist/core/columns/coreColumnsFeature.cjs +18 -12
  2. package/dist/core/columns/coreColumnsFeature.cjs.map +1 -1
  3. package/dist/core/columns/coreColumnsFeature.js +18 -12
  4. package/dist/core/columns/coreColumnsFeature.js.map +1 -1
  5. package/dist/core/headers/coreHeadersFeature.cjs +11 -8
  6. package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
  7. package/dist/core/headers/coreHeadersFeature.js +11 -8
  8. package/dist/core/headers/coreHeadersFeature.js.map +1 -1
  9. package/dist/core/headers/coreHeadersFeature.utils.cjs +2 -1
  10. package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
  11. package/dist/core/headers/coreHeadersFeature.utils.js +2 -1
  12. package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
  13. package/dist/core/table/constructTable.cjs +19 -10
  14. package/dist/core/table/constructTable.cjs.map +1 -1
  15. package/dist/core/table/constructTable.d.cts +1 -3
  16. package/dist/core/table/constructTable.d.ts +1 -3
  17. package/dist/core/table/constructTable.js +21 -11
  18. package/dist/core/table/constructTable.js.map +1 -1
  19. package/dist/core/table/coreTablesFeature.types.d.cts +54 -10
  20. package/dist/core/table/coreTablesFeature.types.d.ts +54 -10
  21. package/dist/core/table/coreTablesFeature.utils.cjs +5 -1
  22. package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
  23. package/dist/core/table/coreTablesFeature.utils.js +5 -1
  24. package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
  25. package/dist/features/column-faceting/columnFacetingFeature.cjs +18 -12
  26. package/dist/features/column-faceting/columnFacetingFeature.cjs.map +1 -1
  27. package/dist/features/column-faceting/columnFacetingFeature.js +18 -12
  28. package/dist/features/column-faceting/columnFacetingFeature.js.map +1 -1
  29. package/dist/features/column-faceting/createFacetedRowModel.cjs +9 -6
  30. package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
  31. package/dist/features/column-faceting/createFacetedRowModel.js +9 -6
  32. package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
  33. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +4 -4
  34. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
  35. package/dist/features/column-filtering/columnFilteringFeature.utils.js +4 -4
  36. package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
  37. package/dist/features/column-filtering/createFilteredRowModel.cjs +11 -6
  38. package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
  39. package/dist/features/column-filtering/createFilteredRowModel.js +11 -6
  40. package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
  41. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +4 -4
  42. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  43. package/dist/features/column-grouping/columnGroupingFeature.utils.js +4 -4
  44. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  45. package/dist/features/column-grouping/createGroupedRowModel.cjs +6 -2
  46. package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
  47. package/dist/features/column-grouping/createGroupedRowModel.js +6 -2
  48. package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
  49. package/dist/features/column-ordering/columnOrderingFeature.cjs +17 -11
  50. package/dist/features/column-ordering/columnOrderingFeature.cjs.map +1 -1
  51. package/dist/features/column-ordering/columnOrderingFeature.js +17 -11
  52. package/dist/features/column-ordering/columnOrderingFeature.js.map +1 -1
  53. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +5 -3
  54. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
  55. package/dist/features/column-ordering/columnOrderingFeature.utils.js +5 -3
  56. package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
  57. package/dist/features/column-pinning/columnPinningFeature.cjs +72 -45
  58. package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
  59. package/dist/features/column-pinning/columnPinningFeature.js +72 -45
  60. package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
  61. package/dist/features/column-pinning/columnPinningFeature.utils.cjs +24 -13
  62. package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
  63. package/dist/features/column-pinning/columnPinningFeature.utils.js +24 -13
  64. package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
  65. package/dist/features/column-resizing/columnResizingFeature.utils.cjs +2 -2
  66. package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
  67. package/dist/features/column-resizing/columnResizingFeature.utils.js +2 -2
  68. package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
  69. package/dist/features/column-sizing/columnSizingFeature.cjs +16 -10
  70. package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
  71. package/dist/features/column-sizing/columnSizingFeature.js +16 -10
  72. package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
  73. package/dist/features/column-sizing/columnSizingFeature.utils.cjs +2 -2
  74. package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
  75. package/dist/features/column-sizing/columnSizingFeature.utils.js +2 -2
  76. package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
  77. package/dist/features/column-visibility/columnVisibilityFeature.cjs +28 -16
  78. package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
  79. package/dist/features/column-visibility/columnVisibilityFeature.js +28 -16
  80. package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
  81. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +2 -2
  82. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
  83. package/dist/features/column-visibility/columnVisibilityFeature.utils.js +2 -2
  84. package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
  85. package/dist/features/row-expanding/createExpandedRowModel.cjs +10 -6
  86. package/dist/features/row-expanding/createExpandedRowModel.cjs.map +1 -1
  87. package/dist/features/row-expanding/createExpandedRowModel.js +10 -6
  88. package/dist/features/row-expanding/createExpandedRowModel.js.map +1 -1
  89. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +8 -5
  90. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
  91. package/dist/features/row-expanding/rowExpandingFeature.utils.js +8 -5
  92. package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
  93. package/dist/features/row-pagination/createPaginatedRowModel.cjs +10 -6
  94. package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +1 -1
  95. package/dist/features/row-pagination/createPaginatedRowModel.js +10 -6
  96. package/dist/features/row-pagination/createPaginatedRowModel.js.map +1 -1
  97. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +6 -6
  98. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
  99. package/dist/features/row-pagination/rowPaginationFeature.utils.js +6 -6
  100. package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
  101. package/dist/features/row-pinning/rowPinningFeature.cjs +12 -6
  102. package/dist/features/row-pinning/rowPinningFeature.cjs.map +1 -1
  103. package/dist/features/row-pinning/rowPinningFeature.js +12 -6
  104. package/dist/features/row-pinning/rowPinningFeature.js.map +1 -1
  105. package/dist/features/row-pinning/rowPinningFeature.utils.cjs +8 -5
  106. package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
  107. package/dist/features/row-pinning/rowPinningFeature.utils.js +8 -5
  108. package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
  109. package/dist/features/row-selection/rowSelectionFeature.cjs +12 -3
  110. package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
  111. package/dist/features/row-selection/rowSelectionFeature.js +12 -3
  112. package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
  113. package/dist/features/row-selection/rowSelectionFeature.types.d.cts +1 -1
  114. package/dist/features/row-selection/rowSelectionFeature.types.d.ts +1 -1
  115. package/dist/features/row-selection/rowSelectionFeature.utils.cjs +14 -7
  116. package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
  117. package/dist/features/row-selection/rowSelectionFeature.utils.js +14 -7
  118. package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
  119. package/dist/features/row-sorting/createSortedRowModel.cjs +6 -2
  120. package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
  121. package/dist/features/row-sorting/createSortedRowModel.js +6 -2
  122. package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
  123. package/dist/features/row-sorting/rowSortingFeature.utils.cjs +4 -4
  124. package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
  125. package/dist/features/row-sorting/rowSortingFeature.utils.js +4 -4
  126. package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
  127. package/dist/features/table-reactivity/tableReactivityFeature.cjs +23 -1
  128. package/dist/features/table-reactivity/tableReactivityFeature.cjs.map +1 -1
  129. package/dist/features/table-reactivity/tableReactivityFeature.js +23 -1
  130. package/dist/features/table-reactivity/tableReactivityFeature.js.map +1 -1
  131. package/dist/index.cjs +1 -261
  132. package/dist/index.d.cts +3 -23
  133. package/dist/index.d.ts +3 -23
  134. package/dist/index.js +2 -22
  135. package/dist/static-functions.cjs +261 -0
  136. package/dist/static-functions.d.cts +21 -0
  137. package/dist/static-functions.d.ts +21 -0
  138. package/dist/static-functions.js +22 -0
  139. package/dist/types/Table.d.cts +5 -3
  140. package/dist/types/Table.d.ts +5 -3
  141. package/dist/utils.cjs +2 -6
  142. package/dist/utils.cjs.map +1 -1
  143. package/dist/utils.js +2 -6
  144. package/dist/utils.js.map +1 -1
  145. package/package.json +5 -1
  146. package/src/core/columns/coreColumnsFeature.ts +4 -4
  147. package/src/core/headers/coreHeadersFeature.ts +4 -4
  148. package/src/core/headers/coreHeadersFeature.utils.ts +1 -1
  149. package/src/core/table/constructTable.ts +31 -15
  150. package/src/core/table/coreTablesFeature.types.ts +69 -9
  151. package/src/core/table/coreTablesFeature.utils.ts +7 -1
  152. package/src/features/column-faceting/columnFacetingFeature.ts +4 -4
  153. package/src/features/column-faceting/createFacetedRowModel.ts +2 -2
  154. package/src/features/column-filtering/columnFilteringFeature.utils.ts +6 -5
  155. package/src/features/column-filtering/createFilteredRowModel.ts +4 -3
  156. package/src/features/column-grouping/columnGroupingFeature.utils.ts +2 -2
  157. package/src/features/column-grouping/createGroupedRowModel.ts +2 -2
  158. package/src/features/column-ordering/columnOrderingFeature.ts +5 -5
  159. package/src/features/column-ordering/columnOrderingFeature.utils.ts +3 -3
  160. package/src/features/column-pinning/columnPinningFeature.ts +22 -21
  161. package/src/features/column-pinning/columnPinningFeature.utils.ts +12 -12
  162. package/src/features/column-resizing/columnResizingFeature.utils.ts +3 -1
  163. package/src/features/column-sizing/columnSizingFeature.ts +2 -2
  164. package/src/features/column-sizing/columnSizingFeature.utils.ts +1 -1
  165. package/src/features/column-visibility/columnVisibilityFeature.ts +6 -6
  166. package/src/features/column-visibility/columnVisibilityFeature.utils.ts +1 -1
  167. package/src/features/row-expanding/createExpandedRowModel.ts +2 -2
  168. package/src/features/row-expanding/rowExpandingFeature.utils.ts +5 -5
  169. package/src/features/row-pagination/createPaginatedRowModel.ts +3 -3
  170. package/src/features/row-pagination/rowPaginationFeature.utils.ts +3 -3
  171. package/src/features/row-pinning/rowPinningFeature.ts +4 -4
  172. package/src/features/row-pinning/rowPinningFeature.utils.ts +4 -4
  173. package/src/features/row-selection/rowSelectionFeature.ts +3 -3
  174. package/src/features/row-selection/rowSelectionFeature.types.ts +1 -1
  175. package/src/features/row-selection/rowSelectionFeature.utils.ts +10 -8
  176. package/src/features/row-sorting/createSortedRowModel.ts +5 -2
  177. package/src/features/row-sorting/rowSortingFeature.utils.ts +5 -4
  178. package/src/features/table-reactivity/tableReactivityFeature.ts +46 -1
  179. package/src/index.ts +0 -20
  180. package/src/static-functions.ts +31 -0
  181. package/src/types/Table.ts +10 -3
  182. package/src/utils.ts +3 -8
@@ -2,13 +2,45 @@ import { RowData, Updater } from "../../types/type-utils.cjs";
2
2
  import { CoreFeatures } from "../coreFeatures.cjs";
3
3
  import { RowModelFns } from "../../types/RowModelFns.cjs";
4
4
  import { CachedRowModels, CreateRowModels_All } from "../../types/RowModel.cjs";
5
- import { TableState } from "../../types/TableState.cjs";
5
+ import { TableState, TableState_All } from "../../types/TableState.cjs";
6
6
  import { TableOptions } from "../../types/TableOptions.cjs";
7
7
  import { TableFeatures } from "../../types/TableFeatures.cjs";
8
- import { ReadonlyStore, Store } from "@tanstack/store";
8
+ import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/store";
9
9
 
10
10
  //#region src/core/table/coreTablesFeature.types.d.ts
11
11
  interface TableMeta<TFeatures extends TableFeatures, TData extends RowData> {}
12
+ /**
13
+ * A map of writable atoms, one per `TableState` slice. These are the internal
14
+ * writable atoms that the library always writes to via `makeStateUpdater`.
15
+ */
16
+ type BaseAtoms<TFeatures extends TableFeatures> = { [K in keyof TableState<TFeatures>]-?: Atom<TableState<TFeatures>[K]> };
17
+ /**
18
+ * A map of readonly derived atoms, one per `TableState` slice. Each derives
19
+ * from its corresponding `baseAtom` plus, optionally, a per-slice external
20
+ * atom or external state value.
21
+ *
22
+ * Precedence: `options.atoms[key]` > `options.state[key]` > `baseAtoms[key]`.
23
+ */
24
+ type Atoms<TFeatures extends TableFeatures> = { [K in keyof TableState<TFeatures>]-?: ReadonlyAtom<TableState<TFeatures>[K]> };
25
+ /**
26
+ * A map of optional external atoms, one per `TableState` slice. Consumers can
27
+ * provide their own writable atom for any state slice to take over ownership
28
+ * of that slice.
29
+ */
30
+ type ExternalAtoms<TFeatures extends TableFeatures> = Partial<{ [K in keyof TableState<TFeatures>]: Atom<TableState<TFeatures>[K]> }>;
31
+ /**
32
+ * Internal "all features" flat variants of the atom types. `Table_Internal`
33
+ * uses these so feature code (written generically over `TFeatures`) can access
34
+ * any slice atom (e.g. `table.atoms.columnPinning`) without TypeScript
35
+ * narrowing away slices that aren't in the current `TFeatures` union.
36
+ *
37
+ * Keys are optional: feature code can read atoms from slices it doesn't own,
38
+ * but those slices may not be registered on the current table. Consumers must
39
+ * use optional chaining (`table.atoms.columnPinning?.get() ?? default`).
40
+ */
41
+ type BaseAtoms_All = { [K in keyof TableState_All]?: Atom<TableState_All[K]> };
42
+ type Atoms_All = { [K in keyof TableState_All]?: ReadonlyAtom<TableState_All[K]> };
43
+ type ExternalAtoms_All = Partial<{ [K in keyof TableState_All]: Atom<TableState_All[K]> }>;
12
44
  interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowData> {
13
45
  /**
14
46
  * The features that you want to enable for the table.
@@ -18,6 +50,14 @@ interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowD
18
50
  * The row model options that you want to enable for the table.
19
51
  */
20
52
  _rowModels?: CreateRowModels_All<TFeatures, TData>;
53
+ /**
54
+ * Optionally, provide your own external writable atoms for individual state slices.
55
+ * When an atom is provided for a given slice, it takes precedence over `options.state[key]`
56
+ * and the internal base atom for that slice. Writes originating from the library are
57
+ * still routed through the internal base atom; consumers are responsible for
58
+ * mirroring changes back to their external atom via the corresponding `onXChange` callback.
59
+ */
60
+ atoms?: ExternalAtoms<TFeatures>;
21
61
  /**
22
62
  * Set this option to override any of the `autoReset...` feature options.
23
63
  */
@@ -43,10 +83,6 @@ interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowD
43
83
  * Pass in individual self-managed state to the table.
44
84
  */
45
85
  state?: Partial<TableState<TFeatures>>;
46
- /**
47
- * Optionally, provide your own external TanStack Store instance if you want to manage the table state externally.
48
- */
49
- store?: Store<TableState<TFeatures>>;
50
86
  }
51
87
  interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends RowData> {
52
88
  /**
@@ -78,9 +114,16 @@ interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends Ro
78
114
  */
79
115
  _rowPrototype?: object;
80
116
  /**
81
- * The base store for the table. This can be used to write to the table state.
117
+ * The internal writable atoms for each `TableState` slice. This is the library's
118
+ * single write surface — all state mutations from features land here.
119
+ */
120
+ baseAtoms: BaseAtoms<TFeatures>;
121
+ /**
122
+ * The readonly derived atoms for each `TableState` slice. Each derives from
123
+ * its corresponding `baseAtom` plus, optionally, a per-slice external atom or
124
+ * external state value (precedence: external atom > external state > base atom).
82
125
  */
83
- baseStore: Store<TableState<TFeatures>>;
126
+ atoms: Atoms<TFeatures>;
84
127
  /**
85
128
  * The base store for the table options.
86
129
  */
@@ -94,7 +137,8 @@ interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends Ro
94
137
  */
95
138
  readonly options: TableOptions<TFeatures, TData>;
96
139
  /**
97
- * Where the table state is stored.
140
+ * The readonly flat store for the table state. Derives from `table.atoms`
141
+ * only; never reads external state directly.
98
142
  */
99
143
  store: ReadonlyStore<TableState<TFeatures>>;
100
144
  }
@@ -109,5 +153,5 @@ interface Table_Table<TFeatures extends TableFeatures, TData extends RowData> ex
109
153
  setOptions: (newOptions: Updater<TableOptions<TFeatures, TData>>) => void;
110
154
  }
111
155
  //#endregion
112
- export { TableMeta, TableOptions_Table, Table_CoreProperties, Table_Table };
156
+ export { Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, ExternalAtoms, ExternalAtoms_All, TableMeta, TableOptions_Table, Table_CoreProperties, Table_Table };
113
157
  //# sourceMappingURL=coreTablesFeature.types.d.cts.map
@@ -2,13 +2,45 @@ import { RowData, Updater } from "../../types/type-utils.js";
2
2
  import { CoreFeatures } from "../coreFeatures.js";
3
3
  import { RowModelFns } from "../../types/RowModelFns.js";
4
4
  import { CachedRowModels, CreateRowModels_All } from "../../types/RowModel.js";
5
- import { TableState } from "../../types/TableState.js";
5
+ import { TableState, TableState_All } from "../../types/TableState.js";
6
6
  import { TableOptions } from "../../types/TableOptions.js";
7
7
  import { TableFeatures } from "../../types/TableFeatures.js";
8
- import { ReadonlyStore, Store } from "@tanstack/store";
8
+ import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/store";
9
9
 
10
10
  //#region src/core/table/coreTablesFeature.types.d.ts
11
11
  interface TableMeta<TFeatures extends TableFeatures, TData extends RowData> {}
12
+ /**
13
+ * A map of writable atoms, one per `TableState` slice. These are the internal
14
+ * writable atoms that the library always writes to via `makeStateUpdater`.
15
+ */
16
+ type BaseAtoms<TFeatures extends TableFeatures> = { [K in keyof TableState<TFeatures>]-?: Atom<TableState<TFeatures>[K]> };
17
+ /**
18
+ * A map of readonly derived atoms, one per `TableState` slice. Each derives
19
+ * from its corresponding `baseAtom` plus, optionally, a per-slice external
20
+ * atom or external state value.
21
+ *
22
+ * Precedence: `options.atoms[key]` > `options.state[key]` > `baseAtoms[key]`.
23
+ */
24
+ type Atoms<TFeatures extends TableFeatures> = { [K in keyof TableState<TFeatures>]-?: ReadonlyAtom<TableState<TFeatures>[K]> };
25
+ /**
26
+ * A map of optional external atoms, one per `TableState` slice. Consumers can
27
+ * provide their own writable atom for any state slice to take over ownership
28
+ * of that slice.
29
+ */
30
+ type ExternalAtoms<TFeatures extends TableFeatures> = Partial<{ [K in keyof TableState<TFeatures>]: Atom<TableState<TFeatures>[K]> }>;
31
+ /**
32
+ * Internal "all features" flat variants of the atom types. `Table_Internal`
33
+ * uses these so feature code (written generically over `TFeatures`) can access
34
+ * any slice atom (e.g. `table.atoms.columnPinning`) without TypeScript
35
+ * narrowing away slices that aren't in the current `TFeatures` union.
36
+ *
37
+ * Keys are optional: feature code can read atoms from slices it doesn't own,
38
+ * but those slices may not be registered on the current table. Consumers must
39
+ * use optional chaining (`table.atoms.columnPinning?.get() ?? default`).
40
+ */
41
+ type BaseAtoms_All = { [K in keyof TableState_All]?: Atom<TableState_All[K]> };
42
+ type Atoms_All = { [K in keyof TableState_All]?: ReadonlyAtom<TableState_All[K]> };
43
+ type ExternalAtoms_All = Partial<{ [K in keyof TableState_All]: Atom<TableState_All[K]> }>;
12
44
  interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowData> {
13
45
  /**
14
46
  * The features that you want to enable for the table.
@@ -18,6 +50,14 @@ interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowD
18
50
  * The row model options that you want to enable for the table.
19
51
  */
20
52
  _rowModels?: CreateRowModels_All<TFeatures, TData>;
53
+ /**
54
+ * Optionally, provide your own external writable atoms for individual state slices.
55
+ * When an atom is provided for a given slice, it takes precedence over `options.state[key]`
56
+ * and the internal base atom for that slice. Writes originating from the library are
57
+ * still routed through the internal base atom; consumers are responsible for
58
+ * mirroring changes back to their external atom via the corresponding `onXChange` callback.
59
+ */
60
+ atoms?: ExternalAtoms<TFeatures>;
21
61
  /**
22
62
  * Set this option to override any of the `autoReset...` feature options.
23
63
  */
@@ -43,10 +83,6 @@ interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowD
43
83
  * Pass in individual self-managed state to the table.
44
84
  */
45
85
  state?: Partial<TableState<TFeatures>>;
46
- /**
47
- * Optionally, provide your own external TanStack Store instance if you want to manage the table state externally.
48
- */
49
- store?: Store<TableState<TFeatures>>;
50
86
  }
51
87
  interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends RowData> {
52
88
  /**
@@ -78,9 +114,16 @@ interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends Ro
78
114
  */
79
115
  _rowPrototype?: object;
80
116
  /**
81
- * The base store for the table. This can be used to write to the table state.
117
+ * The internal writable atoms for each `TableState` slice. This is the library's
118
+ * single write surface — all state mutations from features land here.
119
+ */
120
+ baseAtoms: BaseAtoms<TFeatures>;
121
+ /**
122
+ * The readonly derived atoms for each `TableState` slice. Each derives from
123
+ * its corresponding `baseAtom` plus, optionally, a per-slice external atom or
124
+ * external state value (precedence: external atom > external state > base atom).
82
125
  */
83
- baseStore: Store<TableState<TFeatures>>;
126
+ atoms: Atoms<TFeatures>;
84
127
  /**
85
128
  * The base store for the table options.
86
129
  */
@@ -94,7 +137,8 @@ interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends Ro
94
137
  */
95
138
  readonly options: TableOptions<TFeatures, TData>;
96
139
  /**
97
- * Where the table state is stored.
140
+ * The readonly flat store for the table state. Derives from `table.atoms`
141
+ * only; never reads external state directly.
98
142
  */
99
143
  store: ReadonlyStore<TableState<TFeatures>>;
100
144
  }
@@ -109,5 +153,5 @@ interface Table_Table<TFeatures extends TableFeatures, TData extends RowData> ex
109
153
  setOptions: (newOptions: Updater<TableOptions<TFeatures, TData>>) => void;
110
154
  }
111
155
  //#endregion
112
- export { TableMeta, TableOptions_Table, Table_CoreProperties, Table_Table };
156
+ export { Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, ExternalAtoms, ExternalAtoms_All, TableMeta, TableOptions_Table, Table_CoreProperties, Table_Table };
113
157
  //# sourceMappingURL=coreTablesFeature.types.d.ts.map
@@ -1,8 +1,12 @@
1
1
  const require_utils = require('../../utils.cjs');
2
+ let _tanstack_store = require("@tanstack/store");
2
3
 
3
4
  //#region src/core/table/coreTablesFeature.utils.ts
4
5
  function table_reset(table) {
5
- table.baseStore.setState(() => structuredClone(table.initialState));
6
+ const snap = structuredClone(table.initialState);
7
+ (0, _tanstack_store.batch)(() => {
8
+ for (const key of Object.keys(snap)) table.baseAtoms[key].set(snap[key]);
9
+ });
6
10
  }
7
11
  function table_mergeOptions(table, newOptions) {
8
12
  if (table.options.mergeOptions) return table.options.mergeOptions(table.options, newOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"coreTablesFeature.utils.cjs","names":["functionalUpdate"],"sources":["../../../src/core/table/coreTablesFeature.utils.ts"],"sourcesContent":["import { functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\n\nexport function table_reset<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n table.baseStore.setState(() => structuredClone(table.initialState))\n}\n\nexport function table_mergeOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n newOptions: TableOptions<TFeatures, TData>,\n) {\n if (table.options.mergeOptions) {\n return table.options.mergeOptions(table.options, newOptions)\n }\n\n return {\n ...table.options,\n ...newOptions,\n }\n}\n\nexport function table_setOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<TableOptions<TFeatures, TData>>,\n): void {\n const newOptions = functionalUpdate(updater, table.options)\n const mergedOptions = table_mergeOptions(table, newOptions)\n table.optionsStore.setState(() => mergedOptions)\n}\n"],"mappings":";;;AAMA,SAAgB,YAGd,OAA+C;AAC/C,OAAM,UAAU,eAAe,gBAAgB,MAAM,aAAa,CAAC;;AAGrE,SAAgB,mBAId,OACA,YACA;AACA,KAAI,MAAM,QAAQ,aAChB,QAAO,MAAM,QAAQ,aAAa,MAAM,SAAS,WAAW;AAG9D,QAAO;EACL,GAAG,MAAM;EACT,GAAG;EACJ;;AAGH,SAAgB,iBAId,OACA,SACM;CAEN,MAAM,gBAAgB,mBAAmB,OADtBA,+BAAiB,SAAS,MAAM,QAAQ,CACA;AAC3D,OAAM,aAAa,eAAe,cAAc"}
1
+ {"version":3,"file":"coreTablesFeature.utils.cjs","names":["functionalUpdate"],"sources":["../../../src/core/table/coreTablesFeature.utils.ts"],"sourcesContent":["import { batch } from '@tanstack/store'\nimport { functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\n\nexport function table_reset<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n const snap = structuredClone(table.initialState)\n batch(() => {\n for (const key of Object.keys(snap) as Array<keyof typeof snap>) {\n ;(table.baseAtoms as any)[key].set(snap[key] as any)\n }\n })\n}\n\nexport function table_mergeOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n newOptions: TableOptions<TFeatures, TData>,\n) {\n if (table.options.mergeOptions) {\n return table.options.mergeOptions(table.options, newOptions)\n }\n\n return {\n ...table.options,\n ...newOptions,\n }\n}\n\nexport function table_setOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<TableOptions<TFeatures, TData>>,\n): void {\n const newOptions = functionalUpdate(updater, table.options)\n const mergedOptions = table_mergeOptions(table, newOptions)\n table.optionsStore.setState(() => mergedOptions)\n}\n"],"mappings":";;;;AAOA,SAAgB,YAGd,OAA+C;CAC/C,MAAM,OAAO,gBAAgB,MAAM,aAAa;AAChD,kCAAY;AACV,OAAK,MAAM,OAAO,OAAO,KAAK,KAAK,CAChC,CAAC,MAAM,UAAkB,KAAK,IAAI,KAAK,KAAY;GAEtD;;AAGJ,SAAgB,mBAId,OACA,YACA;AACA,KAAI,MAAM,QAAQ,aAChB,QAAO,MAAM,QAAQ,aAAa,MAAM,SAAS,WAAW;AAG9D,QAAO;EACL,GAAG,MAAM;EACT,GAAG;EACJ;;AAGH,SAAgB,iBAId,OACA,SACM;CAEN,MAAM,gBAAgB,mBAAmB,OADtBA,+BAAiB,SAAS,MAAM,QAAQ,CACA;AAC3D,OAAM,aAAa,eAAe,cAAc"}
@@ -1,8 +1,12 @@
1
1
  import { functionalUpdate } from "../../utils.js";
2
+ import { batch } from "@tanstack/store";
2
3
 
3
4
  //#region src/core/table/coreTablesFeature.utils.ts
4
5
  function table_reset(table) {
5
- table.baseStore.setState(() => structuredClone(table.initialState));
6
+ const snap = structuredClone(table.initialState);
7
+ batch(() => {
8
+ for (const key of Object.keys(snap)) table.baseAtoms[key].set(snap[key]);
9
+ });
6
10
  }
7
11
  function table_mergeOptions(table, newOptions) {
8
12
  if (table.options.mergeOptions) return table.options.mergeOptions(table.options, newOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"coreTablesFeature.utils.js","names":[],"sources":["../../../src/core/table/coreTablesFeature.utils.ts"],"sourcesContent":["import { functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\n\nexport function table_reset<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n table.baseStore.setState(() => structuredClone(table.initialState))\n}\n\nexport function table_mergeOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n newOptions: TableOptions<TFeatures, TData>,\n) {\n if (table.options.mergeOptions) {\n return table.options.mergeOptions(table.options, newOptions)\n }\n\n return {\n ...table.options,\n ...newOptions,\n }\n}\n\nexport function table_setOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<TableOptions<TFeatures, TData>>,\n): void {\n const newOptions = functionalUpdate(updater, table.options)\n const mergedOptions = table_mergeOptions(table, newOptions)\n table.optionsStore.setState(() => mergedOptions)\n}\n"],"mappings":";;;AAMA,SAAgB,YAGd,OAA+C;AAC/C,OAAM,UAAU,eAAe,gBAAgB,MAAM,aAAa,CAAC;;AAGrE,SAAgB,mBAId,OACA,YACA;AACA,KAAI,MAAM,QAAQ,aAChB,QAAO,MAAM,QAAQ,aAAa,MAAM,SAAS,WAAW;AAG9D,QAAO;EACL,GAAG,MAAM;EACT,GAAG;EACJ;;AAGH,SAAgB,iBAId,OACA,SACM;CAEN,MAAM,gBAAgB,mBAAmB,OADtB,iBAAiB,SAAS,MAAM,QAAQ,CACA;AAC3D,OAAM,aAAa,eAAe,cAAc"}
1
+ {"version":3,"file":"coreTablesFeature.utils.js","names":[],"sources":["../../../src/core/table/coreTablesFeature.utils.ts"],"sourcesContent":["import { batch } from '@tanstack/store'\nimport { functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\n\nexport function table_reset<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n const snap = structuredClone(table.initialState)\n batch(() => {\n for (const key of Object.keys(snap) as Array<keyof typeof snap>) {\n ;(table.baseAtoms as any)[key].set(snap[key] as any)\n }\n })\n}\n\nexport function table_mergeOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n newOptions: TableOptions<TFeatures, TData>,\n) {\n if (table.options.mergeOptions) {\n return table.options.mergeOptions(table.options, newOptions)\n }\n\n return {\n ...table.options,\n ...newOptions,\n }\n}\n\nexport function table_setOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<TableOptions<TFeatures, TData>>,\n): void {\n const newOptions = functionalUpdate(updater, table.options)\n const mergedOptions = table_mergeOptions(table, newOptions)\n table.optionsStore.setState(() => mergedOptions)\n}\n"],"mappings":";;;;AAOA,SAAgB,YAGd,OAA+C;CAC/C,MAAM,OAAO,gBAAgB,MAAM,aAAa;AAChD,aAAY;AACV,OAAK,MAAM,OAAO,OAAO,KAAK,KAAK,CAChC,CAAC,MAAM,UAAkB,KAAK,IAAI,KAAK,KAAY;GAEtD;;AAGJ,SAAgB,mBAId,OACA,YACA;AACA,KAAI,MAAM,QAAQ,aAChB,QAAO,MAAM,QAAQ,aAAa,MAAM,SAAS,WAAW;AAG9D,QAAO;EACL,GAAG,MAAM;EACT,GAAG;EACJ;;AAGH,SAAgB,iBAId,OACA,SACM;CAEN,MAAM,gBAAgB,mBAAmB,OADtB,iBAAiB,SAAS,MAAM,QAAQ,CACA;AAC3D,OAAM,aAAa,eAAe,cAAc"}
@@ -7,12 +7,15 @@ function constructColumnFacetingFeature() {
7
7
  assignColumnPrototype: (prototype, table) => {
8
8
  require_utils.assignPrototypeAPIs("columnFacetingFeature", prototype, table, {
9
9
  column_getFacetedRowModel: {
10
- memoDeps: () => [
11
- table.getPreFilteredRowModel().rows,
12
- table.store.state.columnFilters,
13
- table.store.state.globalFilter,
14
- table.getFilteredRowModel().rows
15
- ],
10
+ memoDeps: () => {
11
+ var _table$atoms$columnFi, _table$atoms$globalFi;
12
+ return [
13
+ table.getPreFilteredRowModel().rows,
14
+ (_table$atoms$columnFi = table.atoms.columnFilters) === null || _table$atoms$columnFi === void 0 ? void 0 : _table$atoms$columnFi.get(),
15
+ (_table$atoms$globalFi = table.atoms.globalFilter) === null || _table$atoms$globalFi === void 0 ? void 0 : _table$atoms$globalFi.get(),
16
+ table.getFilteredRowModel().rows
17
+ ];
18
+ },
16
19
  fn: (column) => require_columnFacetingFeature_utils.column_getFacetedRowModel(column, column.table)
17
20
  },
18
21
  column_getFacetedMinMaxValues: {
@@ -28,12 +31,15 @@ function constructColumnFacetingFeature() {
28
31
  constructTableAPIs: (table) => {
29
32
  require_utils.assignTableAPIs("columnFacetingFeature", table, {
30
33
  table_getGlobalFacetedRowModel: {
31
- memoDeps: () => [
32
- table.getPreFilteredRowModel().rows,
33
- table.store.state.columnFilters,
34
- table.store.state.globalFilter,
35
- table.getFilteredRowModel().rows
36
- ],
34
+ memoDeps: () => {
35
+ var _table$atoms$columnFi2, _table$atoms$globalFi2;
36
+ return [
37
+ table.getPreFilteredRowModel().rows,
38
+ (_table$atoms$columnFi2 = table.atoms.columnFilters) === null || _table$atoms$columnFi2 === void 0 ? void 0 : _table$atoms$columnFi2.get(),
39
+ (_table$atoms$globalFi2 = table.atoms.globalFilter) === null || _table$atoms$globalFi2 === void 0 ? void 0 : _table$atoms$globalFi2.get(),
40
+ table.getFilteredRowModel().rows
41
+ ];
42
+ },
37
43
  fn: () => require_columnFacetingFeature_utils.table_getGlobalFacetedRowModel(table)
38
44
  },
39
45
  table_getGlobalFacetedMinMaxValues: {
@@ -1 +1 @@
1
- {"version":3,"file":"columnFacetingFeature.cjs","names":["column_getFacetedRowModel","callMemoOrStaticFn","column_getFacetedMinMaxValues","column_getFacetedUniqueValues","table_getGlobalFacetedRowModel","table_getGlobalFacetedMinMaxValues","table_getGlobalFacetedUniqueValues"],"sources":["../../../src/features/column-faceting/columnFacetingFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n callMemoOrStaticFn,\n} from '../../utils'\nimport {\n column_getFacetedMinMaxValues,\n column_getFacetedRowModel,\n column_getFacetedUniqueValues,\n table_getGlobalFacetedMinMaxValues,\n table_getGlobalFacetedRowModel,\n table_getGlobalFacetedUniqueValues,\n} from './columnFacetingFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Column_Internal } from '../../types/Column'\n// import type {\n// CachedRowModel_Faceted,\n// Column_ColumnFaceting,\n// CreateRowModel_Faceted,\n// } from './columnFacetingFeature.types'\n\ninterface ColumnFacetingFeatureConstructors<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n // CachedRowModel: CachedRowModel_Faceted<TFeatures, TData>\n // Column: Column_ColumnFaceting<TFeatures, TData>\n // CreateRowModels: CreateRowModel_Faceted<TFeatures, TData>\n}\n\nexport function constructColumnFacetingFeature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): TableFeature<ColumnFacetingFeatureConstructors<TFeatures, TData>> {\n return {\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnFacetingFeature', prototype, table, {\n column_getFacetedRowModel: {\n memoDeps: () => [\n table.getPreFilteredRowModel().rows,\n table.store.state.columnFilters,\n table.store.state.globalFilter,\n table.getFilteredRowModel().rows,\n ],\n fn: (column) => column_getFacetedRowModel(column, column.table),\n },\n column_getFacetedMinMaxValues: {\n memoDeps: (column: Column_Internal<TFeatures, TData>) => [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n column.table,\n ).flatRows,\n ],\n fn: (column) => column_getFacetedMinMaxValues(column, column.table),\n },\n column_getFacetedUniqueValues: {\n memoDeps: (column: Column_Internal<TFeatures, TData>) => [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n column.table,\n ).flatRows,\n ],\n fn: (column) => column_getFacetedUniqueValues(column, column.table),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('columnFacetingFeature', table, {\n table_getGlobalFacetedRowModel: {\n memoDeps: () => [\n table.getPreFilteredRowModel().rows,\n table.store.state.columnFilters,\n table.store.state.globalFilter,\n table.getFilteredRowModel().rows,\n ],\n fn: () => table_getGlobalFacetedRowModel(table),\n },\n table_getGlobalFacetedMinMaxValues: {\n memoDeps: () => [\n callMemoOrStaticFn(\n table,\n 'getGlobalFacetedRowModel',\n table_getGlobalFacetedRowModel,\n ).flatRows,\n ],\n fn: () => table_getGlobalFacetedMinMaxValues(table),\n },\n table_getGlobalFacetedUniqueValues: {\n memoDeps: () => [\n callMemoOrStaticFn(\n table,\n 'getGlobalFacetedRowModel',\n table_getGlobalFacetedRowModel,\n ).flatRows,\n ],\n fn: () => table_getGlobalFacetedUniqueValues(table),\n },\n })\n },\n }\n}\n\n/**\n * The Column Faceting feature adds column faceting APIs to the column objects.\n */\nexport const columnFacetingFeature = constructColumnFacetingFeature()\n"],"mappings":";;;;AA+BA,SAAgB,iCAGuD;AACrE,QAAO;EACL,wBAAwB,WAAW,UAAU;AAC3C,qCAAoB,yBAAyB,WAAW,OAAO;IAC7D,2BAA2B;KACzB,gBAAgB;MACd,MAAM,wBAAwB,CAAC;MAC/B,MAAM,MAAM,MAAM;MAClB,MAAM,MAAM,MAAM;MAClB,MAAM,qBAAqB,CAAC;MAC7B;KACD,KAAK,WAAWA,8DAA0B,QAAQ,OAAO,MAAM;KAChE;IACD,+BAA+B;KAC7B,WAAW,WAA8C,CACvDC,iCACE,QACA,sBACAD,+DACA,OAAO,MACR,CAAC,SACH;KACD,KAAK,WAAWE,kEAA8B,QAAQ,OAAO,MAAM;KACpE;IACD,+BAA+B;KAC7B,WAAW,WAA8C,CACvDD,iCACE,QACA,sBACAD,+DACA,OAAO,MACR,CAAC,SACH;KACD,KAAK,WAAWG,kEAA8B,QAAQ,OAAO,MAAM;KACpE;IACF,CAAC;;EAGJ,qBAAqB,UAAU;AAC7B,iCAAgB,yBAAyB,OAAO;IAC9C,gCAAgC;KAC9B,gBAAgB;MACd,MAAM,wBAAwB,CAAC;MAC/B,MAAM,MAAM,MAAM;MAClB,MAAM,MAAM,MAAM;MAClB,MAAM,qBAAqB,CAAC;MAC7B;KACD,UAAUC,mEAA+B,MAAM;KAChD;IACD,oCAAoC;KAClC,gBAAgB,CACdH,iCACE,OACA,4BACAG,mEACD,CAAC,SACH;KACD,UAAUC,uEAAmC,MAAM;KACpD;IACD,oCAAoC;KAClC,gBAAgB,CACdJ,iCACE,OACA,4BACAG,mEACD,CAAC,SACH;KACD,UAAUE,uEAAmC,MAAM;KACpD;IACF,CAAC;;EAEL;;;;;AAMH,MAAa,wBAAwB,gCAAgC"}
1
+ {"version":3,"file":"columnFacetingFeature.cjs","names":["column_getFacetedRowModel","callMemoOrStaticFn","column_getFacetedMinMaxValues","column_getFacetedUniqueValues","table_getGlobalFacetedRowModel","table_getGlobalFacetedMinMaxValues","table_getGlobalFacetedUniqueValues"],"sources":["../../../src/features/column-faceting/columnFacetingFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n callMemoOrStaticFn,\n} from '../../utils'\nimport {\n column_getFacetedMinMaxValues,\n column_getFacetedRowModel,\n column_getFacetedUniqueValues,\n table_getGlobalFacetedMinMaxValues,\n table_getGlobalFacetedRowModel,\n table_getGlobalFacetedUniqueValues,\n} from './columnFacetingFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Column_Internal } from '../../types/Column'\n// import type {\n// CachedRowModel_Faceted,\n// Column_ColumnFaceting,\n// CreateRowModel_Faceted,\n// } from './columnFacetingFeature.types'\n\ninterface ColumnFacetingFeatureConstructors<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n // CachedRowModel: CachedRowModel_Faceted<TFeatures, TData>\n // Column: Column_ColumnFaceting<TFeatures, TData>\n // CreateRowModels: CreateRowModel_Faceted<TFeatures, TData>\n}\n\nexport function constructColumnFacetingFeature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): TableFeature<ColumnFacetingFeatureConstructors<TFeatures, TData>> {\n return {\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnFacetingFeature', prototype, table, {\n column_getFacetedRowModel: {\n memoDeps: () => [\n table.getPreFilteredRowModel().rows,\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel().rows,\n ],\n fn: (column) => column_getFacetedRowModel(column, column.table),\n },\n column_getFacetedMinMaxValues: {\n memoDeps: (column: Column_Internal<TFeatures, TData>) => [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n column.table,\n ).flatRows,\n ],\n fn: (column) => column_getFacetedMinMaxValues(column, column.table),\n },\n column_getFacetedUniqueValues: {\n memoDeps: (column: Column_Internal<TFeatures, TData>) => [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n column.table,\n ).flatRows,\n ],\n fn: (column) => column_getFacetedUniqueValues(column, column.table),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('columnFacetingFeature', table, {\n table_getGlobalFacetedRowModel: {\n memoDeps: () => [\n table.getPreFilteredRowModel().rows,\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel().rows,\n ],\n fn: () => table_getGlobalFacetedRowModel(table),\n },\n table_getGlobalFacetedMinMaxValues: {\n memoDeps: () => [\n callMemoOrStaticFn(\n table,\n 'getGlobalFacetedRowModel',\n table_getGlobalFacetedRowModel,\n ).flatRows,\n ],\n fn: () => table_getGlobalFacetedMinMaxValues(table),\n },\n table_getGlobalFacetedUniqueValues: {\n memoDeps: () => [\n callMemoOrStaticFn(\n table,\n 'getGlobalFacetedRowModel',\n table_getGlobalFacetedRowModel,\n ).flatRows,\n ],\n fn: () => table_getGlobalFacetedUniqueValues(table),\n },\n })\n },\n }\n}\n\n/**\n * The Column Faceting feature adds column faceting APIs to the column objects.\n */\nexport const columnFacetingFeature = constructColumnFacetingFeature()\n"],"mappings":";;;;AA+BA,SAAgB,iCAGuD;AACrE,QAAO;EACL,wBAAwB,WAAW,UAAU;AAC3C,qCAAoB,yBAAyB,WAAW,OAAO;IAC7D,2BAA2B;KACzB,gBAAgB;;;OACd,MAAM,wBAAwB,CAAC;gCAC/B,MAAM,MAAM,6FAAe,KAAK;gCAChC,MAAM,MAAM,4FAAc,KAAK;OAC/B,MAAM,qBAAqB,CAAC;OAC7B;;KACD,KAAK,WAAWA,8DAA0B,QAAQ,OAAO,MAAM;KAChE;IACD,+BAA+B;KAC7B,WAAW,WAA8C,CACvDC,iCACE,QACA,sBACAD,+DACA,OAAO,MACR,CAAC,SACH;KACD,KAAK,WAAWE,kEAA8B,QAAQ,OAAO,MAAM;KACpE;IACD,+BAA+B;KAC7B,WAAW,WAA8C,CACvDD,iCACE,QACA,sBACAD,+DACA,OAAO,MACR,CAAC,SACH;KACD,KAAK,WAAWG,kEAA8B,QAAQ,OAAO,MAAM;KACpE;IACF,CAAC;;EAGJ,qBAAqB,UAAU;AAC7B,iCAAgB,yBAAyB,OAAO;IAC9C,gCAAgC;KAC9B,gBAAgB;;;OACd,MAAM,wBAAwB,CAAC;iCAC/B,MAAM,MAAM,+FAAe,KAAK;iCAChC,MAAM,MAAM,8FAAc,KAAK;OAC/B,MAAM,qBAAqB,CAAC;OAC7B;;KACD,UAAUC,mEAA+B,MAAM;KAChD;IACD,oCAAoC;KAClC,gBAAgB,CACdH,iCACE,OACA,4BACAG,mEACD,CAAC,SACH;KACD,UAAUC,uEAAmC,MAAM;KACpD;IACD,oCAAoC;KAClC,gBAAgB,CACdJ,iCACE,OACA,4BACAG,mEACD,CAAC,SACH;KACD,UAAUE,uEAAmC,MAAM;KACpD;IACF,CAAC;;EAEL;;;;;AAMH,MAAa,wBAAwB,gCAAgC"}
@@ -7,12 +7,15 @@ function constructColumnFacetingFeature() {
7
7
  assignColumnPrototype: (prototype, table) => {
8
8
  assignPrototypeAPIs("columnFacetingFeature", prototype, table, {
9
9
  column_getFacetedRowModel: {
10
- memoDeps: () => [
11
- table.getPreFilteredRowModel().rows,
12
- table.store.state.columnFilters,
13
- table.store.state.globalFilter,
14
- table.getFilteredRowModel().rows
15
- ],
10
+ memoDeps: () => {
11
+ var _table$atoms$columnFi, _table$atoms$globalFi;
12
+ return [
13
+ table.getPreFilteredRowModel().rows,
14
+ (_table$atoms$columnFi = table.atoms.columnFilters) === null || _table$atoms$columnFi === void 0 ? void 0 : _table$atoms$columnFi.get(),
15
+ (_table$atoms$globalFi = table.atoms.globalFilter) === null || _table$atoms$globalFi === void 0 ? void 0 : _table$atoms$globalFi.get(),
16
+ table.getFilteredRowModel().rows
17
+ ];
18
+ },
16
19
  fn: (column) => column_getFacetedRowModel(column, column.table)
17
20
  },
18
21
  column_getFacetedMinMaxValues: {
@@ -28,12 +31,15 @@ function constructColumnFacetingFeature() {
28
31
  constructTableAPIs: (table) => {
29
32
  assignTableAPIs("columnFacetingFeature", table, {
30
33
  table_getGlobalFacetedRowModel: {
31
- memoDeps: () => [
32
- table.getPreFilteredRowModel().rows,
33
- table.store.state.columnFilters,
34
- table.store.state.globalFilter,
35
- table.getFilteredRowModel().rows
36
- ],
34
+ memoDeps: () => {
35
+ var _table$atoms$columnFi2, _table$atoms$globalFi2;
36
+ return [
37
+ table.getPreFilteredRowModel().rows,
38
+ (_table$atoms$columnFi2 = table.atoms.columnFilters) === null || _table$atoms$columnFi2 === void 0 ? void 0 : _table$atoms$columnFi2.get(),
39
+ (_table$atoms$globalFi2 = table.atoms.globalFilter) === null || _table$atoms$globalFi2 === void 0 ? void 0 : _table$atoms$globalFi2.get(),
40
+ table.getFilteredRowModel().rows
41
+ ];
42
+ },
37
43
  fn: () => table_getGlobalFacetedRowModel(table)
38
44
  },
39
45
  table_getGlobalFacetedMinMaxValues: {
@@ -1 +1 @@
1
- {"version":3,"file":"columnFacetingFeature.js","names":[],"sources":["../../../src/features/column-faceting/columnFacetingFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n callMemoOrStaticFn,\n} from '../../utils'\nimport {\n column_getFacetedMinMaxValues,\n column_getFacetedRowModel,\n column_getFacetedUniqueValues,\n table_getGlobalFacetedMinMaxValues,\n table_getGlobalFacetedRowModel,\n table_getGlobalFacetedUniqueValues,\n} from './columnFacetingFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Column_Internal } from '../../types/Column'\n// import type {\n// CachedRowModel_Faceted,\n// Column_ColumnFaceting,\n// CreateRowModel_Faceted,\n// } from './columnFacetingFeature.types'\n\ninterface ColumnFacetingFeatureConstructors<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n // CachedRowModel: CachedRowModel_Faceted<TFeatures, TData>\n // Column: Column_ColumnFaceting<TFeatures, TData>\n // CreateRowModels: CreateRowModel_Faceted<TFeatures, TData>\n}\n\nexport function constructColumnFacetingFeature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): TableFeature<ColumnFacetingFeatureConstructors<TFeatures, TData>> {\n return {\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnFacetingFeature', prototype, table, {\n column_getFacetedRowModel: {\n memoDeps: () => [\n table.getPreFilteredRowModel().rows,\n table.store.state.columnFilters,\n table.store.state.globalFilter,\n table.getFilteredRowModel().rows,\n ],\n fn: (column) => column_getFacetedRowModel(column, column.table),\n },\n column_getFacetedMinMaxValues: {\n memoDeps: (column: Column_Internal<TFeatures, TData>) => [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n column.table,\n ).flatRows,\n ],\n fn: (column) => column_getFacetedMinMaxValues(column, column.table),\n },\n column_getFacetedUniqueValues: {\n memoDeps: (column: Column_Internal<TFeatures, TData>) => [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n column.table,\n ).flatRows,\n ],\n fn: (column) => column_getFacetedUniqueValues(column, column.table),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('columnFacetingFeature', table, {\n table_getGlobalFacetedRowModel: {\n memoDeps: () => [\n table.getPreFilteredRowModel().rows,\n table.store.state.columnFilters,\n table.store.state.globalFilter,\n table.getFilteredRowModel().rows,\n ],\n fn: () => table_getGlobalFacetedRowModel(table),\n },\n table_getGlobalFacetedMinMaxValues: {\n memoDeps: () => [\n callMemoOrStaticFn(\n table,\n 'getGlobalFacetedRowModel',\n table_getGlobalFacetedRowModel,\n ).flatRows,\n ],\n fn: () => table_getGlobalFacetedMinMaxValues(table),\n },\n table_getGlobalFacetedUniqueValues: {\n memoDeps: () => [\n callMemoOrStaticFn(\n table,\n 'getGlobalFacetedRowModel',\n table_getGlobalFacetedRowModel,\n ).flatRows,\n ],\n fn: () => table_getGlobalFacetedUniqueValues(table),\n },\n })\n },\n }\n}\n\n/**\n * The Column Faceting feature adds column faceting APIs to the column objects.\n */\nexport const columnFacetingFeature = constructColumnFacetingFeature()\n"],"mappings":";;;;AA+BA,SAAgB,iCAGuD;AACrE,QAAO;EACL,wBAAwB,WAAW,UAAU;AAC3C,uBAAoB,yBAAyB,WAAW,OAAO;IAC7D,2BAA2B;KACzB,gBAAgB;MACd,MAAM,wBAAwB,CAAC;MAC/B,MAAM,MAAM,MAAM;MAClB,MAAM,MAAM,MAAM;MAClB,MAAM,qBAAqB,CAAC;MAC7B;KACD,KAAK,WAAW,0BAA0B,QAAQ,OAAO,MAAM;KAChE;IACD,+BAA+B;KAC7B,WAAW,WAA8C,CACvD,mBACE,QACA,sBACA,2BACA,OAAO,MACR,CAAC,SACH;KACD,KAAK,WAAW,8BAA8B,QAAQ,OAAO,MAAM;KACpE;IACD,+BAA+B;KAC7B,WAAW,WAA8C,CACvD,mBACE,QACA,sBACA,2BACA,OAAO,MACR,CAAC,SACH;KACD,KAAK,WAAW,8BAA8B,QAAQ,OAAO,MAAM;KACpE;IACF,CAAC;;EAGJ,qBAAqB,UAAU;AAC7B,mBAAgB,yBAAyB,OAAO;IAC9C,gCAAgC;KAC9B,gBAAgB;MACd,MAAM,wBAAwB,CAAC;MAC/B,MAAM,MAAM,MAAM;MAClB,MAAM,MAAM,MAAM;MAClB,MAAM,qBAAqB,CAAC;MAC7B;KACD,UAAU,+BAA+B,MAAM;KAChD;IACD,oCAAoC;KAClC,gBAAgB,CACd,mBACE,OACA,4BACA,+BACD,CAAC,SACH;KACD,UAAU,mCAAmC,MAAM;KACpD;IACD,oCAAoC;KAClC,gBAAgB,CACd,mBACE,OACA,4BACA,+BACD,CAAC,SACH;KACD,UAAU,mCAAmC,MAAM;KACpD;IACF,CAAC;;EAEL;;;;;AAMH,MAAa,wBAAwB,gCAAgC"}
1
+ {"version":3,"file":"columnFacetingFeature.js","names":[],"sources":["../../../src/features/column-faceting/columnFacetingFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n callMemoOrStaticFn,\n} from '../../utils'\nimport {\n column_getFacetedMinMaxValues,\n column_getFacetedRowModel,\n column_getFacetedUniqueValues,\n table_getGlobalFacetedMinMaxValues,\n table_getGlobalFacetedRowModel,\n table_getGlobalFacetedUniqueValues,\n} from './columnFacetingFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Column_Internal } from '../../types/Column'\n// import type {\n// CachedRowModel_Faceted,\n// Column_ColumnFaceting,\n// CreateRowModel_Faceted,\n// } from './columnFacetingFeature.types'\n\ninterface ColumnFacetingFeatureConstructors<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n // CachedRowModel: CachedRowModel_Faceted<TFeatures, TData>\n // Column: Column_ColumnFaceting<TFeatures, TData>\n // CreateRowModels: CreateRowModel_Faceted<TFeatures, TData>\n}\n\nexport function constructColumnFacetingFeature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): TableFeature<ColumnFacetingFeatureConstructors<TFeatures, TData>> {\n return {\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnFacetingFeature', prototype, table, {\n column_getFacetedRowModel: {\n memoDeps: () => [\n table.getPreFilteredRowModel().rows,\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel().rows,\n ],\n fn: (column) => column_getFacetedRowModel(column, column.table),\n },\n column_getFacetedMinMaxValues: {\n memoDeps: (column: Column_Internal<TFeatures, TData>) => [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n column.table,\n ).flatRows,\n ],\n fn: (column) => column_getFacetedMinMaxValues(column, column.table),\n },\n column_getFacetedUniqueValues: {\n memoDeps: (column: Column_Internal<TFeatures, TData>) => [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n column.table,\n ).flatRows,\n ],\n fn: (column) => column_getFacetedUniqueValues(column, column.table),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('columnFacetingFeature', table, {\n table_getGlobalFacetedRowModel: {\n memoDeps: () => [\n table.getPreFilteredRowModel().rows,\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel().rows,\n ],\n fn: () => table_getGlobalFacetedRowModel(table),\n },\n table_getGlobalFacetedMinMaxValues: {\n memoDeps: () => [\n callMemoOrStaticFn(\n table,\n 'getGlobalFacetedRowModel',\n table_getGlobalFacetedRowModel,\n ).flatRows,\n ],\n fn: () => table_getGlobalFacetedMinMaxValues(table),\n },\n table_getGlobalFacetedUniqueValues: {\n memoDeps: () => [\n callMemoOrStaticFn(\n table,\n 'getGlobalFacetedRowModel',\n table_getGlobalFacetedRowModel,\n ).flatRows,\n ],\n fn: () => table_getGlobalFacetedUniqueValues(table),\n },\n })\n },\n }\n}\n\n/**\n * The Column Faceting feature adds column faceting APIs to the column objects.\n */\nexport const columnFacetingFeature = constructColumnFacetingFeature()\n"],"mappings":";;;;AA+BA,SAAgB,iCAGuD;AACrE,QAAO;EACL,wBAAwB,WAAW,UAAU;AAC3C,uBAAoB,yBAAyB,WAAW,OAAO;IAC7D,2BAA2B;KACzB,gBAAgB;;;OACd,MAAM,wBAAwB,CAAC;gCAC/B,MAAM,MAAM,6FAAe,KAAK;gCAChC,MAAM,MAAM,4FAAc,KAAK;OAC/B,MAAM,qBAAqB,CAAC;OAC7B;;KACD,KAAK,WAAW,0BAA0B,QAAQ,OAAO,MAAM;KAChE;IACD,+BAA+B;KAC7B,WAAW,WAA8C,CACvD,mBACE,QACA,sBACA,2BACA,OAAO,MACR,CAAC,SACH;KACD,KAAK,WAAW,8BAA8B,QAAQ,OAAO,MAAM;KACpE;IACD,+BAA+B;KAC7B,WAAW,WAA8C,CACvD,mBACE,QACA,sBACA,2BACA,OAAO,MACR,CAAC,SACH;KACD,KAAK,WAAW,8BAA8B,QAAQ,OAAO,MAAM;KACpE;IACF,CAAC;;EAGJ,qBAAqB,UAAU;AAC7B,mBAAgB,yBAAyB,OAAO;IAC9C,gCAAgC;KAC9B,gBAAgB;;;OACd,MAAM,wBAAwB,CAAC;iCAC/B,MAAM,MAAM,+FAAe,KAAK;iCAChC,MAAM,MAAM,8FAAc,KAAK;OAC/B,MAAM,qBAAqB,CAAC;OAC7B;;KACD,UAAU,+BAA+B,MAAM;KAChD;IACD,oCAAoC;KAClC,gBAAgB,CACd,mBACE,OACA,4BACA,+BACD,CAAC,SACH;KACD,UAAU,mCAAmC,MAAM;KACpD;IACD,oCAAoC;KAClC,gBAAgB,CACd,mBACE,OACA,4BACA,+BACD,CAAC,SACH;KACD,UAAU,mCAAmC,MAAM;KACpD;IACF,CAAC;;EAEL;;;;;AAMH,MAAa,wBAAwB,gCAAgC"}
@@ -9,12 +9,15 @@ function createFacetedRowModel() {
9
9
  feature: "columnFacetingFeature",
10
10
  table,
11
11
  fnName: "createFacetedRowModel",
12
- memoDeps: () => [
13
- table.getPreFilteredRowModel(),
14
- table.store.state.columnFilters,
15
- table.store.state.globalFilter,
16
- table.getFilteredRowModel()
17
- ],
12
+ memoDeps: () => {
13
+ var _table$atoms$columnFi, _table$atoms$globalFi;
14
+ return [
15
+ table.getPreFilteredRowModel(),
16
+ (_table$atoms$columnFi = table.atoms.columnFilters) === null || _table$atoms$columnFi === void 0 ? void 0 : _table$atoms$columnFi.get(),
17
+ (_table$atoms$globalFi = table.atoms.globalFilter) === null || _table$atoms$globalFi === void 0 ? void 0 : _table$atoms$globalFi.get(),
18
+ table.getFilteredRowModel()
19
+ ];
20
+ },
18
21
  fn: (preRowModel, columnFilters, globalFilter) => _createFacetedRowModel(table, columnId, preRowModel, columnFilters, globalFilter)
19
22
  });
20
23
  };
@@ -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\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 Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.store.state.columnFilters,\n table.store.state.globalFilter,\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 = [\n ...(columnFilters?.map((d) => d.id).filter((d) => d !== columnId) ?? []),\n globalFilter ? '__global__' : undefined,\n ].filter(Boolean) as Array<string>\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (const colId of filterableIds) {\n if (row.columnFilters?.[colId] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;AAYA,SAAgB,wBAMsB;AACpC,SAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;AACd,SAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,wBAAwB;IAC9B,MAAM,MAAM,MAAM;IAClB,MAAM,MAAM,MAAM;IAClB,MAAM,qBAAqB;IAC5B;GACD,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,aACD;GACJ,CAAC;;;AAIN,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;AACA,KAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,aAC1D,QAAO;CAGT,MAAM,gBAAgB,CACpB,kEAAI,cAAe,KAAK,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,MAAM,SAAS,KAAI,EAAE,EACvE,eAAe,eAAe,OAC/B,CAAC,OAAO,QAAQ;CAEjB,MAAM,kBACJ,QACG;AAEH,OAAK,MAAM,SAAS,eAAe;;AACjC,8BAAI,IAAI,uFAAgB,YAAW,MACjC,QAAO;;AAGX,SAAO;;AAGT,QAAOC,mCAAW,YAAY,MAAM,gBAAgB,MAAM"}
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\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 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 = [\n ...(columnFilters?.map((d) => d.id).filter((d) => d !== columnId) ?? []),\n globalFilter ? '__global__' : undefined,\n ].filter(Boolean) as Array<string>\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (const colId of filterableIds) {\n if (row.columnFilters?.[colId] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;AAYA,SAAgB,wBAMsB;AACpC,SAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;AACd,SAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,wBAAwB;8BAC9B,MAAM,MAAM,6FAAe,KAAK;8BAChC,MAAM,MAAM,4FAAc,KAAK;KAC/B,MAAM,qBAAqB;KAC5B;;GACD,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,aACD;GACJ,CAAC;;;AAIN,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;AACA,KAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,aAC1D,QAAO;CAGT,MAAM,gBAAgB,CACpB,kEAAI,cAAe,KAAK,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,MAAM,SAAS,KAAI,EAAE,EACvE,eAAe,eAAe,OAC/B,CAAC,OAAO,QAAQ;CAEjB,MAAM,kBACJ,QACG;AAEH,OAAK,MAAM,SAAS,eAAe;;AACjC,8BAAI,IAAI,uFAAgB,YAAW,MACjC,QAAO;;AAGX,SAAO;;AAGT,QAAOC,mCAAW,YAAY,MAAM,gBAAgB,MAAM"}
@@ -9,12 +9,15 @@ function createFacetedRowModel() {
9
9
  feature: "columnFacetingFeature",
10
10
  table,
11
11
  fnName: "createFacetedRowModel",
12
- memoDeps: () => [
13
- table.getPreFilteredRowModel(),
14
- table.store.state.columnFilters,
15
- table.store.state.globalFilter,
16
- table.getFilteredRowModel()
17
- ],
12
+ memoDeps: () => {
13
+ var _table$atoms$columnFi, _table$atoms$globalFi;
14
+ return [
15
+ table.getPreFilteredRowModel(),
16
+ (_table$atoms$columnFi = table.atoms.columnFilters) === null || _table$atoms$columnFi === void 0 ? void 0 : _table$atoms$columnFi.get(),
17
+ (_table$atoms$globalFi = table.atoms.globalFilter) === null || _table$atoms$globalFi === void 0 ? void 0 : _table$atoms$globalFi.get(),
18
+ table.getFilteredRowModel()
19
+ ];
20
+ },
18
21
  fn: (preRowModel, columnFilters, globalFilter) => _createFacetedRowModel(table, columnId, preRowModel, columnFilters, globalFilter)
19
22
  });
20
23
  };
@@ -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\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 Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.store.state.columnFilters,\n table.store.state.globalFilter,\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 = [\n ...(columnFilters?.map((d) => d.id).filter((d) => d !== columnId) ?? []),\n globalFilter ? '__global__' : undefined,\n ].filter(Boolean) as Array<string>\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (const colId of filterableIds) {\n if (row.columnFilters?.[colId] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;AAYA,SAAgB,wBAMsB;AACpC,SAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;AACd,SAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,wBAAwB;IAC9B,MAAM,MAAM,MAAM;IAClB,MAAM,MAAM,MAAM;IAClB,MAAM,qBAAqB;IAC5B;GACD,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,aACD;GACJ,CAAC;;;AAIN,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;AACA,KAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,aAC1D,QAAO;CAGT,MAAM,gBAAgB,CACpB,kEAAI,cAAe,KAAK,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,MAAM,SAAS,KAAI,EAAE,EACvE,eAAe,eAAe,OAC/B,CAAC,OAAO,QAAQ;CAEjB,MAAM,kBACJ,QACG;AAEH,OAAK,MAAM,SAAS,eAAe;;AACjC,8BAAI,IAAI,uFAAgB,YAAW,MACjC,QAAO;;AAGX,SAAO;;AAGT,QAAO,WAAW,YAAY,MAAM,gBAAgB,MAAM"}
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\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 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 = [\n ...(columnFilters?.map((d) => d.id).filter((d) => d !== columnId) ?? []),\n globalFilter ? '__global__' : undefined,\n ].filter(Boolean) as Array<string>\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (const colId of filterableIds) {\n if (row.columnFilters?.[colId] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;AAYA,SAAgB,wBAMsB;AACpC,SAAQ,QAAQ,aAAa;EAC3B,MAAM,QAAQ;AACd,SAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,wBAAwB;8BAC9B,MAAM,MAAM,6FAAe,KAAK;8BAChC,MAAM,MAAM,4FAAc,KAAK;KAC/B,MAAM,qBAAqB;KAC5B;;GACD,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,aACD;GACJ,CAAC;;;AAIN,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;AACA,KAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,aAC1D,QAAO;CAGT,MAAM,gBAAgB,CACpB,kEAAI,cAAe,KAAK,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,MAAM,SAAS,KAAI,EAAE,EACvE,eAAe,eAAe,OAC/B,CAAC,OAAO,QAAQ;CAEjB,MAAM,kBACJ,QACG;AAEH,OAAK,MAAM,SAAS,eAAe;;AACjC,8BAAI,IAAI,uFAAgB,YAAW,MACjC,QAAO;;AAGX,SAAO;;AAGT,QAAO,WAAW,YAAY,MAAM,gBAAgB,MAAM"}
@@ -29,12 +29,12 @@ function column_getIsFiltered(column) {
29
29
  return column_getFilterIndex(column) > -1;
30
30
  }
31
31
  function column_getFilterValue(column) {
32
- var _column$table$store$s;
33
- return (_column$table$store$s = column.table.store.state.columnFilters) === null || _column$table$store$s === void 0 || (_column$table$store$s = _column$table$store$s.find((d) => d.id === column.id)) === null || _column$table$store$s === void 0 ? void 0 : _column$table$store$s.value;
32
+ var _column$table$atoms$c;
33
+ return (_column$table$atoms$c = column.table.atoms.columnFilters) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.get()) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.find((d) => d.id === column.id)) === null || _column$table$atoms$c === void 0 ? void 0 : _column$table$atoms$c.value;
34
34
  }
35
35
  function column_getFilterIndex(column) {
36
- var _column$table$store$s2;
37
- return ((_column$table$store$s2 = column.table.store.state.columnFilters) === null || _column$table$store$s2 === void 0 ? void 0 : _column$table$store$s2.findIndex((d) => d.id === column.id)) ?? -1;
36
+ var _column$table$atoms$c2;
37
+ return ((_column$table$atoms$c2 = column.table.atoms.columnFilters) === null || _column$table$atoms$c2 === void 0 || (_column$table$atoms$c2 = _column$table$atoms$c2.get()) === null || _column$table$atoms$c2 === void 0 ? void 0 : _column$table$atoms$c2.findIndex((d) => d.id === column.id)) ?? -1;
38
38
  }
39
39
  function column_setFilterValue(column, value) {
40
40
  table_setColumnFilters(column.table, (old) => {
@@ -1 +1 @@
1
- {"version":3,"file":"columnFilteringFeature.utils.cjs","names":["isFunction","functionalUpdate"],"sources":["../../../src/features/column-filtering/columnFilteringFeature.utils.ts"],"sourcesContent":["import { functionalUpdate, isFunction } from '../../utils'\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 {\n ColumnFiltersState,\n FilterFn,\n} from './columnFilteringFeature.types'\n\nexport function getDefaultColumnFiltersState(): ColumnFiltersState {\n return structuredClone([])\n}\n\nexport function column_getAutoFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const filterFns = column.table._rowModelFns.filterFns as\n | Record<string, FilterFn<TFeatures, TData>>\n | undefined\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow ? firstRow.getValue(column.id) : undefined\n\n if (typeof value === 'string') {\n return filterFns?.includesString\n }\n\n if (typeof value === 'number') {\n return filterFns?.inNumberRange\n }\n\n if (typeof value === 'boolean') {\n return filterFns?.equals\n }\n\n if (value !== null && typeof value === 'object') {\n return filterFns?.equals\n }\n\n if (Array.isArray(value)) {\n return filterFns?.arrIncludes\n }\n\n return filterFns?.weakEquals\n}\n\nexport function column_getFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n): FilterFn<TFeatures, TData> | undefined {\n let filterFn = null\n const filterFns = column.table._rowModelFns.filterFns as\n | Record<string, FilterFn<TFeatures, TData>>\n | undefined\n filterFn = isFunction(column.columnDef.filterFn)\n ? column.columnDef.filterFn\n : column.columnDef.filterFn === 'auto'\n ? column_getAutoFilterFn(column)\n : filterFns?.[column.columnDef.filterFn as string]\n\n if (process.env.NODE_ENV === 'development' && !filterFn) {\n console.warn(\n `Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`,\n )\n }\n\n return filterFn\n}\n\nexport function column_getCanFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableColumnFilter ?? true) &&\n (column.table.options.enableColumnFilters ?? true) &&\n (column.table.options.enableFilters ?? true) &&\n !!column.accessorFn\n )\n}\n\nexport function column_getIsFiltered<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column_getFilterIndex(column) > -1\n}\n\nexport function column_getFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column.table.store.state.columnFilters?.find((d) => d.id === column.id)\n ?.value\n}\n\nexport function column_getFilterIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return (\n column.table.store.state.columnFilters?.findIndex(\n (d) => d.id === column.id,\n ) ?? -1\n )\n}\n\nexport function column_setFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, value: any) {\n table_setColumnFilters(column.table, (old) => {\n const filterFn = column_getFilterFn(column)\n const previousFilter = old.find((d) => d.id === column.id)\n\n const newFilter = functionalUpdate(\n value,\n previousFilter ? previousFilter.value : undefined,\n )\n\n if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {\n return old.filter((d) => d.id !== column.id)\n }\n\n const newFilterObj = { id: column.id, value: newFilter }\n\n if (previousFilter) {\n return old.map((d) => {\n if (d.id === column.id) {\n return newFilterObj\n }\n return d\n })\n }\n\n if (old.length) {\n return [...old, newFilterObj]\n }\n\n return [newFilterObj]\n })\n}\n\nexport function table_setColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnFiltersState>,\n) {\n const leafColumns = table.getAllLeafColumns()\n\n const updateFn = (old: ColumnFiltersState) => {\n return functionalUpdate(updater, old).filter((filter) => {\n const column = leafColumns.find((d) => d.id === filter.id)\n\n if (column) {\n const filterFn = column_getFilterFn(column)\n\n if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {\n return false\n }\n }\n\n return true\n })\n }\n\n table.options.onColumnFiltersChange?.(updateFn)\n}\n\nexport function table_resetColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnFilters(\n table,\n defaultState ? [] : (table.initialState.columnFilters ?? []),\n )\n}\n\nexport function shouldAutoRemoveFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n filterFn?: FilterFn<TFeatures, TData>,\n value?: any,\n column?: Column_Internal<TFeatures, TData, TValue>,\n) {\n return (\n (filterFn && filterFn.autoRemove\n ? filterFn.autoRemove(\n value,\n column as Column_Internal<TFeatures, TData, unknown>,\n )\n : false) ||\n typeof value === 'undefined' ||\n (typeof value === 'string' && !value)\n )\n}\n"],"mappings":";;;AAUA,SAAgB,+BAAmD;AACjE,QAAO,gBAAgB,EAAE,CAAC;;AAG5B,SAAgB,uBAId,QAAmD;CACnD,MAAM,YAAY,OAAO,MAAM,aAAa;CAI5C,MAAM,WAAW,OAAO,MAAM,iBAAiB,CAAC,SAAS;CAEzD,MAAM,QAAQ,WAAW,SAAS,SAAS,OAAO,GAAG,GAAG;AAExD,KAAI,OAAO,UAAU,SACnB,8DAAO,UAAW;AAGpB,KAAI,OAAO,UAAU,SACnB,8DAAO,UAAW;AAGpB,KAAI,OAAO,UAAU,UACnB,8DAAO,UAAW;AAGpB,KAAI,UAAU,QAAQ,OAAO,UAAU,SACrC,8DAAO,UAAW;AAGpB,KAAI,MAAM,QAAQ,MAAM,CACtB,8DAAO,UAAW;AAGpB,8DAAO,UAAW;;AAGpB,SAAgB,mBAKd,QACwC;CACxC,IAAI,WAAW;CACf,MAAM,YAAY,OAAO,MAAM,aAAa;AAG5C,YAAWA,yBAAW,OAAO,UAAU,SAAS,GAC5C,OAAO,UAAU,WACjB,OAAO,UAAU,aAAa,SAC5B,uBAAuB,OAAO,yDAC9B,UAAY,OAAO,UAAU;AAEnC,KAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,SAC7C,SAAQ,KACN,oEAAoE,OAAO,GAAG,GAC/E;AAGH,QAAO;;AAGT,SAAgB,oBAId,QAAmD;AACnD,SACG,OAAO,UAAU,sBAAsB,UACvC,OAAO,MAAM,QAAQ,uBAAuB,UAC5C,OAAO,MAAM,QAAQ,iBAAiB,SACvC,CAAC,CAAC,OAAO;;AAIb,SAAgB,qBAId,QAAmD;AACnD,QAAO,sBAAsB,OAAO,GAAG;;AAGzC,SAAgB,sBAId,QAAmD;;AACnD,iCAAO,OAAO,MAAM,MAAM,MAAM,8GAAe,MAAM,MAAM,EAAE,OAAO,OAAO,GAAG,gFAC1E;;AAGN,SAAgB,sBAId,QAA2D;;AAC3D,mCACE,OAAO,MAAM,MAAM,MAAM,+FAAe,WACrC,MAAM,EAAE,OAAO,OAAO,GACxB,KAAI;;AAIT,SAAgB,sBAId,QAAmD,OAAY;AAC/D,wBAAuB,OAAO,QAAQ,QAAQ;EAC5C,MAAM,WAAW,mBAAmB,OAAO;EAC3C,MAAM,iBAAiB,IAAI,MAAM,MAAM,EAAE,OAAO,OAAO,GAAG;EAE1D,MAAM,YAAYC,+BAChB,OACA,iBAAiB,eAAe,QAAQ,OACzC;AAED,MAAI,uBAAuB,UAAU,WAAW,OAAO,CACrD,QAAO,IAAI,QAAQ,MAAM,EAAE,OAAO,OAAO,GAAG;EAG9C,MAAM,eAAe;GAAE,IAAI,OAAO;GAAI,OAAO;GAAW;AAExD,MAAI,eACF,QAAO,IAAI,KAAK,MAAM;AACpB,OAAI,EAAE,OAAO,OAAO,GAClB,QAAO;AAET,UAAO;IACP;AAGJ,MAAI,IAAI,OACN,QAAO,CAAC,GAAG,KAAK,aAAa;AAG/B,SAAO,CAAC,aAAa;GACrB;;AAGJ,SAAgB,uBAId,OACA,SACA;;CACA,MAAM,cAAc,MAAM,mBAAmB;CAE7C,MAAM,YAAY,QAA4B;AAC5C,SAAOA,+BAAiB,SAAS,IAAI,CAAC,QAAQ,WAAW;GACvD,MAAM,SAAS,YAAY,MAAM,MAAM,EAAE,OAAO,OAAO,GAAG;AAE1D,OAAI,QAGF;QAAI,uBAFa,mBAAmB,OAAO,EAEN,OAAO,OAAO,OAAO,CACxD,QAAO;;AAIX,UAAO;IACP;;AAGJ,kDAAM,SAAQ,kHAAwB,SAAS;;AAGjD,SAAgB,yBAGd,OAAyC,cAAwB;AACjE,wBACE,OACA,eAAe,EAAE,GAAI,MAAM,aAAa,iBAAiB,EAAE,CAC5D;;AAGH,SAAgB,uBAKd,UACA,OACA,QACA;AACA,SACG,YAAY,SAAS,aAClB,SAAS,WACP,OACA,OACD,GACD,UACJ,OAAO,UAAU,eAChB,OAAO,UAAU,YAAY,CAAC"}
1
+ {"version":3,"file":"columnFilteringFeature.utils.cjs","names":["isFunction","functionalUpdate"],"sources":["../../../src/features/column-filtering/columnFilteringFeature.utils.ts"],"sourcesContent":["import { functionalUpdate, isFunction } from '../../utils'\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 {\n ColumnFiltersState,\n FilterFn,\n} from './columnFilteringFeature.types'\n\nexport function getDefaultColumnFiltersState(): ColumnFiltersState {\n return structuredClone([])\n}\n\nexport function column_getAutoFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const filterFns = column.table._rowModelFns.filterFns as\n | Record<string, FilterFn<TFeatures, TData>>\n | undefined\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow ? firstRow.getValue(column.id) : undefined\n\n if (typeof value === 'string') {\n return filterFns?.includesString\n }\n\n if (typeof value === 'number') {\n return filterFns?.inNumberRange\n }\n\n if (typeof value === 'boolean') {\n return filterFns?.equals\n }\n\n if (value !== null && typeof value === 'object') {\n return filterFns?.equals\n }\n\n if (Array.isArray(value)) {\n return filterFns?.arrIncludes\n }\n\n return filterFns?.weakEquals\n}\n\nexport function column_getFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n): FilterFn<TFeatures, TData> | undefined {\n let filterFn = null\n const filterFns = column.table._rowModelFns.filterFns as\n | Record<string, FilterFn<TFeatures, TData>>\n | undefined\n filterFn = isFunction(column.columnDef.filterFn)\n ? column.columnDef.filterFn\n : column.columnDef.filterFn === 'auto'\n ? column_getAutoFilterFn(column)\n : filterFns?.[column.columnDef.filterFn as string]\n\n if (process.env.NODE_ENV === 'development' && !filterFn) {\n console.warn(\n `Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`,\n )\n }\n\n return filterFn\n}\n\nexport function column_getCanFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableColumnFilter ?? true) &&\n (column.table.options.enableColumnFilters ?? true) &&\n (column.table.options.enableFilters ?? true) &&\n !!column.accessorFn\n )\n}\n\nexport function column_getIsFiltered<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column_getFilterIndex(column) > -1\n}\n\nexport function column_getFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column.table.atoms.columnFilters\n ?.get()\n ?.find((d) => d.id === column.id)?.value\n}\n\nexport function column_getFilterIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return (\n column.table.atoms.columnFilters\n ?.get()\n ?.findIndex((d) => d.id === column.id) ?? -1\n )\n}\n\nexport function column_setFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, value: any) {\n table_setColumnFilters(column.table, (old) => {\n const filterFn = column_getFilterFn(column)\n const previousFilter = old.find((d) => d.id === column.id)\n\n const newFilter = functionalUpdate(\n value,\n previousFilter ? previousFilter.value : undefined,\n )\n\n if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {\n return old.filter((d) => d.id !== column.id)\n }\n\n const newFilterObj = { id: column.id, value: newFilter }\n\n if (previousFilter) {\n return old.map((d) => {\n if (d.id === column.id) {\n return newFilterObj\n }\n return d\n })\n }\n\n if (old.length) {\n return [...old, newFilterObj]\n }\n\n return [newFilterObj]\n })\n}\n\nexport function table_setColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnFiltersState>,\n) {\n const leafColumns = table.getAllLeafColumns()\n\n const updateFn = (old: ColumnFiltersState) => {\n return functionalUpdate(updater, old).filter((filter) => {\n const column = leafColumns.find((d) => d.id === filter.id)\n\n if (column) {\n const filterFn = column_getFilterFn(column)\n\n if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {\n return false\n }\n }\n\n return true\n })\n }\n\n table.options.onColumnFiltersChange?.(updateFn)\n}\n\nexport function table_resetColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnFilters(\n table,\n defaultState ? [] : (table.initialState.columnFilters ?? []),\n )\n}\n\nexport function shouldAutoRemoveFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n filterFn?: FilterFn<TFeatures, TData>,\n value?: any,\n column?: Column_Internal<TFeatures, TData, TValue>,\n) {\n return (\n (filterFn && filterFn.autoRemove\n ? filterFn.autoRemove(\n value,\n column as Column_Internal<TFeatures, TData, unknown>,\n )\n : false) ||\n typeof value === 'undefined' ||\n (typeof value === 'string' && !value)\n )\n}\n"],"mappings":"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"}
@@ -29,12 +29,12 @@ function column_getIsFiltered(column) {
29
29
  return column_getFilterIndex(column) > -1;
30
30
  }
31
31
  function column_getFilterValue(column) {
32
- var _column$table$store$s;
33
- return (_column$table$store$s = column.table.store.state.columnFilters) === null || _column$table$store$s === void 0 || (_column$table$store$s = _column$table$store$s.find((d) => d.id === column.id)) === null || _column$table$store$s === void 0 ? void 0 : _column$table$store$s.value;
32
+ var _column$table$atoms$c;
33
+ return (_column$table$atoms$c = column.table.atoms.columnFilters) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.get()) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.find((d) => d.id === column.id)) === null || _column$table$atoms$c === void 0 ? void 0 : _column$table$atoms$c.value;
34
34
  }
35
35
  function column_getFilterIndex(column) {
36
- var _column$table$store$s2;
37
- return ((_column$table$store$s2 = column.table.store.state.columnFilters) === null || _column$table$store$s2 === void 0 ? void 0 : _column$table$store$s2.findIndex((d) => d.id === column.id)) ?? -1;
36
+ var _column$table$atoms$c2;
37
+ return ((_column$table$atoms$c2 = column.table.atoms.columnFilters) === null || _column$table$atoms$c2 === void 0 || (_column$table$atoms$c2 = _column$table$atoms$c2.get()) === null || _column$table$atoms$c2 === void 0 ? void 0 : _column$table$atoms$c2.findIndex((d) => d.id === column.id)) ?? -1;
38
38
  }
39
39
  function column_setFilterValue(column, value) {
40
40
  table_setColumnFilters(column.table, (old) => {