@tanstack/table-core 9.0.0-beta.15 → 9.0.0-beta.17

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 (160) hide show
  1. package/dist/core/cells/constructCell.d.cts +2 -2
  2. package/dist/core/cells/constructCell.d.ts +2 -2
  3. package/dist/core/cells/coreCellsFeature.types.d.cts +2 -2
  4. package/dist/core/cells/coreCellsFeature.types.d.ts +2 -2
  5. package/dist/core/cells/coreCellsFeature.utils.d.cts +2 -2
  6. package/dist/core/cells/coreCellsFeature.utils.d.ts +2 -2
  7. package/dist/core/columns/constructColumn.d.cts +2 -2
  8. package/dist/core/columns/constructColumn.d.ts +2 -2
  9. package/dist/core/columns/coreColumnsFeature.types.d.cts +2 -2
  10. package/dist/core/columns/coreColumnsFeature.types.d.ts +2 -2
  11. package/dist/core/columns/coreColumnsFeature.utils.cjs +2 -2
  12. package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
  13. package/dist/core/columns/coreColumnsFeature.utils.d.cts +8 -8
  14. package/dist/core/columns/coreColumnsFeature.utils.d.ts +8 -8
  15. package/dist/core/columns/coreColumnsFeature.utils.js +3 -3
  16. package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
  17. package/dist/core/headers/buildHeaderGroups.d.cts +2 -2
  18. package/dist/core/headers/buildHeaderGroups.d.ts +2 -2
  19. package/dist/core/headers/constructHeader.d.cts +2 -2
  20. package/dist/core/headers/constructHeader.d.ts +2 -2
  21. package/dist/core/headers/coreHeadersFeature.utils.d.cts +6 -6
  22. package/dist/core/headers/coreHeadersFeature.utils.d.ts +6 -6
  23. package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +13 -13
  24. package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +13 -13
  25. package/dist/core/row-models/createCoreRowModel.cjs +1 -1
  26. package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
  27. package/dist/core/row-models/createCoreRowModel.d.cts +2 -2
  28. package/dist/core/row-models/createCoreRowModel.d.ts +2 -2
  29. package/dist/core/row-models/createCoreRowModel.js +2 -2
  30. package/dist/core/row-models/createCoreRowModel.js.map +1 -1
  31. package/dist/core/rows/constructRow.cjs +3 -2
  32. package/dist/core/rows/constructRow.cjs.map +1 -1
  33. package/dist/core/rows/constructRow.d.cts +2 -2
  34. package/dist/core/rows/constructRow.d.ts +2 -2
  35. package/dist/core/rows/constructRow.js +4 -2
  36. package/dist/core/rows/constructRow.js.map +1 -1
  37. package/dist/core/rows/coreRowsFeature.types.d.cts +2 -2
  38. package/dist/core/rows/coreRowsFeature.types.d.ts +2 -2
  39. package/dist/core/rows/coreRowsFeature.utils.cjs +3 -3
  40. package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
  41. package/dist/core/rows/coreRowsFeature.utils.d.cts +3 -3
  42. package/dist/core/rows/coreRowsFeature.utils.d.ts +3 -3
  43. package/dist/core/rows/coreRowsFeature.utils.js +4 -4
  44. package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
  45. package/dist/core/table/coreTablesFeature.types.d.cts +1 -1
  46. package/dist/core/table/coreTablesFeature.types.d.ts +1 -1
  47. package/dist/core/table/coreTablesFeature.utils.d.cts +5 -5
  48. package/dist/core/table/coreTablesFeature.utils.d.ts +5 -5
  49. package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +8 -8
  50. package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +8 -8
  51. package/dist/features/column-filtering/columnFilteringFeature.cjs +2 -2
  52. package/dist/features/column-filtering/columnFilteringFeature.cjs.map +1 -1
  53. package/dist/features/column-filtering/columnFilteringFeature.js +3 -3
  54. package/dist/features/column-filtering/columnFilteringFeature.js.map +1 -1
  55. package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +12 -12
  56. package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +12 -12
  57. package/dist/features/column-filtering/createFilteredRowModel.cjs +8 -5
  58. package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
  59. package/dist/features/column-filtering/createFilteredRowModel.js +9 -6
  60. package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
  61. package/dist/features/column-filtering/filterRowsUtils.cjs +3 -2
  62. package/dist/features/column-filtering/filterRowsUtils.cjs.map +1 -1
  63. package/dist/features/column-filtering/filterRowsUtils.js +3 -2
  64. package/dist/features/column-filtering/filterRowsUtils.js.map +1 -1
  65. package/dist/features/column-grouping/columnGroupingFeature.cjs +1 -1
  66. package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
  67. package/dist/features/column-grouping/columnGroupingFeature.js +2 -2
  68. package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
  69. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +3 -3
  70. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  71. package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +11 -11
  72. package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +11 -11
  73. package/dist/features/column-grouping/columnGroupingFeature.utils.js +4 -4
  74. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  75. package/dist/features/column-grouping/createGroupedRowModel.cjs +4 -5
  76. package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
  77. package/dist/features/column-grouping/createGroupedRowModel.js +5 -6
  78. package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
  79. package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +9 -9
  80. package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +9 -9
  81. package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +29 -29
  82. package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +29 -29
  83. package/dist/features/column-resizing/columnResizingFeature.utils.cjs +2 -5
  84. package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
  85. package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +6 -6
  86. package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +6 -6
  87. package/dist/features/column-resizing/columnResizingFeature.utils.js +3 -6
  88. package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
  89. package/dist/features/column-sizing/columnSizingFeature.utils.cjs +11 -4
  90. package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
  91. package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +12 -12
  92. package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +12 -12
  93. package/dist/features/column-sizing/columnSizingFeature.utils.js +12 -5
  94. package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
  95. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +12 -9
  96. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
  97. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +14 -14
  98. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +14 -14
  99. package/dist/features/column-visibility/columnVisibilityFeature.utils.js +13 -10
  100. package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
  101. package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +6 -6
  102. package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +6 -6
  103. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +21 -12
  104. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
  105. package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +10 -10
  106. package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +10 -10
  107. package/dist/features/row-expanding/rowExpandingFeature.utils.js +22 -13
  108. package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
  109. package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +17 -17
  110. package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +17 -17
  111. package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +7 -7
  112. package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +7 -7
  113. package/dist/features/row-selection/rowSelectionFeature.utils.cjs +15 -12
  114. package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
  115. package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +27 -15
  116. package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +27 -15
  117. package/dist/features/row-selection/rowSelectionFeature.utils.js +16 -13
  118. package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
  119. package/dist/features/row-sorting/createSortedRowModel.cjs +1 -1
  120. package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
  121. package/dist/features/row-sorting/createSortedRowModel.js +2 -2
  122. package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
  123. package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +16 -16
  124. package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +16 -16
  125. package/dist/index.cjs +2 -0
  126. package/dist/index.d.cts +4 -4
  127. package/dist/index.d.ts +4 -4
  128. package/dist/index.js +2 -2
  129. package/dist/types/Column.d.cts +2 -4
  130. package/dist/types/Column.d.ts +2 -4
  131. package/dist/types/Table.d.cts +3 -16
  132. package/dist/types/Table.d.ts +3 -16
  133. package/dist/types/TableFeatures.d.cts +7 -7
  134. package/dist/types/TableFeatures.d.ts +7 -7
  135. package/dist/utils.cjs +24 -2
  136. package/dist/utils.cjs.map +1 -1
  137. package/dist/utils.d.cts +16 -5
  138. package/dist/utils.d.ts +16 -5
  139. package/dist/utils.js +23 -3
  140. package/dist/utils.js.map +1 -1
  141. package/package.json +2 -2
  142. package/src/core/columns/coreColumnsFeature.utils.ts +3 -3
  143. package/src/core/headers/coreHeadersFeature.types.ts +2 -2
  144. package/src/core/row-models/createCoreRowModel.ts +2 -2
  145. package/src/core/rows/constructRow.ts +3 -2
  146. package/src/core/rows/coreRowsFeature.utils.ts +4 -4
  147. package/src/features/column-filtering/columnFilteringFeature.ts +3 -2
  148. package/src/features/column-filtering/createFilteredRowModel.ts +13 -10
  149. package/src/features/column-filtering/filterRowsUtils.ts +3 -2
  150. package/src/features/column-grouping/columnGroupingFeature.ts +2 -1
  151. package/src/features/column-grouping/columnGroupingFeature.utils.ts +2 -2
  152. package/src/features/column-grouping/createGroupedRowModel.ts +10 -5
  153. package/src/features/column-resizing/columnResizingFeature.utils.ts +5 -6
  154. package/src/features/column-sizing/columnSizingFeature.utils.ts +27 -5
  155. package/src/features/column-visibility/columnVisibilityFeature.utils.ts +31 -15
  156. package/src/features/row-expanding/rowExpandingFeature.utils.ts +38 -13
  157. package/src/features/row-selection/rowSelectionFeature.utils.ts +35 -13
  158. package/src/features/row-sorting/createSortedRowModel.ts +6 -9
  159. package/src/types/Column.ts +3 -1
  160. package/src/utils.ts +24 -2
@@ -13,7 +13,7 @@ const require_utils = require('../../utils.cjs');
13
13
  * ```
14
14
  */
15
15
  function getDefaultExpandedState() {
16
- return {};
16
+ return require_utils.makeObjectMap();
17
17
  }
18
18
  /**
19
19
  * Schedules an expanded-state reset after row-structure changes.
@@ -59,7 +59,7 @@ function table_setExpanded(table, updater) {
59
59
  */
60
60
  function table_toggleAllRowsExpanded(table, expanded) {
61
61
  if (expanded ?? !table_getIsAllRowsExpanded(table)) table_setExpanded(table, true);
62
- else table_setExpanded(table, {});
62
+ else table_setExpanded(table, require_utils.makeObjectMap());
63
63
  }
64
64
  /**
65
65
  * Resets `expanded` to the configured initial state or feature default.
@@ -74,7 +74,8 @@ function table_toggleAllRowsExpanded(table, expanded) {
74
74
  * ```
75
75
  */
76
76
  function table_resetExpanded(table, defaultState) {
77
- table_setExpanded(table, defaultState ? {} : require_utils.cloneState(table.initialState.expanded ?? {}));
77
+ const initialExpanded = table.initialState.expanded;
78
+ table_setExpanded(table, defaultState ? require_utils.makeObjectMap() : initialExpanded === true ? true : Object.assign(require_utils.makeObjectMap(), require_utils.cloneState(initialExpanded ?? {})));
78
79
  }
79
80
  /**
80
81
  * Checks whether at least one pre-paginated row can expand.
@@ -176,19 +177,24 @@ function table_getExpandedDepth(table) {
176
177
  */
177
178
  function row_toggleExpanded(row, expanded) {
178
179
  table_setExpanded(row.table, (old) => {
179
- const exists = old === true ? true : !!old[row.id];
180
- let oldExpanded = {};
180
+ const exists = old === true ? true : isExpandedRowId(old, row.id);
181
+ let oldExpanded = require_utils.makeObjectMap();
181
182
  if (old === true) Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {
182
183
  oldExpanded[rowId] = true;
183
184
  });
184
- else oldExpanded = old;
185
+ else oldExpanded = Object.assign(require_utils.makeObjectMap(), old);
185
186
  expanded = expanded ?? !exists;
186
- if (!exists && expanded) return {
187
- ...oldExpanded,
188
- [row.id]: true
189
- };
187
+ if (!exists && expanded) {
188
+ oldExpanded[row.id] = true;
189
+ return oldExpanded;
190
+ }
190
191
  if (exists && !expanded) {
191
- const { [row.id]: _, ...rest } = oldExpanded;
192
+ const rest = require_utils.makeObjectMap();
193
+ const rowIds = Object.keys(oldExpanded);
194
+ for (let i = 0; i < rowIds.length; i++) {
195
+ const rowId = rowIds[i];
196
+ if (rowId !== row.id && oldExpanded[rowId]) rest[rowId] = true;
197
+ }
192
198
  return rest;
193
199
  }
194
200
  return old;
@@ -208,7 +214,10 @@ function row_toggleExpanded(row, expanded) {
208
214
  function row_getIsExpanded(row) {
209
215
  var _row$table$atoms$expa, _row$table$options$ge, _row$table$options;
210
216
  const expanded = ((_row$table$atoms$expa = row.table.atoms.expanded) === null || _row$table$atoms$expa === void 0 ? void 0 : _row$table$atoms$expa.get()) ?? {};
211
- return !!(((_row$table$options$ge = (_row$table$options = row.table.options).getIsRowExpanded) === null || _row$table$options$ge === void 0 ? void 0 : _row$table$options$ge.call(_row$table$options, row)) ?? (expanded === true || expanded[row.id]));
217
+ return !!(((_row$table$options$ge = (_row$table$options = row.table.options).getIsRowExpanded) === null || _row$table$options$ge === void 0 ? void 0 : _row$table$options$ge.call(_row$table$options, row)) ?? (expanded === true || isExpandedRowId(expanded, row.id)));
218
+ }
219
+ function isExpandedRowId(expanded, rowId) {
220
+ return !!(expanded && expanded !== true && require_utils.hasOwn(expanded, rowId) && expanded[rowId]);
212
221
  }
213
222
  /**
214
223
  * Checks whether this row can be expanded.
@@ -1 +1 @@
1
- {"version":3,"file":"rowExpandingFeature.utils.cjs","names":["cloneState"],"sources":["../../../src/features/row-expanding/rowExpandingFeature.utils.ts"],"sourcesContent":["import { cloneState } 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 { Row } from '../../types/Row'\nimport type {\n ExpandedState,\n ExpandedStateList,\n} from './rowExpandingFeature.types'\n\n/**\n * Creates the default expanded state.\n *\n * The feature default is an empty map, meaning no rows are expanded. Reset APIs\n * use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const expanded = getDefaultExpandedState()\n * ```\n */\nexport function getDefaultExpandedState(): ExpandedState {\n return {}\n}\n\n/**\n * Schedules an expanded-state reset after row-structure changes.\n *\n * The reset runs when `autoResetAll`, `autoResetExpanded`, or the default\n * client-side expanding behavior allows it. Manual expanding opts out unless\n * the reset options explicitly opt back in.\n *\n * @example\n * ```ts\n * table_autoResetExpanded(table)\n * ```\n */\nexport function table_autoResetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n table._reactivity.schedule(() => table_resetExpanded(table))\n }\n}\n\n/**\n * Routes an expanded-state updater through the table's expanded change handler.\n *\n * The updater may be `true`, a row-id map, or a function of the previous\n * expanded state, matching the instance `table.setExpanded` behavior.\n *\n * @example\n * ```ts\n * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))\n * ```\n */\nexport function table_setExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>) {\n table.options.onExpandedChange?.(updater)\n}\n\n/**\n * Expands or collapses every row.\n *\n * Passing `true` stores the special expanded-all state. Passing `false` stores\n * an empty map. Omitting the value toggles based on whether all rows are\n * currently expanded.\n *\n * @example\n * ```ts\n * table_toggleAllRowsExpanded(table)\n * ```\n */\nexport function table_toggleAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, expanded?: boolean) {\n if (expanded ?? !table_getIsAllRowsExpanded(table)) {\n table_setExpanded(table, true)\n } else {\n table_setExpanded(table, {})\n }\n}\n\n/**\n * Resets `expanded` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.expanded` when it\n * exists. Passing `true` ignores initial state and resets to `{}`.\n *\n * @example\n * ```ts\n * table_resetExpanded(table)\n * table_resetExpanded(table, true)\n * ```\n */\nexport function table_resetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setExpanded(\n table,\n defaultState ? {} : cloneState(table.initialState.expanded ?? {}),\n )\n}\n\n/**\n * Checks whether at least one pre-paginated row can expand.\n *\n * Pagination is intentionally ignored so controls can reflect expandable rows\n * that may not be on the current page.\n *\n * @example\n * ```ts\n * const canExpand = table_getCanSomeRowsExpand(table)\n * ```\n */\nexport function table_getCanSomeRowsExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getPrePaginatedRowModel()\n .flatRows.some((row) => row_getCanExpand(row))\n}\n\n/**\n * Creates an event handler that toggles all rows expanded.\n *\n * React-style synthetic events are persisted when present before the table state\n * is toggled.\n *\n * @example\n * ```ts\n * const onClick = table_getToggleAllRowsExpandedHandler(table)\n * ```\n */\nexport function table_getToggleAllRowsExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table_toggleAllRowsExpanded(table)\n }\n}\n\n/**\n * Checks whether any row is expanded.\n *\n * The special expanded-all value `true` counts as some rows expanded.\n *\n * @example\n * ```ts\n * const someExpanded = table_getIsSomeRowsExpanded(table)\n * ```\n */\nexport function table_getIsSomeRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n return expanded === true || Object.values(expanded).some(Boolean)\n}\n\n/**\n * Checks whether every row in the current row model is expanded.\n *\n * The special expanded-all value `true` returns true immediately. Empty\n * expanded state returns false.\n *\n * @example\n * ```ts\n * const allExpanded = table_getIsAllRowsExpanded(table)\n * ```\n */\nexport function table_getIsAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n\n // If expanded is true, save some cycles and return true\n if (expanded === true) {\n return true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n}\n\n/**\n * Computes the deepest expanded row id depth.\n *\n * Row ids are split on `.`; expanded-all state scans the current row model,\n * while explicit expanded state scans its expanded id keys.\n *\n * @example\n * ```ts\n * const depth = table_getExpandedDepth(table)\n * ```\n */\nexport function table_getExpandedDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n let maxDepth = 0\n\n const rowIds =\n table.atoms.expanded?.get() === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.atoms.expanded?.get() ?? {})\n\n rowIds.forEach((id) => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n}\n\n/**\n * Expands or collapses this row.\n *\n * Omitting `expanded` toggles the row. If the current state is expanded-all,\n * the function first materializes that state into a row-id map before applying\n * the row-specific change.\n *\n * @example\n * ```ts\n * row_toggleExpanded(row)\n * ```\n */\nexport function row_toggleExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, expanded?: boolean) {\n table_setExpanded(row.table, (old) => {\n const exists = old === true ? true : !!old[row.id]\n\n let oldExpanded: ExpandedStateList = {}\n\n if (old === true) {\n Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = old\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n return {\n ...oldExpanded,\n [row.id]: true,\n }\n }\n\n if (exists && !expanded) {\n const { [row.id]: _, ...rest } = oldExpanded\n return rest\n }\n\n return old\n })\n}\n\n/**\n * Checks whether this row is expanded.\n *\n * `options.getIsRowExpanded` can override state-derived behavior. Otherwise\n * the row is expanded when expanded state is `true` or contains this row id.\n *\n * @example\n * ```ts\n * const expanded = row_getIsExpanded(row)\n * ```\n */\nexport function row_getIsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}\n\n return !!(\n row.table.options.getIsRowExpanded?.(row) ??\n (expanded === true || expanded[row.id])\n )\n}\n\n/**\n * Checks whether this row can be expanded.\n *\n * `options.getRowCanExpand` wins when provided. Otherwise rows can expand when\n * expanding is enabled and the row has subRows.\n *\n * @example\n * ```ts\n * const canExpand = row_getCanExpand(row)\n * ```\n */\nexport function row_getCanExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return (\n row.table.options.getRowCanExpand?.(row) ??\n ((row.table.options.enableExpanding ?? true) && !!row.subRows.length)\n )\n}\n\n/**\n * Checks whether every ancestor of this row is expanded.\n *\n * The current row is not considered; only its parent chain is walked.\n *\n * @example\n * ```ts\n * const parentsExpanded = row_getIsAllParentsExpanded(row)\n * ```\n */\nexport function row_getIsAllParentsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = row.table.getRow(currentRow.parentId, true)\n isFullyExpanded = row_getIsExpanded(currentRow)\n }\n\n return isFullyExpanded\n}\n\n/**\n * Creates a row control handler that toggles this row's expanded state.\n *\n * The handler is a no-op when the row cannot expand.\n *\n * @example\n * ```ts\n * const onClick = row_getToggleExpandedHandler(row)\n * ```\n */\nexport function row_getToggleExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const canExpand = row_getCanExpand(row)\n\n return () => {\n if (!canExpand) return\n row_toggleExpanded(row)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,SAAgB,0BAAyC;CACvD,OAAO,CAAC;AACV;;;;;;;;;;;;;AAcA,SAAgB,wBAGd,OAAyC;CACzC,IACE,MAAM,QAAQ,gBACd,MAAM,QAAQ,qBACd,CAAC,MAAM,QAAQ,iBAEf,MAAM,YAAY,eAAe,oBAAoB,KAAK,CAAC;AAE/D;;;;;;;;;;;;AAaA,SAAgB,kBAGd,OAAyC,SAAiC;;CAC1E,iDAAM,SAAQ,6GAAmB,OAAO;AAC1C;;;;;;;;;;;;;AAcA,SAAgB,4BAGd,OAAyC,UAAoB;CAC7D,IAAI,YAAY,CAAC,2BAA2B,KAAK,GAC/C,kBAAkB,OAAO,IAAI;MAE7B,kBAAkB,OAAO,CAAC,CAAC;AAE/B;;;;;;;;;;;;;AAcA,SAAgB,oBAGd,OAAyC,cAAwB;CACjE,kBACE,OACA,eAAe,CAAC,IAAIA,yBAAW,MAAM,aAAa,YAAY,CAAC,CAAC,CAClE;AACF;;;;;;;;;;;;AAaA,SAAgB,2BAGd,OAAyC;CACzC,OAAO,MACJ,wBAAwB,CAAC,CACzB,SAAS,MAAM,QAAQ,iBAAiB,GAAG,CAAC;AACjD;;;;;;;;;;;;AAaA,SAAgB,sCAGd,OAAyC;CACzC,QAAQ,MAAe;;EACpB,YAAC,EAAU,2DAAU;EACtB,4BAA4B,KAAK;CACnC;AACF;;;;;;;;;;;AAYA,SA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AC,UAAU;GACvB,MAAM,GAAG,IAAI,KAAK,GAAG,GAAG,SAAS;GACjC,OAAO;EACT;EAEA,OAAO;CACT,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,kBAGd,KAA4B;;CAC5B,MAAM,qCAA0B,IAAI,MAAM,MAAM,wFAAU,IAAI,MAAK,CAAC;CAEpE,OAAO,CAAC,kDACN,IAAI,MAAM,SAAQ,yHAAmB,GAAG,OACvC,aAAa,QAAQ,SAAS,IAAI;AAEvC;;;;;;;;;;;;AAaA,SAAgB,iBAGd,KAA4B;;CAC5B,yDACE,IAAI,MAAM,SAAQ,2HAAkB,GAAG,QACrC,IAAI,MAAM,QAAQ,mBAAmB,SAAS,CAAC,CAAC,IAAI,QAAQ;AAElE;;;;;;;;;;;AAYA,SAAgB,4BAGd,KAA4B;CAC5B,IAAI,kBAAkB;CACtB,IAAI,aAAa;CAEjB,OAAO,mBAAmB,WAAW,UAAU;EAC7C,aAAa,IAAI,MAAM,OAAO,WAAW,UAAU,IAAI;EACvD,kBAAkB,kBAAkB,UAAU;CAChD;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,6BAGd,KAA4B;CAC5B,MAAM,YAAY,iBAAiB,GAAG;CAEtC,aAAa;EACX,IAAI,CAAC,WAAW;EAChB,mBAAmB,GAAG;CACxB;AACF"}
1
+ {"version":3,"file":"rowExpandingFeature.utils.cjs","names":["makeObjectMap","cloneState","hasOwn"],"sources":["../../../src/features/row-expanding/rowExpandingFeature.utils.ts"],"sourcesContent":["import { cloneState, hasOwn, makeObjectMap } 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 { Row } from '../../types/Row'\nimport type {\n ExpandedState,\n ExpandedStateList,\n} from './rowExpandingFeature.types'\n\n/**\n * Creates the default expanded state.\n *\n * The feature default is an empty map, meaning no rows are expanded. Reset APIs\n * use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const expanded = getDefaultExpandedState()\n * ```\n */\nexport function getDefaultExpandedState(): ExpandedState {\n return makeObjectMap()\n}\n\n/**\n * Schedules an expanded-state reset after row-structure changes.\n *\n * The reset runs when `autoResetAll`, `autoResetExpanded`, or the default\n * client-side expanding behavior allows it. Manual expanding opts out unless\n * the reset options explicitly opt back in.\n *\n * @example\n * ```ts\n * table_autoResetExpanded(table)\n * ```\n */\nexport function table_autoResetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n table._reactivity.schedule(() => table_resetExpanded(table))\n }\n}\n\n/**\n * Routes an expanded-state updater through the table's expanded change handler.\n *\n * The updater may be `true`, a row-id map, or a function of the previous\n * expanded state, matching the instance `table.setExpanded` behavior.\n *\n * @example\n * ```ts\n * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))\n * ```\n */\nexport function table_setExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>) {\n table.options.onExpandedChange?.(updater)\n}\n\n/**\n * Expands or collapses every row.\n *\n * Passing `true` stores the special expanded-all state. Passing `false` stores\n * an empty map. Omitting the value toggles based on whether all rows are\n * currently expanded.\n *\n * @example\n * ```ts\n * table_toggleAllRowsExpanded(table)\n * ```\n */\nexport function table_toggleAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, expanded?: boolean) {\n if (expanded ?? !table_getIsAllRowsExpanded(table)) {\n table_setExpanded(table, true)\n } else {\n table_setExpanded(table, makeObjectMap())\n }\n}\n\n/**\n * Resets `expanded` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.expanded` when it\n * exists. Passing `true` ignores initial state and resets to `{}`.\n *\n * @example\n * ```ts\n * table_resetExpanded(table)\n * table_resetExpanded(table, true)\n * ```\n */\nexport function table_resetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n const initialExpanded = table.initialState.expanded\n table_setExpanded(\n table,\n defaultState\n ? makeObjectMap()\n : initialExpanded === true\n ? true\n : Object.assign(\n makeObjectMap<boolean | undefined>(),\n cloneState(initialExpanded ?? {}),\n ),\n )\n}\n\n/**\n * Checks whether at least one pre-paginated row can expand.\n *\n * Pagination is intentionally ignored so controls can reflect expandable rows\n * that may not be on the current page.\n *\n * @example\n * ```ts\n * const canExpand = table_getCanSomeRowsExpand(table)\n * ```\n */\nexport function table_getCanSomeRowsExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getPrePaginatedRowModel()\n .flatRows.some((row) => row_getCanExpand(row))\n}\n\n/**\n * Creates an event handler that toggles all rows expanded.\n *\n * React-style synthetic events are persisted when present before the table state\n * is toggled.\n *\n * @example\n * ```ts\n * const onClick = table_getToggleAllRowsExpandedHandler(table)\n * ```\n */\nexport function table_getToggleAllRowsExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table_toggleAllRowsExpanded(table)\n }\n}\n\n/**\n * Checks whether any row is expanded.\n *\n * The special expanded-all value `true` counts as some rows expanded.\n *\n * @example\n * ```ts\n * const someExpanded = table_getIsSomeRowsExpanded(table)\n * ```\n */\nexport function table_getIsSomeRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n return expanded === true || Object.values(expanded).some(Boolean)\n}\n\n/**\n * Checks whether every row in the current row model is expanded.\n *\n * The special expanded-all value `true` returns true immediately. Empty\n * expanded state returns false.\n *\n * @example\n * ```ts\n * const allExpanded = table_getIsAllRowsExpanded(table)\n * ```\n */\nexport function table_getIsAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n\n // If expanded is true, save some cycles and return true\n if (expanded === true) {\n return true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n}\n\n/**\n * Computes the deepest expanded row id depth.\n *\n * Row ids are split on `.`; expanded-all state scans the current row model,\n * while explicit expanded state scans its expanded id keys.\n *\n * @example\n * ```ts\n * const depth = table_getExpandedDepth(table)\n * ```\n */\nexport function table_getExpandedDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n let maxDepth = 0\n\n const rowIds =\n table.atoms.expanded?.get() === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.atoms.expanded?.get() ?? {})\n\n rowIds.forEach((id) => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n}\n\n/**\n * Expands or collapses this row.\n *\n * Omitting `expanded` toggles the row. If the current state is expanded-all,\n * the function first materializes that state into a row-id map before applying\n * the row-specific change.\n *\n * @example\n * ```ts\n * row_toggleExpanded(row)\n * ```\n */\nexport function row_toggleExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, expanded?: boolean) {\n table_setExpanded(row.table, (old) => {\n const exists = old === true ? true : isExpandedRowId(old, row.id)\n\n let oldExpanded: ExpandedStateList = makeObjectMap()\n\n if (old === true) {\n Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = Object.assign(makeObjectMap<boolean | undefined>(), old)\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n oldExpanded[row.id] = true\n return oldExpanded\n }\n\n if (exists && !expanded) {\n const rest: ExpandedStateList = makeObjectMap()\n const rowIds = Object.keys(oldExpanded)\n for (let i = 0; i < rowIds.length; i++) {\n const rowId = rowIds[i]!\n if (rowId !== row.id && oldExpanded[rowId]) {\n rest[rowId] = true\n }\n }\n return rest\n }\n\n return old\n })\n}\n\n/**\n * Checks whether this row is expanded.\n *\n * `options.getIsRowExpanded` can override state-derived behavior. Otherwise\n * the row is expanded when expanded state is `true` or contains this row id.\n *\n * @example\n * ```ts\n * const expanded = row_getIsExpanded(row)\n * ```\n */\nexport function row_getIsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}\n\n return !!(\n row.table.options.getIsRowExpanded?.(row) ??\n (expanded === true || isExpandedRowId(expanded, row.id))\n )\n}\n\nfunction isExpandedRowId(\n expanded: ExpandedState | undefined,\n rowId: string,\n): boolean {\n return !!(\n expanded &&\n expanded !== true &&\n hasOwn(expanded, rowId) &&\n expanded[rowId]\n )\n}\n\n/**\n * Checks whether this row can be expanded.\n *\n * `options.getRowCanExpand` wins when provided. Otherwise rows can expand when\n * expanding is enabled and the row has subRows.\n *\n * @example\n * ```ts\n * const canExpand = row_getCanExpand(row)\n * ```\n */\nexport function row_getCanExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return (\n row.table.options.getRowCanExpand?.(row) ??\n ((row.table.options.enableExpanding ?? true) && !!row.subRows.length)\n )\n}\n\n/**\n * Checks whether every ancestor of this row is expanded.\n *\n * The current row is not considered; only its parent chain is walked.\n *\n * @example\n * ```ts\n * const parentsExpanded = row_getIsAllParentsExpanded(row)\n * ```\n */\nexport function row_getIsAllParentsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = row.table.getRow(currentRow.parentId, true)\n isFullyExpanded = row_getIsExpanded(currentRow)\n }\n\n return isFullyExpanded\n}\n\n/**\n * Creates a row control handler that toggles this row's expanded state.\n *\n * The handler is a no-op when the row cannot expand.\n *\n * @example\n * ```ts\n * const onClick = row_getToggleExpandedHandler(row)\n * ```\n */\nexport function row_getToggleExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const canExpand = row_getCanExpand(row)\n\n return () => {\n if (!canExpand) return\n row_toggleExpanded(row)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,SAAgB,0BAAyC;CACvD,OAAOA,4BAAc;AACvB;;;;;;;;;;;;;AAcA,SAAgB,wBAGd,OAAyC;CACzC,IACE,MAAM,QAAQ,gBACd,MAAM,QAAQ,qBACd,CAAC,MAAM,QAAQ,iBAEf,MAAM,YAAY,eAAe,oBAAoB,KAAK,CAAC;AAE/D;;;;;;;;;;;;AAaA,SAAgB,kBAGd,OAAyC,SAAiC;;CAC1E,iDAAM,SAAQ,6GAAmB,OAAO;AAC1C;;;;;;;;;;;;;AAcA,SAAgB,4BAGd,OAAyC,UAAoB;CAC7D,IAAI,YAAY,CAAC,2BAA2B,KAAK,GAC/C,kBAAkB,OAAO,IAAI;MAE7B,kBAAkB,OAAOA,4BAAc,CAAC;AAE5C;;;;;;;;;;;;;AAcA,SAAgB,oBAGd,OAAyC,cAAwB;CACjE,MAAM,kBAAkB,MAAM,aAAa;CAC3C,kBACE,OACA,eACIA,4BAAc,IACd,oBAAoB,OAClB,OACA,OAAO,OACLA,4BAAmC,GACnCC,yBAAW,mBAAmB,CAAC,CAAC,CAClC,CACR;AACF;;;;;;;;;;;;AAaA,SAAgB,2BAGd,OAAyC;CACzC,OAAO,MACJ,wBAAwB,CAAC,CACzB,SAAS,MAAM,QAAQ,iBAAiB,GAAG,CAAC;AACjD;;;;;;;;;;;;AAaA,SAAgB,sCAGd,OAAyC;CACzC,QAAQ,MAAe;;EACpB,YAAC,EAAU,2DAAU;EACtB,4BAA4B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";
2
2
  import { ExpandedState } from "./rowExpandingFeature.types.cjs";
3
3
  import { Row } from "../../types/Row.cjs";
4
- import { Table_Internal } from "../../types/Table.cjs";
4
+ import { Table } from "../../types/Table.cjs";
5
5
  import { TableFeatures } from "../../types/TableFeatures.cjs";
6
6
 
7
7
  //#region src/features/row-expanding/rowExpandingFeature.utils.d.ts
@@ -29,7 +29,7 @@ declare function getDefaultExpandedState(): ExpandedState;
29
29
  * table_autoResetExpanded(table)
30
30
  * ```
31
31
  */
32
- declare function table_autoResetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
32
+ declare function table_autoResetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
33
33
  /**
34
34
  * Routes an expanded-state updater through the table's expanded change handler.
35
35
  *
@@ -41,7 +41,7 @@ declare function table_autoResetExpanded<TFeatures extends TableFeatures, TData
41
41
  * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))
42
42
  * ```
43
43
  */
44
- declare function table_setExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>): void;
44
+ declare function table_setExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, updater: Updater<ExpandedState>): void;
45
45
  /**
46
46
  * Expands or collapses every row.
47
47
  *
@@ -54,7 +54,7 @@ declare function table_setExpanded<TFeatures extends TableFeatures, TData extend
54
54
  * table_toggleAllRowsExpanded(table)
55
55
  * ```
56
56
  */
57
- declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, expanded?: boolean): void;
57
+ declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, expanded?: boolean): void;
58
58
  /**
59
59
  * Resets `expanded` to the configured initial state or feature default.
60
60
  *
@@ -67,7 +67,7 @@ declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TD
67
67
  * table_resetExpanded(table, true)
68
68
  * ```
69
69
  */
70
- declare function table_resetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
70
+ declare function table_resetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, defaultState?: boolean): void;
71
71
  /**
72
72
  * Checks whether at least one pre-paginated row can expand.
73
73
  *
@@ -79,7 +79,7 @@ declare function table_resetExpanded<TFeatures extends TableFeatures, TData exte
79
79
  * const canExpand = table_getCanSomeRowsExpand(table)
80
80
  * ```
81
81
  */
82
- declare function table_getCanSomeRowsExpand<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
82
+ declare function table_getCanSomeRowsExpand<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
83
83
  /**
84
84
  * Creates an event handler that toggles all rows expanded.
85
85
  *
@@ -91,7 +91,7 @@ declare function table_getCanSomeRowsExpand<TFeatures extends TableFeatures, TDa
91
91
  * const onClick = table_getToggleAllRowsExpandedHandler(table)
92
92
  * ```
93
93
  */
94
- declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): (e: unknown) => void;
94
+ declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): (e: unknown) => void;
95
95
  /**
96
96
  * Checks whether any row is expanded.
97
97
  *
@@ -102,7 +102,7 @@ declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFe
102
102
  * const someExpanded = table_getIsSomeRowsExpanded(table)
103
103
  * ```
104
104
  */
105
- declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
105
+ declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
106
106
  /**
107
107
  * Checks whether every row in the current row model is expanded.
108
108
  *
@@ -114,7 +114,7 @@ declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TD
114
114
  * const allExpanded = table_getIsAllRowsExpanded(table)
115
115
  * ```
116
116
  */
117
- declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
117
+ declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
118
118
  /**
119
119
  * Computes the deepest expanded row id depth.
120
120
  *
@@ -126,7 +126,7 @@ declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TDa
126
126
  * const depth = table_getExpandedDepth(table)
127
127
  * ```
128
128
  */
129
- declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number;
129
+ declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): number;
130
130
  /**
131
131
  * Expands or collapses this row.
132
132
  *
@@ -1,7 +1,7 @@
1
1
  import { RowData, Updater } from "../../types/type-utils.js";
2
2
  import { ExpandedState } from "./rowExpandingFeature.types.js";
3
3
  import { Row } from "../../types/Row.js";
4
- import { Table_Internal } from "../../types/Table.js";
4
+ import { Table } from "../../types/Table.js";
5
5
  import { TableFeatures } from "../../types/TableFeatures.js";
6
6
 
7
7
  //#region src/features/row-expanding/rowExpandingFeature.utils.d.ts
@@ -29,7 +29,7 @@ declare function getDefaultExpandedState(): ExpandedState;
29
29
  * table_autoResetExpanded(table)
30
30
  * ```
31
31
  */
32
- declare function table_autoResetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
32
+ declare function table_autoResetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
33
33
  /**
34
34
  * Routes an expanded-state updater through the table's expanded change handler.
35
35
  *
@@ -41,7 +41,7 @@ declare function table_autoResetExpanded<TFeatures extends TableFeatures, TData
41
41
  * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))
42
42
  * ```
43
43
  */
44
- declare function table_setExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>): void;
44
+ declare function table_setExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, updater: Updater<ExpandedState>): void;
45
45
  /**
46
46
  * Expands or collapses every row.
47
47
  *
@@ -54,7 +54,7 @@ declare function table_setExpanded<TFeatures extends TableFeatures, TData extend
54
54
  * table_toggleAllRowsExpanded(table)
55
55
  * ```
56
56
  */
57
- declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, expanded?: boolean): void;
57
+ declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, expanded?: boolean): void;
58
58
  /**
59
59
  * Resets `expanded` to the configured initial state or feature default.
60
60
  *
@@ -67,7 +67,7 @@ declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TD
67
67
  * table_resetExpanded(table, true)
68
68
  * ```
69
69
  */
70
- declare function table_resetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
70
+ declare function table_resetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, defaultState?: boolean): void;
71
71
  /**
72
72
  * Checks whether at least one pre-paginated row can expand.
73
73
  *
@@ -79,7 +79,7 @@ declare function table_resetExpanded<TFeatures extends TableFeatures, TData exte
79
79
  * const canExpand = table_getCanSomeRowsExpand(table)
80
80
  * ```
81
81
  */
82
- declare function table_getCanSomeRowsExpand<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
82
+ declare function table_getCanSomeRowsExpand<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
83
83
  /**
84
84
  * Creates an event handler that toggles all rows expanded.
85
85
  *
@@ -91,7 +91,7 @@ declare function table_getCanSomeRowsExpand<TFeatures extends TableFeatures, TDa
91
91
  * const onClick = table_getToggleAllRowsExpandedHandler(table)
92
92
  * ```
93
93
  */
94
- declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): (e: unknown) => void;
94
+ declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): (e: unknown) => void;
95
95
  /**
96
96
  * Checks whether any row is expanded.
97
97
  *
@@ -102,7 +102,7 @@ declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFe
102
102
  * const someExpanded = table_getIsSomeRowsExpanded(table)
103
103
  * ```
104
104
  */
105
- declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
105
+ declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
106
106
  /**
107
107
  * Checks whether every row in the current row model is expanded.
108
108
  *
@@ -114,7 +114,7 @@ declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TD
114
114
  * const allExpanded = table_getIsAllRowsExpanded(table)
115
115
  * ```
116
116
  */
117
- declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
117
+ declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
118
118
  /**
119
119
  * Computes the deepest expanded row id depth.
120
120
  *
@@ -126,7 +126,7 @@ declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TDa
126
126
  * const depth = table_getExpandedDepth(table)
127
127
  * ```
128
128
  */
129
- declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number;
129
+ declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): number;
130
130
  /**
131
131
  * Expands or collapses this row.
132
132
  *
@@ -1,4 +1,4 @@
1
- import { cloneState } from "../../utils.js";
1
+ import { cloneState, hasOwn, makeObjectMap } from "../../utils.js";
2
2
 
3
3
  //#region src/features/row-expanding/rowExpandingFeature.utils.ts
4
4
  /**
@@ -13,7 +13,7 @@ import { cloneState } from "../../utils.js";
13
13
  * ```
14
14
  */
15
15
  function getDefaultExpandedState() {
16
- return {};
16
+ return makeObjectMap();
17
17
  }
18
18
  /**
19
19
  * Schedules an expanded-state reset after row-structure changes.
@@ -59,7 +59,7 @@ function table_setExpanded(table, updater) {
59
59
  */
60
60
  function table_toggleAllRowsExpanded(table, expanded) {
61
61
  if (expanded ?? !table_getIsAllRowsExpanded(table)) table_setExpanded(table, true);
62
- else table_setExpanded(table, {});
62
+ else table_setExpanded(table, makeObjectMap());
63
63
  }
64
64
  /**
65
65
  * Resets `expanded` to the configured initial state or feature default.
@@ -74,7 +74,8 @@ function table_toggleAllRowsExpanded(table, expanded) {
74
74
  * ```
75
75
  */
76
76
  function table_resetExpanded(table, defaultState) {
77
- table_setExpanded(table, defaultState ? {} : cloneState(table.initialState.expanded ?? {}));
77
+ const initialExpanded = table.initialState.expanded;
78
+ table_setExpanded(table, defaultState ? makeObjectMap() : initialExpanded === true ? true : Object.assign(makeObjectMap(), cloneState(initialExpanded ?? {})));
78
79
  }
79
80
  /**
80
81
  * Checks whether at least one pre-paginated row can expand.
@@ -176,19 +177,24 @@ function table_getExpandedDepth(table) {
176
177
  */
177
178
  function row_toggleExpanded(row, expanded) {
178
179
  table_setExpanded(row.table, (old) => {
179
- const exists = old === true ? true : !!old[row.id];
180
- let oldExpanded = {};
180
+ const exists = old === true ? true : isExpandedRowId(old, row.id);
181
+ let oldExpanded = makeObjectMap();
181
182
  if (old === true) Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {
182
183
  oldExpanded[rowId] = true;
183
184
  });
184
- else oldExpanded = old;
185
+ else oldExpanded = Object.assign(makeObjectMap(), old);
185
186
  expanded = expanded ?? !exists;
186
- if (!exists && expanded) return {
187
- ...oldExpanded,
188
- [row.id]: true
189
- };
187
+ if (!exists && expanded) {
188
+ oldExpanded[row.id] = true;
189
+ return oldExpanded;
190
+ }
190
191
  if (exists && !expanded) {
191
- const { [row.id]: _, ...rest } = oldExpanded;
192
+ const rest = makeObjectMap();
193
+ const rowIds = Object.keys(oldExpanded);
194
+ for (let i = 0; i < rowIds.length; i++) {
195
+ const rowId = rowIds[i];
196
+ if (rowId !== row.id && oldExpanded[rowId]) rest[rowId] = true;
197
+ }
192
198
  return rest;
193
199
  }
194
200
  return old;
@@ -208,7 +214,10 @@ function row_toggleExpanded(row, expanded) {
208
214
  function row_getIsExpanded(row) {
209
215
  var _row$table$atoms$expa, _row$table$options$ge, _row$table$options;
210
216
  const expanded = ((_row$table$atoms$expa = row.table.atoms.expanded) === null || _row$table$atoms$expa === void 0 ? void 0 : _row$table$atoms$expa.get()) ?? {};
211
- return !!(((_row$table$options$ge = (_row$table$options = row.table.options).getIsRowExpanded) === null || _row$table$options$ge === void 0 ? void 0 : _row$table$options$ge.call(_row$table$options, row)) ?? (expanded === true || expanded[row.id]));
217
+ return !!(((_row$table$options$ge = (_row$table$options = row.table.options).getIsRowExpanded) === null || _row$table$options$ge === void 0 ? void 0 : _row$table$options$ge.call(_row$table$options, row)) ?? (expanded === true || isExpandedRowId(expanded, row.id)));
218
+ }
219
+ function isExpandedRowId(expanded, rowId) {
220
+ return !!(expanded && expanded !== true && hasOwn(expanded, rowId) && expanded[rowId]);
212
221
  }
213
222
  /**
214
223
  * Checks whether this row can be expanded.
@@ -1 +1 @@
1
- {"version":3,"file":"rowExpandingFeature.utils.js","names":[],"sources":["../../../src/features/row-expanding/rowExpandingFeature.utils.ts"],"sourcesContent":["import { cloneState } 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 { Row } from '../../types/Row'\nimport type {\n ExpandedState,\n ExpandedStateList,\n} from './rowExpandingFeature.types'\n\n/**\n * Creates the default expanded state.\n *\n * The feature default is an empty map, meaning no rows are expanded. Reset APIs\n * use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const expanded = getDefaultExpandedState()\n * ```\n */\nexport function getDefaultExpandedState(): ExpandedState {\n return {}\n}\n\n/**\n * Schedules an expanded-state reset after row-structure changes.\n *\n * The reset runs when `autoResetAll`, `autoResetExpanded`, or the default\n * client-side expanding behavior allows it. Manual expanding opts out unless\n * the reset options explicitly opt back in.\n *\n * @example\n * ```ts\n * table_autoResetExpanded(table)\n * ```\n */\nexport function table_autoResetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n table._reactivity.schedule(() => table_resetExpanded(table))\n }\n}\n\n/**\n * Routes an expanded-state updater through the table's expanded change handler.\n *\n * The updater may be `true`, a row-id map, or a function of the previous\n * expanded state, matching the instance `table.setExpanded` behavior.\n *\n * @example\n * ```ts\n * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))\n * ```\n */\nexport function table_setExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>) {\n table.options.onExpandedChange?.(updater)\n}\n\n/**\n * Expands or collapses every row.\n *\n * Passing `true` stores the special expanded-all state. Passing `false` stores\n * an empty map. Omitting the value toggles based on whether all rows are\n * currently expanded.\n *\n * @example\n * ```ts\n * table_toggleAllRowsExpanded(table)\n * ```\n */\nexport function table_toggleAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, expanded?: boolean) {\n if (expanded ?? !table_getIsAllRowsExpanded(table)) {\n table_setExpanded(table, true)\n } else {\n table_setExpanded(table, {})\n }\n}\n\n/**\n * Resets `expanded` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.expanded` when it\n * exists. Passing `true` ignores initial state and resets to `{}`.\n *\n * @example\n * ```ts\n * table_resetExpanded(table)\n * table_resetExpanded(table, true)\n * ```\n */\nexport function table_resetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setExpanded(\n table,\n defaultState ? {} : cloneState(table.initialState.expanded ?? {}),\n )\n}\n\n/**\n * Checks whether at least one pre-paginated row can expand.\n *\n * Pagination is intentionally ignored so controls can reflect expandable rows\n * that may not be on the current page.\n *\n * @example\n * ```ts\n * const canExpand = table_getCanSomeRowsExpand(table)\n * ```\n */\nexport function table_getCanSomeRowsExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getPrePaginatedRowModel()\n .flatRows.some((row) => row_getCanExpand(row))\n}\n\n/**\n * Creates an event handler that toggles all rows expanded.\n *\n * React-style synthetic events are persisted when present before the table state\n * is toggled.\n *\n * @example\n * ```ts\n * const onClick = table_getToggleAllRowsExpandedHandler(table)\n * ```\n */\nexport function table_getToggleAllRowsExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table_toggleAllRowsExpanded(table)\n }\n}\n\n/**\n * Checks whether any row is expanded.\n *\n * The special expanded-all value `true` counts as some rows expanded.\n *\n * @example\n * ```ts\n * const someExpanded = table_getIsSomeRowsExpanded(table)\n * ```\n */\nexport function table_getIsSomeRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n return expanded === true || Object.values(expanded).some(Boolean)\n}\n\n/**\n * Checks whether every row in the current row model is expanded.\n *\n * The special expanded-all value `true` returns true immediately. Empty\n * expanded state returns false.\n *\n * @example\n * ```ts\n * const allExpanded = table_getIsAllRowsExpanded(table)\n * ```\n */\nexport function table_getIsAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n\n // If expanded is true, save some cycles and return true\n if (expanded === true) {\n return true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n}\n\n/**\n * Computes the deepest expanded row id depth.\n *\n * Row ids are split on `.`; expanded-all state scans the current row model,\n * while explicit expanded state scans its expanded id keys.\n *\n * @example\n * ```ts\n * const depth = table_getExpandedDepth(table)\n * ```\n */\nexport function table_getExpandedDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n let maxDepth = 0\n\n const rowIds =\n table.atoms.expanded?.get() === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.atoms.expanded?.get() ?? {})\n\n rowIds.forEach((id) => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n}\n\n/**\n * Expands or collapses this row.\n *\n * Omitting `expanded` toggles the row. If the current state is expanded-all,\n * the function first materializes that state into a row-id map before applying\n * the row-specific change.\n *\n * @example\n * ```ts\n * row_toggleExpanded(row)\n * ```\n */\nexport function row_toggleExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, expanded?: boolean) {\n table_setExpanded(row.table, (old) => {\n const exists = old === true ? true : !!old[row.id]\n\n let oldExpanded: ExpandedStateList = {}\n\n if (old === true) {\n Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = old\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n return {\n ...oldExpanded,\n [row.id]: true,\n }\n }\n\n if (exists && !expanded) {\n const { [row.id]: _, ...rest } = oldExpanded\n return rest\n }\n\n return old\n })\n}\n\n/**\n * Checks whether this row is expanded.\n *\n * `options.getIsRowExpanded` can override state-derived behavior. Otherwise\n * the row is expanded when expanded state is `true` or contains this row id.\n *\n * @example\n * ```ts\n * const expanded = row_getIsExpanded(row)\n * ```\n */\nexport function row_getIsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}\n\n return !!(\n row.table.options.getIsRowExpanded?.(row) ??\n (expanded === true || expanded[row.id])\n )\n}\n\n/**\n * Checks whether this row can be expanded.\n *\n * `options.getRowCanExpand` wins when provided. Otherwise rows can expand when\n * expanding is enabled and the row has subRows.\n *\n * @example\n * ```ts\n * const canExpand = row_getCanExpand(row)\n * ```\n */\nexport function row_getCanExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return (\n row.table.options.getRowCanExpand?.(row) ??\n ((row.table.options.enableExpanding ?? true) && !!row.subRows.length)\n )\n}\n\n/**\n * Checks whether every ancestor of this row is expanded.\n *\n * The current row is not considered; only its parent chain is walked.\n *\n * @example\n * ```ts\n * const parentsExpanded = row_getIsAllParentsExpanded(row)\n * ```\n */\nexport function row_getIsAllParentsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = row.table.getRow(currentRow.parentId, true)\n isFullyExpanded = row_getIsExpanded(currentRow)\n }\n\n return isFullyExpanded\n}\n\n/**\n * Creates a row control handler that toggles this row's expanded state.\n *\n * The handler is a no-op when the row cannot expand.\n *\n * @example\n * ```ts\n * const onClick = row_getToggleExpandedHandler(row)\n * ```\n */\nexport function row_getToggleExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends R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,yHAAmB,GAAG,OACvC,aAAa,QAAQ,SAAS,IAAI;AAEvC;;;;;;;;;;;;AAaA,SAAgB,iBAGd,KAA4B;;CAC5B,yDACE,IAAI,MAAM,SAAQ,2HAAkB,GAAG,QACrC,IAAI,MAAM,QAAQ,mBAAmB,SAAS,CAAC,CAAC,IAAI,QAAQ;AAElE;;;;;;;;;;;AAYA,SAAgB,4BAGd,KAA4B;CAC5B,IAAI,kBAAkB;CACtB,IAAI,aAAa;CAEjB,OAAO,mBAAmB,WAAW,UAAU;EAC7C,aAAa,IAAI,MAAM,OAAO,WAAW,UAAU,IAAI;EACvD,kBAAkB,kBAAkB,UAAU;CAChD;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,6BAGd,KAA4B;CAC5B,MAAM,YAAY,iBAAiB,GAAG;CAEtC,aAAa;EACX,IAAI,CAAC,WAAW;EAChB,mBAAmB,GAAG;CACxB;AACF"}
1
+ {"version":3,"file":"rowExpandingFeature.utils.js","names":[],"sources":["../../../src/features/row-expanding/rowExpandingFeature.utils.ts"],"sourcesContent":["import { cloneState, hasOwn, makeObjectMap } 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 { Row } from '../../types/Row'\nimport type {\n ExpandedState,\n ExpandedStateList,\n} from './rowExpandingFeature.types'\n\n/**\n * Creates the default expanded state.\n *\n * The feature default is an empty map, meaning no rows are expanded. Reset APIs\n * use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const expanded = getDefaultExpandedState()\n * ```\n */\nexport function getDefaultExpandedState(): ExpandedState {\n return makeObjectMap()\n}\n\n/**\n * Schedules an expanded-state reset after row-structure changes.\n *\n * The reset runs when `autoResetAll`, `autoResetExpanded`, or the default\n * client-side expanding behavior allows it. Manual expanding opts out unless\n * the reset options explicitly opt back in.\n *\n * @example\n * ```ts\n * table_autoResetExpanded(table)\n * ```\n */\nexport function table_autoResetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n table._reactivity.schedule(() => table_resetExpanded(table))\n }\n}\n\n/**\n * Routes an expanded-state updater through the table's expanded change handler.\n *\n * The updater may be `true`, a row-id map, or a function of the previous\n * expanded state, matching the instance `table.setExpanded` behavior.\n *\n * @example\n * ```ts\n * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))\n * ```\n */\nexport function table_setExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>) {\n table.options.onExpandedChange?.(updater)\n}\n\n/**\n * Expands or collapses every row.\n *\n * Passing `true` stores the special expanded-all state. Passing `false` stores\n * an empty map. Omitting the value toggles based on whether all rows are\n * currently expanded.\n *\n * @example\n * ```ts\n * table_toggleAllRowsExpanded(table)\n * ```\n */\nexport function table_toggleAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, expanded?: boolean) {\n if (expanded ?? !table_getIsAllRowsExpanded(table)) {\n table_setExpanded(table, true)\n } else {\n table_setExpanded(table, makeObjectMap())\n }\n}\n\n/**\n * Resets `expanded` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.expanded` when it\n * exists. Passing `true` ignores initial state and resets to `{}`.\n *\n * @example\n * ```ts\n * table_resetExpanded(table)\n * table_resetExpanded(table, true)\n * ```\n */\nexport function table_resetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n const initialExpanded = table.initialState.expanded\n table_setExpanded(\n table,\n defaultState\n ? makeObjectMap()\n : initialExpanded === true\n ? true\n : Object.assign(\n makeObjectMap<boolean | undefined>(),\n cloneState(initialExpanded ?? {}),\n ),\n )\n}\n\n/**\n * Checks whether at least one pre-paginated row can expand.\n *\n * Pagination is intentionally ignored so controls can reflect expandable rows\n * that may not be on the current page.\n *\n * @example\n * ```ts\n * const canExpand = table_getCanSomeRowsExpand(table)\n * ```\n */\nexport function table_getCanSomeRowsExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getPrePaginatedRowModel()\n .flatRows.some((row) => row_getCanExpand(row))\n}\n\n/**\n * Creates an event handler that toggles all rows expanded.\n *\n * React-style synthetic events are persisted when present before the table state\n * is toggled.\n *\n * @example\n * ```ts\n * const onClick = table_getToggleAllRowsExpandedHandler(table)\n * ```\n */\nexport function table_getToggleAllRowsExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table_toggleAllRowsExpanded(table)\n }\n}\n\n/**\n * Checks whether any row is expanded.\n *\n * The special expanded-all value `true` counts as some rows expanded.\n *\n * @example\n * ```ts\n * const someExpanded = table_getIsSomeRowsExpanded(table)\n * ```\n */\nexport function table_getIsSomeRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n return expanded === true || Object.values(expanded).some(Boolean)\n}\n\n/**\n * Checks whether every row in the current row model is expanded.\n *\n * The special expanded-all value `true` returns true immediately. Empty\n * expanded state returns false.\n *\n * @example\n * ```ts\n * const allExpanded = table_getIsAllRowsExpanded(table)\n * ```\n */\nexport function table_getIsAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n\n // If expanded is true, save some cycles and return true\n if (expanded === true) {\n return true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n}\n\n/**\n * Computes the deepest expanded row id depth.\n *\n * Row ids are split on `.`; expanded-all state scans the current row model,\n * while explicit expanded state scans its expanded id keys.\n *\n * @example\n * ```ts\n * const depth = table_getExpandedDepth(table)\n * ```\n */\nexport function table_getExpandedDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n let maxDepth = 0\n\n const rowIds =\n table.atoms.expanded?.get() === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.atoms.expanded?.get() ?? {})\n\n rowIds.forEach((id) => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n}\n\n/**\n * Expands or collapses this row.\n *\n * Omitting `expanded` toggles the row. If the current state is expanded-all,\n * the function first materializes that state into a row-id map before applying\n * the row-specific change.\n *\n * @example\n * ```ts\n * row_toggleExpanded(row)\n * ```\n */\nexport function row_toggleExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, expanded?: boolean) {\n table_setExpanded(row.table, (old) => {\n const exists = old === true ? true : isExpandedRowId(old, row.id)\n\n let oldExpanded: ExpandedStateList = makeObjectMap()\n\n if (old === true) {\n Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = Object.assign(makeObjectMap<boolean | undefined>(), old)\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n oldExpanded[row.id] = true\n return oldExpanded\n }\n\n if (exists && !expanded) {\n const rest: ExpandedStateList = makeObjectMap()\n const rowIds = Object.keys(oldExpanded)\n for (let i = 0; i < rowIds.length; i++) {\n const rowId = rowIds[i]!\n if (rowId !== row.id && oldExpanded[rowId]) {\n rest[rowId] = true\n }\n }\n return rest\n }\n\n return old\n })\n}\n\n/**\n * Checks whether this row is expanded.\n *\n * `options.getIsRowExpanded` can override state-derived behavior. Otherwise\n * the row is expanded when expanded state is `true` or contains this row id.\n *\n * @example\n * ```ts\n * const expanded = row_getIsExpanded(row)\n * ```\n */\nexport function row_getIsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}\n\n return !!(\n row.table.options.getIsRowExpanded?.(row) ??\n (expanded === true || isExpandedRowId(expanded, row.id))\n )\n}\n\nfunction isExpandedRowId(\n expanded: ExpandedState | undefined,\n rowId: string,\n): boolean {\n return !!(\n expanded &&\n expanded !== true &&\n hasOwn(expanded, rowId) &&\n expanded[rowId]\n )\n}\n\n/**\n * Checks whether this row can be expanded.\n *\n * `options.getRowCanExpand` wins when provided. Otherwise rows can expand when\n * expanding is enabled and the row has subRows.\n *\n * @example\n * ```ts\n * const canExpand = row_getCanExpand(row)\n * ```\n */\nexport function row_getCanExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return (\n row.table.options.getRowCanExpand?.(row) ??\n ((row.table.options.enableExpanding ?? true) && !!row.subRows.length)\n )\n}\n\n/**\n * Checks whether every ancestor of this row is expanded.\n *\n * The current row is not considered; only its parent chain is walked.\n *\n * @example\n * ```ts\n * const parentsExpanded = row_getIsAllParentsExpanded(row)\n * ```\n */\nexport function row_getIsAllParentsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = row.table.getRow(currentRow.parentId, true)\n isFullyExpanded = row_getIsExpanded(currentRow)\n }\n\n return isFullyExpanded\n}\n\n/**\n * Creates a row control handler that toggles this row's expanded state.\n *\n * The handler is a no-op when the row cannot expand.\n *\n * @example\n * ```ts\n * const onClick = row_getToggleExpandedHandler(row)\n * ```\n */\nexport function row_getToggleExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const canExpand = row_getCanExpand(row)\n\n return () => {\n if (!canExp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A,OAAO;EACT;EAEA,OAAO;CACT,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,kBAGd,KAA4B;;CAC5B,MAAM,qCAA0B,IAAI,MAAM,MAAM,wFAAU,IAAI,MAAK,CAAC;CAEpE,OAAO,CAAC,kDACN,IAAI,MAAM,SAAQ,yHAAmB,GAAG,OACvC,aAAa,QAAQ,gBAAgB,UAAU,IAAI,EAAE;AAE1D;AAEA,SAAS,gBACP,UACA,OACS;CACT,OAAO,CAAC,EACN,YACA,aAAa,QACb,OAAO,UAAU,KAAK,KACtB,SAAS;AAEb;;;;;;;;;;;;AAaA,SAAgB,iBAGd,KAA4B;;CAC5B,yDACE,IAAI,MAAM,SAAQ,2HAAkB,GAAG,QACrC,IAAI,MAAM,QAAQ,mBAAmB,SAAS,CAAC,CAAC,IAAI,QAAQ;AAElE;;;;;;;;;;;AAYA,SAAgB,4BAGd,KAA4B;CAC5B,IAAI,kBAAkB;CACtB,IAAI,aAAa;CAEjB,OAAO,mBAAmB,WAAW,UAAU;EAC7C,aAAa,IAAI,MAAM,OAAO,WAAW,UAAU,IAAI;EACvD,kBAAkB,kBAAkB,UAAU;CAChD;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,6BAGd,KAA4B;CAC5B,MAAM,YAAY,iBAAiB,GAAG;CAEtC,aAAa;EACX,IAAI,CAAC,WAAW;EAChB,mBAAmB,GAAG;CACxB;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { RowData, Updater } from "../../types/type-utils.cjs";
2
2
  import { PaginationState } from "./rowPaginationFeature.types.cjs";
3
- import { Table_Internal } from "../../types/Table.cjs";
3
+ import { Table } from "../../types/Table.cjs";
4
4
  import { TableFeatures } from "../../types/TableFeatures.cjs";
5
5
 
6
6
  //#region src/features/row-pagination/rowPaginationFeature.utils.d.ts
@@ -28,7 +28,7 @@ declare function getDefaultPaginationState(): PaginationState;
28
28
  * table_autoResetPageIndex(table)
29
29
  * ```
30
30
  */
31
- declare function table_autoResetPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
31
+ declare function table_autoResetPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
32
32
  /**
33
33
  * Routes a pagination updater through the table's pagination change handler.
34
34
  *
@@ -41,7 +41,7 @@ declare function table_autoResetPageIndex<TFeatures extends TableFeatures, TData
41
41
  * table_setPagination(table, (old) => old)
42
42
  * ```
43
43
  */
44
- declare function table_setPagination<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<PaginationState>): void | undefined;
44
+ declare function table_setPagination<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, updater: Updater<PaginationState>): void | undefined;
45
45
  /**
46
46
  * Resets `pagination` to the configured initial state or feature default.
47
47
  *
@@ -55,7 +55,7 @@ declare function table_setPagination<TFeatures extends TableFeatures, TData exte
55
55
  * table_resetPagination(table, true)
56
56
  * ```
57
57
  */
58
- declare function table_resetPagination<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
58
+ declare function table_resetPagination<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, defaultState?: boolean): void;
59
59
  /**
60
60
  * Updates `pagination.pageIndex` and clamps it to the known page range.
61
61
  *
@@ -67,7 +67,7 @@ declare function table_resetPagination<TFeatures extends TableFeatures, TData ex
67
67
  * table_setPageIndex(table, (old) => old)
68
68
  * ```
69
69
  */
70
- declare function table_setPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<number>): void;
70
+ declare function table_setPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, updater: Updater<number>): void;
71
71
  /**
72
72
  * Resets only `pagination.pageIndex`.
73
73
  *
@@ -80,7 +80,7 @@ declare function table_setPageIndex<TFeatures extends TableFeatures, TData exten
80
80
  * table_resetPageIndex(table, true)
81
81
  * ```
82
82
  */
83
- declare function table_resetPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
83
+ declare function table_resetPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, defaultState?: boolean): void;
84
84
  /**
85
85
  * Resets only `pagination.pageSize`.
86
86
  *
@@ -93,7 +93,7 @@ declare function table_resetPageIndex<TFeatures extends TableFeatures, TData ext
93
93
  * table_resetPageSize(table, true)
94
94
  * ```
95
95
  */
96
- declare function table_resetPageSize<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
96
+ declare function table_resetPageSize<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, defaultState?: boolean): void;
97
97
  /**
98
98
  * Updates `pagination.pageSize` while preserving the current top row.
99
99
  *
@@ -105,7 +105,7 @@ declare function table_resetPageSize<TFeatures extends TableFeatures, TData exte
105
105
  * table_setPageSize(table, (old) => old)
106
106
  * ```
107
107
  */
108
- declare function table_setPageSize<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<number>): void;
108
+ declare function table_setPageSize<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, updater: Updater<number>): void;
109
109
  /**
110
110
  * Builds the zero-based page indexes available for the current page count.
111
111
  *
@@ -117,7 +117,7 @@ declare function table_setPageSize<TFeatures extends TableFeatures, TData extend
117
117
  * const pageIndexes = table_getPageOptions(table)
118
118
  * ```
119
119
  */
120
- declare function table_getPageOptions<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number[];
120
+ declare function table_getPageOptions<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): number[];
121
121
  /**
122
122
  * Checks whether the current page index can move backward.
123
123
  *
@@ -129,7 +129,7 @@ declare function table_getPageOptions<TFeatures extends TableFeatures, TData ext
129
129
  * const canGoBack = table_getCanPreviousPage(table)
130
130
  * ```
131
131
  */
132
- declare function table_getCanPreviousPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
132
+ declare function table_getCanPreviousPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
133
133
  /**
134
134
  * Checks whether the current page index can move forward.
135
135
  *
@@ -141,7 +141,7 @@ declare function table_getCanPreviousPage<TFeatures extends TableFeatures, TData
141
141
  * const canGoForward = table_getCanNextPage(table)
142
142
  * ```
143
143
  */
144
- declare function table_getCanNextPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
144
+ declare function table_getCanNextPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
145
145
  /**
146
146
  * Moves the table to the previous page.
147
147
  *
@@ -153,7 +153,7 @@ declare function table_getCanNextPage<TFeatures extends TableFeatures, TData ext
153
153
  * table_previousPage(table)
154
154
  * ```
155
155
  */
156
- declare function table_previousPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
156
+ declare function table_previousPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
157
157
  /**
158
158
  * Moves the table to the next page.
159
159
  *
@@ -165,7 +165,7 @@ declare function table_previousPage<TFeatures extends TableFeatures, TData exten
165
165
  * table_nextPage(table)
166
166
  * ```
167
167
  */
168
- declare function table_nextPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
168
+ declare function table_nextPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
169
169
  /**
170
170
  * Moves the table to the first page.
171
171
  *
@@ -176,7 +176,7 @@ declare function table_nextPage<TFeatures extends TableFeatures, TData extends R
176
176
  * table_firstPage(table)
177
177
  * ```
178
178
  */
179
- declare function table_firstPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
179
+ declare function table_firstPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
180
180
  /**
181
181
  * Moves the table to the last known page.
182
182
  *
@@ -187,7 +187,7 @@ declare function table_firstPage<TFeatures extends TableFeatures, TData extends
187
187
  * table_lastPage(table)
188
188
  * ```
189
189
  */
190
- declare function table_lastPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
190
+ declare function table_lastPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
191
191
  /**
192
192
  * Resolves the number of pages for the current pagination state.
193
193
  *
@@ -199,7 +199,7 @@ declare function table_lastPage<TFeatures extends TableFeatures, TData extends R
199
199
  * const pages = table_getPageCount(table)
200
200
  * ```
201
201
  */
202
- declare function table_getPageCount<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number;
202
+ declare function table_getPageCount<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): number;
203
203
  /**
204
204
  * Resolves the total row count used for pagination math.
205
205
  *
@@ -212,7 +212,7 @@ declare function table_getPageCount<TFeatures extends TableFeatures, TData exten
212
212
  * const rows = table_getRowCount(table)
213
213
  * ```
214
214
  */
215
- declare function table_getRowCount<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number;
215
+ declare function table_getRowCount<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): number;
216
216
  //#endregion
217
217
  export { getDefaultPaginationState, table_autoResetPageIndex, table_firstPage, table_getCanNextPage, table_getCanPreviousPage, table_getPageCount, table_getPageOptions, table_getRowCount, table_lastPage, table_nextPage, table_previousPage, table_resetPageIndex, table_resetPageSize, table_resetPagination, table_setPageIndex, table_setPageSize, table_setPagination };
218
218
  //# sourceMappingURL=rowPaginationFeature.utils.d.cts.map