@rickcedwhat/playwright-smart-table 6.8.2 → 6.10.0

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 (38) hide show
  1. package/README.md +0 -2
  2. package/dist/engine/rowFinder.js +153 -168
  3. package/dist/engine/tableIteration.js +105 -123
  4. package/dist/engine/tableMapper.js +88 -103
  5. package/dist/packageVersion.d.ts +1 -1
  6. package/dist/packageVersion.js +1 -1
  7. package/dist/presets/glide/columns.js +23 -32
  8. package/dist/presets/glide/headers.js +18 -27
  9. package/dist/presets/glide/index.d.ts +9 -9
  10. package/dist/presets/glide/index.js +24 -33
  11. package/dist/presets/mui.js +197 -124
  12. package/dist/presets/rdg.d.ts +1 -1
  13. package/dist/presets/rdg.js +32 -41
  14. package/dist/smartRow.js +163 -96
  15. package/dist/strategies/columns.js +2 -11
  16. package/dist/strategies/dedupe.js +3 -12
  17. package/dist/strategies/fill.js +20 -29
  18. package/dist/strategies/headers.js +22 -31
  19. package/dist/strategies/index.d.ts +4 -0
  20. package/dist/strategies/index.js +3 -0
  21. package/dist/strategies/loading.js +24 -33
  22. package/dist/strategies/pagination.js +21 -30
  23. package/dist/strategies/sorting.js +18 -31
  24. package/dist/strategies/stabilization.js +28 -37
  25. package/dist/strategies/viewport.d.ts +52 -0
  26. package/dist/strategies/viewport.js +123 -0
  27. package/dist/typeContext.d.ts +1 -1
  28. package/dist/typeContext.js +100 -9
  29. package/dist/types.d.ts +100 -9
  30. package/dist/useTable.js +98 -76
  31. package/dist/utils/debugUtils.js +5 -16
  32. package/dist/utils/elementTracker.js +27 -40
  33. package/dist/utils/mutex.js +5 -16
  34. package/dist/utils/navigationBarrier.js +25 -36
  35. package/dist/utils/paginationPath.js +102 -115
  36. package/dist/utils/smartRowArray.js +2 -11
  37. package/dist/utils.js +4 -13
  38. package/package.json +9 -5
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.StabilizationStrategies = void 0;
13
4
  exports.StabilizationStrategies = {
@@ -15,77 +6,77 @@ exports.StabilizationStrategies = {
15
6
  * Waits for the visible text of the table rows to change.
16
7
  */
17
8
  contentChanged: (options = {}) => {
18
- return (_a, action_1) => __awaiter(void 0, [_a, action_1], void 0, function* ({ root, config, resolve, page }, action) {
19
- var _b, _c;
9
+ return async ({ root, config, resolve, page }, action) => {
10
+ var _a, _b;
20
11
  const rows = resolve(config.rowSelector, root);
21
- const timeout = (_b = options.timeout) !== null && _b !== void 0 ? _b : 5000;
22
- const scope = (_c = options.scope) !== null && _c !== void 0 ? _c : 'all';
12
+ const timeout = (_a = options.timeout) !== null && _a !== void 0 ? _a : 5000;
13
+ const scope = (_b = options.scope) !== null && _b !== void 0 ? _b : 'all';
23
14
  // Helper to get fingerprint
24
- const getFingerprint = () => __awaiter(void 0, void 0, void 0, function* () {
15
+ const getFingerprint = async () => {
25
16
  if (scope === 'first') {
26
- return yield rows.first().innerText().catch(() => '');
17
+ return await rows.first().innerText().catch(() => '');
27
18
  }
28
- const allText = yield rows.allInnerTexts();
19
+ const allText = await rows.allInnerTexts();
29
20
  return allText.join('|');
30
- });
21
+ };
31
22
  // 1. Capture Before
32
- const beforeFingerprint = yield getFingerprint();
23
+ const beforeFingerprint = await getFingerprint();
33
24
  // 2. Perform Action
34
- yield action();
25
+ await action();
35
26
  // 3. Wait for Change
36
27
  const startTime = Date.now();
37
28
  while (Date.now() - startTime < timeout) {
38
- const afterFingerprint = yield getFingerprint();
29
+ const afterFingerprint = await getFingerprint();
39
30
  if (afterFingerprint !== beforeFingerprint) {
40
31
  return true;
41
32
  }
42
- yield page.waitForTimeout(100);
33
+ await page.waitForTimeout(100);
43
34
  }
44
35
  return false;
45
- });
36
+ };
46
37
  },
47
38
  /**
48
39
  * Waits for the total number of rows to strictly increase.
49
40
  */
50
41
  rowCountIncreased: (options = {}) => {
51
- return (_a, action_1) => __awaiter(void 0, [_a, action_1], void 0, function* ({ root, config, resolve, page }, action) {
52
- var _b;
42
+ return async ({ root, config, resolve, page }, action) => {
43
+ var _a;
53
44
  const rows = resolve(config.rowSelector, root);
54
- const timeout = (_b = options.timeout) !== null && _b !== void 0 ? _b : 5000;
55
- const beforeCount = yield rows.count();
56
- yield action();
45
+ const timeout = (_a = options.timeout) !== null && _a !== void 0 ? _a : 5000;
46
+ const beforeCount = await rows.count();
47
+ await action();
57
48
  const startTime = Date.now();
58
49
  while (Date.now() - startTime < timeout) {
59
- const afterCount = yield rows.count();
50
+ const afterCount = await rows.count();
60
51
  if (afterCount > beforeCount) {
61
52
  return true;
62
53
  }
63
- yield page.waitForTimeout(100);
54
+ await page.waitForTimeout(100);
64
55
  }
65
56
  return false;
66
- });
57
+ };
67
58
  },
68
59
  /**
69
60
  * Waits for a specific network condition or spinner to disappear.
70
61
  * Useful for tables that have explicit loading states but might not change content immediately.
71
62
  */
72
63
  networkIdle: (options = {}) => {
73
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page, resolve }) {
74
- var _b;
75
- const timeout = (_b = options.timeout) !== null && _b !== void 0 ? _b : 5000;
64
+ return async ({ root, page, resolve }) => {
65
+ var _a;
66
+ const timeout = (_a = options.timeout) !== null && _a !== void 0 ? _a : 5000;
76
67
  if (options.spinnerSelector) {
77
68
  const spinner = resolve(options.spinnerSelector, root);
78
69
  try {
79
- yield spinner.waitFor({ state: 'detached', timeout });
70
+ await spinner.waitFor({ state: 'detached', timeout });
80
71
  return true;
81
72
  }
82
- catch (_c) {
73
+ catch (_b) {
83
74
  return false;
84
75
  }
85
76
  }
86
77
  // Fallback to simple wait if no selector
87
- yield page.waitForTimeout(500);
78
+ await page.waitForTimeout(500);
88
79
  return true;
89
- });
80
+ };
90
81
  }
91
82
  };
@@ -0,0 +1,52 @@
1
+ import { ViewportStrategy } from '../types';
2
+ export type DataAttributeViewportOptions = {
3
+ /**
4
+ * CSS selector for the scroll container (the element with overflow: auto/scroll).
5
+ * Resolved with `closest()` from the root element, so ancestors are found automatically.
6
+ * Defaults to 'div[class*="overflow-auto"]'.
7
+ */
8
+ scrollContainer?: string;
9
+ /**
10
+ * Milliseconds to wait for cells to appear in the DOM after a column scroll.
11
+ * Defaults to 3000.
12
+ */
13
+ attachTimeout?: number;
14
+ /**
15
+ * DOM attribute on row elements that holds the row index.
16
+ * Defaults to 'data-index'. Use 'aria-rowindex' for ARIA grids.
17
+ */
18
+ rowAttribute?: string;
19
+ /**
20
+ * DOM attribute on cell elements that holds the column index.
21
+ * Defaults to 'data-index'. Use 'aria-colindex' for ARIA grids.
22
+ */
23
+ columnAttribute?: string;
24
+ /**
25
+ * Estimated row height used when the target virtualized row is not mounted.
26
+ * If omitted, the strategy infers it from visible rows and falls back to 40px.
27
+ */
28
+ rowHeight?: number;
29
+ /**
30
+ * Estimated column width used when the target virtualized header is not mounted.
31
+ * If omitted, the strategy infers it from visible headers/cells and falls back to 120px.
32
+ */
33
+ columnWidth?: number;
34
+ /**
35
+ * Pixel padding applied when jumping to an estimated row or column position.
36
+ * Defaults to 20.
37
+ */
38
+ scrollPadding?: number;
39
+ /**
40
+ * Value subtracted from the attribute to get the 0-based row index.
41
+ * Defaults to 0. Use 1 for 'aria-rowindex' which is 1-based.
42
+ */
43
+ rowOffset?: number;
44
+ /**
45
+ * Value subtracted from the attribute to get the 0-based column index.
46
+ * Defaults to 0. Use 1 for 'aria-colindex' which is 1-based.
47
+ */
48
+ columnOffset?: number;
49
+ };
50
+ export declare const ViewportStrategies: {
51
+ dataAttribute: (options?: DataAttributeViewportOptions) => ViewportStrategy;
52
+ };
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViewportStrategies = void 0;
4
+ /**
5
+ * Viewport strategies for tables where row and cell elements carry a DOM attribute
6
+ * equal to their index (e.g. Braintrust logs table, TanStack-style grids).
7
+ *
8
+ * Derives selectors from the table config so no duplication is needed:
9
+ * - getVisibleColumnRange — reads column attribute from cells in the first visible row
10
+ * - getVisibleRowRange — reads row attribute from all visible row elements
11
+ * - scrollToColumn — aligns header's left edge to container left, waits for cell mount
12
+ * - scrollToRow — scrolls row into view, waits for row mount
13
+ *
14
+ * @example
15
+ * // TanStack / Braintrust (data-index, 0-based — default)
16
+ * viewport: Strategies.Viewport.dataAttribute()
17
+ *
18
+ * @example
19
+ * // ARIA grid (aria-rowindex / aria-colindex, 1-based)
20
+ * viewport: Strategies.Viewport.dataAttribute({ rowAttribute: 'aria-rowindex', columnAttribute: 'aria-colindex', rowOffset: 1, columnOffset: 1 })
21
+ */
22
+ const dataAttribute = (options) => {
23
+ var _a, _b, _c, _d, _e, _f, _g;
24
+ const containerSel = (_a = options === null || options === void 0 ? void 0 : options.scrollContainer) !== null && _a !== void 0 ? _a : 'div[class*="overflow-auto"]';
25
+ const attachTimeout = (_b = options === null || options === void 0 ? void 0 : options.attachTimeout) !== null && _b !== void 0 ? _b : 3000;
26
+ const rowAttr = (_c = options === null || options === void 0 ? void 0 : options.rowAttribute) !== null && _c !== void 0 ? _c : 'data-index';
27
+ const colAttr = (_d = options === null || options === void 0 ? void 0 : options.columnAttribute) !== null && _d !== void 0 ? _d : 'data-index';
28
+ const rowOffset = (_e = options === null || options === void 0 ? void 0 : options.rowOffset) !== null && _e !== void 0 ? _e : 0;
29
+ const colOffset = (_f = options === null || options === void 0 ? void 0 : options.columnOffset) !== null && _f !== void 0 ? _f : 0;
30
+ const rowHeight = options === null || options === void 0 ? void 0 : options.rowHeight;
31
+ const columnWidth = options === null || options === void 0 ? void 0 : options.columnWidth;
32
+ const scrollPadding = (_g = options === null || options === void 0 ? void 0 : options.scrollPadding) !== null && _g !== void 0 ? _g : 20;
33
+ return {
34
+ getVisibleColumnRange: async ({ root, config }) => {
35
+ const rowSel = config.rowSelector;
36
+ const cellSel = typeof config.cellSelector === 'string' ? config.cellSelector : `[${colAttr}]`;
37
+ return root.evaluate((el, { rowSel, cellSel, colAttr, colOffset }) => {
38
+ const firstRow = el.querySelector(rowSel);
39
+ if (!firstRow)
40
+ return { first: 0, last: 0 };
41
+ const indices = Array.from(firstRow.querySelectorAll(cellSel))
42
+ .map(c => Number(c.getAttribute(colAttr)) - colOffset)
43
+ .filter(n => !isNaN(n));
44
+ if (!indices.length)
45
+ return { first: 0, last: 0 };
46
+ return { first: Math.min(...indices), last: Math.max(...indices) };
47
+ }, { rowSel, cellSel, colAttr, colOffset });
48
+ },
49
+ getVisibleRowRange: async ({ root, config }) => {
50
+ const rowSel = config.rowSelector;
51
+ return root.evaluate((el, { rowSel, rowAttr, rowOffset }) => {
52
+ const indices = Array.from(el.querySelectorAll(rowSel))
53
+ .map(r => Number(r.getAttribute(rowAttr)) - rowOffset)
54
+ .filter(n => !isNaN(n));
55
+ if (!indices.length)
56
+ return { first: 0, last: 0 };
57
+ return { first: Math.min(...indices), last: Math.max(...indices) };
58
+ }, { rowSel, rowAttr, rowOffset });
59
+ },
60
+ scrollToColumn: async ({ root, config }, colIndex) => {
61
+ const headerSel = typeof config.headerSelector === 'string' ? config.headerSelector : null;
62
+ const cellSel = typeof config.cellSelector === 'string' ? config.cellSelector : `[${colAttr}]`;
63
+ await root.evaluate((el, { containerSel, headerSel, cellSel, idx, columnWidth, scrollPadding }) => {
64
+ const container = el.closest(containerSel);
65
+ if (!container || !headerSel)
66
+ return;
67
+ const headers = Array.from(el.querySelectorAll(headerSel));
68
+ const target = headers[idx];
69
+ if (!target) {
70
+ const widthSources = headers.length ? headers : Array.from(el.querySelectorAll(cellSel));
71
+ const widths = widthSources
72
+ .map(node => node.getBoundingClientRect().width)
73
+ .filter(width => width > 0);
74
+ const estimatedWidth = columnWidth !== null && columnWidth !== void 0 ? columnWidth : (widths.length
75
+ ? widths.reduce((sum, width) => sum + width, 0) / widths.length
76
+ : 120);
77
+ container.scrollLeft = Math.max(0, idx * estimatedWidth - scrollPadding);
78
+ return;
79
+ }
80
+ const cRect = container.getBoundingClientRect();
81
+ const tRect = target.getBoundingClientRect();
82
+ if (tRect.left < cRect.left) {
83
+ // Scrolling left: reveal the target's left edge with padding.
84
+ container.scrollLeft -= (cRect.left - tRect.left) + scrollPadding;
85
+ }
86
+ else if (tRect.right > cRect.right) {
87
+ // Scrolling right: reveal the target's right edge with padding.
88
+ container.scrollLeft += (tRect.right - cRect.right) + scrollPadding;
89
+ }
90
+ }, { containerSel, headerSel, cellSel, idx: colIndex, columnWidth, scrollPadding });
91
+ // Wait for a cell at this column index to mount in any row
92
+ await root
93
+ .locator(`${config.rowSelector} [${colAttr}="${colIndex + colOffset}"]`)
94
+ .first()
95
+ .waitFor({ state: 'attached', timeout: attachTimeout });
96
+ },
97
+ scrollToRow: async ({ root, config }, rowIndex) => {
98
+ const rowSel = config.rowSelector;
99
+ await root.evaluate((el, { containerSel, rowSel, rowAttr, idx, rowOffset, rowHeight, scrollPadding }) => {
100
+ const container = el.closest(containerSel);
101
+ if (!container)
102
+ return;
103
+ const row = container.querySelector(`${rowSel}[${rowAttr}="${idx + rowOffset}"]`);
104
+ if (row) {
105
+ row.scrollIntoView({ block: 'nearest', inline: 'nearest' });
106
+ return;
107
+ }
108
+ const visibleRows = Array.from(container.querySelectorAll(rowSel));
109
+ const heights = visibleRows
110
+ .map(visibleRow => visibleRow.getBoundingClientRect().height)
111
+ .filter(height => height > 0);
112
+ const estimatedHeight = rowHeight !== null && rowHeight !== void 0 ? rowHeight : (heights.length
113
+ ? heights.reduce((sum, height) => sum + height, 0) / heights.length
114
+ : 40);
115
+ container.scrollTop = Math.max(0, idx * estimatedHeight - scrollPadding);
116
+ }, { containerSel, rowSel, rowAttr, idx: rowIndex, rowOffset, rowHeight, scrollPadding });
117
+ await root
118
+ .locator(`${rowSel}[${rowAttr}="${rowIndex + rowOffset}"]`)
119
+ .waitFor({ state: 'attached', timeout: attachTimeout });
120
+ },
121
+ };
122
+ };
123
+ exports.ViewportStrategies = { dataAttribute };
@@ -3,4 +3,4 @@
3
3
  * This file is generated by scripts/embed-types.mjs
4
4
  * It contains the raw text of types.ts to provide context for LLM prompts.
5
5
  */
6
- export declare const TYPE_CONTEXT = "\n/**\n * Flexible selector type - can be a CSS string, function returning a Locator, or Locator itself.\n * @example\n * // String selector\n * rowSelector: 'tbody tr'\n * \n * // Function selector\n * rowSelector: (root) => root.locator('[role=\"row\"]')\n */\nexport type Selector = string | ((root: Locator | Page) => Locator) | ((root: Locator) => Locator);\n\n/**\n * Value used to filter rows.\n * - string/number/RegExp: filter by text content of the cell.\n * - function: filter by custom locator logic within the cell.\n * @example\n * // Text filter\n * { Name: 'John' }\n * \n * // Custom locator filter (e.g. checkbox is checked)\n * { Status: (cell) => cell.locator('input:checked') }\n */\nexport type FilterValue = string | RegExp | number | ((cell: Locator) => Locator);\n\n/**\n * Function to get a cell locator given row, column info.\n * Replaces the old cellResolver.\n */\nexport type GetCellLocatorFn = (args: {\n row: Locator;\n columnName: string;\n columnIndex: number;\n rowIndex?: number;\n page: Page;\n}) => Locator;\n\n/**\n * Hook called before each cell value is read in toJSON (and columnOverrides.read).\n * Use this to scroll off-screen columns into view in horizontally virtualized tables,\n * wait for lazy-rendered content, or perform any pre-read setup.\n *\n * @example\n * // Scroll the column header into view to trigger horizontal virtualization render\n * strategies: {\n * beforeCellRead: async ({ columnName, getHeaderCell }) => {\n * const header = await getHeaderCell(columnName);\n * await header.scrollIntoViewIfNeeded();\n * }\n * }\n */\nexport type BeforeCellReadFn = (args: {\n /** The resolved cell locator */\n cell: Locator;\n columnName: string;\n columnIndex: number;\n row: Locator;\n page: Page;\n root: Locator;\n /** Resolves a column name to its header cell locator */\n getHeaderCell: (columnName: string) => Promise<Locator>;\n}) => Promise<void>;\n\n/**\n * Function to get the currently active/focused cell.\n * Returns null if no cell is active.\n */\nexport type GetActiveCellFn = (args: TableContext) => Promise<{\n rowIndex: number;\n columnIndex: number;\n columnName?: string;\n locator: Locator;\n} | null>;\n\n\n/**\n * SmartRow - A Playwright Locator with table-aware methods.\n * \n * Extends all standard Locator methods (click, isVisible, etc.) with table-specific functionality.\n * \n * @example\n * const row = table.getRow({ Name: 'John Doe' });\n * await row.click(); // Standard Locator method\n * const email = row.getCell('Email'); // Table-aware method\n * const data = await row.toJSON(); // Extract all row data\n * await row.smartFill({ Name: 'Jane', Status: 'Active' }); // Fill form fields\n */\nexport type SmartRow<T = any> = Locator & {\n /** Optional row index (0-based) if known */\n rowIndex?: number;\n\n /** Optional page index this row was found on (0-based) */\n tablePageIndex?: number;\n\n /** Reference to the parent TableResult */\n table: TableResult<T>;\n\n /**\n * Get a cell locator by column name.\n * @param column - Column name (case-sensitive)\n * @returns Locator for the cell\n * @example\n * const emailCell = row.getCell('Email');\n * await expect(emailCell).toHaveText('john@example.com');\n */\n getCell(column: string): Locator;\n\n /**\n * Extract all cell data as a key-value object.\n * @param options - Optional configuration\n * @param options.columns - Specific columns to extract (extracts all if not specified)\n * @returns Promise resolving to row data\n * @example\n * const data = await row.toJSON();\n * // { Name: 'John', Email: 'john@example.com', ... }\n * \n * const partial = await row.toJSON({ columns: ['Name', 'Email'] });\n * // { Name: 'John', Email: 'john@example.com' }\n */\n toJSON(options?: { columns?: string[] }): Promise<T>;\n\n /**\n * Scrolls/paginates to bring this row into view.\n * Only works if rowIndex is known (e.g., from getRowByIndex).\n * @throws Error if rowIndex is unknown\n */\n bringIntoView(): Promise<void>;\n\n /**\n * Intelligently fills form fields in the row.\n * Automatically detects input types (text, select, checkbox, contenteditable).\n * \n * @param data - Column-value pairs to fill\n * @param options - Optional configuration\n * @param options.inputMappers - Custom input selectors per column\n * @example\n * // Auto-detection\n * await row.smartFill({ Name: 'John', Status: 'Active', Subscribe: true });\n * \n * // Custom input mappers\n * await row.smartFill(\n * { Name: 'John' },\n * { inputMappers: { Name: (cell) => cell.locator('.custom-input') } }\n * );\n */\n smartFill: (data: Partial<T> | Record<string, any>, options?: FillOptions) => Promise<void>;\n\n /**\n * Returns whether the row exists in the DOM (i.e. is not a sentinel row).\n */\n wasFound(): boolean;\n};\n\nexport type StrategyContext = TableContext & {\n rowLocator?: Locator;\n rowIndex?: number;\n};\n\n/**\n * Defines the contract for a sorting strategy.\n */\nexport interface SortingStrategy {\n /**\n * Performs the sort action on a column.\n */\n doSort(options: {\n columnName: string;\n direction: 'asc' | 'desc';\n context: StrategyContext;\n }): Promise<void>;\n\n /**\n * Retrieves the current sort state of a column.\n */\n getSortState(options: {\n columnName: string;\n context: StrategyContext;\n }): Promise<'asc' | 'desc' | 'none'>;\n}\n\n/**\n * Debug configuration for development and troubleshooting\n */\nexport type DebugConfig = {\n /**\n * Slow down operations for debugging\n * - number: Apply same delay to all operations (ms)\n * - object: Granular delays per operation type\n */\n slow?: number | {\n pagination?: number;\n getCell?: number;\n findRow?: number;\n default?: number;\n };\n /**\n * Log level for debug output\n * - 'verbose': All logs (verbose, info, error)\n * - 'info': Info and error logs only\n * - 'error': Error logs only\n * - 'none': No logs\n */\n logLevel?: 'verbose' | 'info' | 'error' | 'none';\n};\n\nexport interface TableContext<T = any> {\n root: Locator;\n config: FinalTableConfig<T>;\n page: Page;\n resolve: (selector: Selector, parent: Locator | Page) => Locator;\n /** Resolves a column name to its header cell locator. Available after table is initialized. */\n getHeaderCell?: (columnName: string) => Promise<Locator>;\n /** Returns all column names in order. Available after table is initialized. */\n getHeaders?: () => Promise<string[]>;\n /** Scrolls the table horizontally to bring the given column's header into view. */\n scrollToColumn?: (columnName: string) => Promise<void>;\n}\n\nexport interface PaginationPrimitives {\n /** Classic \"Next Page\" or \"Scroll Down\" */\n goNext?: (context: TableContext) => Promise<boolean>;\n\n /** Classic \"Previous Page\" or \"Scroll Up\" */\n goPrevious?: (context: TableContext) => Promise<boolean>;\n\n /** Bulk skip forward multiple pages at once. Returns number of pages skipped. */\n goNextBulk?: (context: TableContext) => Promise<boolean | number>;\n\n /** Bulk skip backward multiple pages at once. Returns number of pages skipped. */\n goPreviousBulk?: (context: TableContext) => Promise<boolean | number>;\n\n /** Jump to first page / scroll to top */\n goToFirst?: (context: TableContext) => Promise<boolean>;\n\n /**\n * Jump to specific page index (0-indexed).\n * Can be full-range (e.g. page number input: any page works) or windowed (e.g. only visible links 6\u201314).\n * Return false when the page is not reachable in the current UI; the library will step toward the target (goNextBulk/goNext or goPreviousBulk/goPrevious) and retry goToPage until it succeeds.\n */\n goToPage?: (pageIndex: number, context: TableContext) => Promise<boolean>;\n\n /** How many pages one goNextBulk() advances. Used by navigation path planner for optimal bringIntoView. */\n nextBulkPages?: number;\n\n /** How many pages one goPreviousBulk() goes back. Used by navigation path planner for optimal bringIntoView. */\n previousBulkPages?: number;\n}\n\nexport type PaginationStrategy = PaginationPrimitives;\n\nexport type DedupeStrategy = (row: SmartRow) => string | number | Promise<string | number>;\n\n\n\nexport type FillStrategy = (options: {\n row: SmartRow;\n columnName: string;\n value: any;\n index: number;\n page: Page;\n rootLocator: Locator;\n config: FinalTableConfig<any>;\n table: TableResult; // The parent table instance\n fillOptions?: FillOptions;\n}) => Promise<void>;\n\nexport interface ColumnOverride<TValue = any> {\n /** \n * How to extract the value from the cell.\n * `context` provides access to the parent row, permitting multi-cell logic or bypassing the default cell locator.\n */\n read?: (cell: Locator) => Promise<TValue> | TValue;\n\n /** \n * How to fill the cell with a new value. (Replaces smartFill default logic)\n * Provides the current value (via `read`) if a `write` wants to check state first.\n */\n write?: (params: {\n cell: Locator;\n targetValue: TValue;\n currentValue?: TValue;\n row: SmartRow<any>;\n }) => Promise<void>;\n}\n\nexport type { HeaderStrategy } from './strategies/headers';\n\n/**\n * Strategy to resolve column names (string or regex) to their index.\n */\nexport type { ColumnResolutionStrategy } from './strategies/resolution';\n\n/**\n * Strategy to filter rows based on criteria. Applied when using getRow/findRow/findRows with filters.\n * The default engine handles string, RegExp, number, and function (cell) => Locator filters.\n */\nexport interface FilterStrategy {\n apply(options: {\n rows: Locator;\n filter: { column: string, value: FilterValue };\n colIndex: number;\n tableContext: TableContext;\n }): Locator;\n}\n\n/**\n * Strategy to check if the table or rows are loading. Used after pagination/sort to wait for content.\n * E.g. isHeaderLoading for init stability; isTableLoading after sort/pagination.\n */\nexport interface LoadingStrategy {\n isTableLoading?: (context: TableContext) => Promise<boolean>;\n isRowLoading?: (row: SmartRow) => Promise<boolean>;\n isHeaderLoading?: (context: TableContext) => Promise<boolean>;\n}\n\n/**\n * Organized container for all table interaction strategies.\n */\nexport interface TableStrategies {\n /** Strategy for discovering/scanning headers */\n header?: HeaderStrategy;\n /** Primitive navigation functions (goUp, goDown, goLeft, goRight, goHome) */\n navigation?: NavigationPrimitives;\n\n /** Strategy for filling form inputs */\n fill?: FillStrategy;\n /** Strategy for paginating through data */\n pagination?: PaginationStrategy;\n /** Strategy for sorting columns */\n sorting?: SortingStrategy;\n /** Strategy for deduplicating rows during iteration/scrolling */\n dedupe?: DedupeStrategy;\n /** Function to get a cell locator */\n getCellLocator?: GetCellLocatorFn;\n /** Function to get the currently active/focused cell */\n getActiveCell?: GetActiveCellFn;\n /**\n * Strategy for filtering rows. If present, FilterEngine will delegate filter application\n * to this pluggable strategy.\n */\n filter?: FilterStrategy;\n /**\n * Hook called before each cell value is read in toJSON and columnOverrides.read.\n * Fires for both the default innerText extraction and custom read mappers.\n * Useful for scrolling off-screen columns into view in horizontally virtualized tables.\n */\n beforeCellRead?: BeforeCellReadFn;\n /**\n * Strategy for detecting loading states. Use this for table-, row-, and header-level readiness.\n * E.g. after sort/pagination, the engine uses loading.isTableLoading when present.\n */\n loading?: LoadingStrategy;\n}\n\n\nexport interface TableConfig<T = any> {\n /** Selector for the table headers */\n headerSelector?: string | ((root: Locator) => Locator);\n /** Selector for the table rows */\n rowSelector?: string;\n /** Selector for the cells within a row */\n cellSelector?: string | ((row: Locator) => Locator);\n /** Number of pages to scan for verification */\n maxPages?: number;\n /**\n * Default concurrency strategy for iteration methods.\n * Can be overridden by the options passed to forEach, map, or filter.\n */\n concurrency?: RowIterationMode;\n /** Hook to rename columns dynamically */\n headerTransformer?: (args: { text: string, index: number, locator: Locator, seenHeaders: Set<string> }) => string | Promise<string>;\n /** Automatically scroll to table on init */\n autoScroll?: boolean;\n /** Debug options for development and troubleshooting */\n debug?: DebugConfig;\n /** Reset hook */\n onReset?: (context: TableContext) => Promise<void>;\n /** All interaction strategies */\n strategies?: TableStrategies;\n\n /**\n * Unified interface for reading and writing data to specific columns.\n * Overrides both default extraction (toJSON) and filling (smartFill) logic.\n */\n columnOverrides?: Partial<Record<keyof T, ColumnOverride<T[keyof T]>>>;\n}\n\nexport interface FinalTableConfig<T = any> extends TableConfig<T> {\n headerSelector: string | ((root: Locator) => Locator);\n rowSelector: string;\n cellSelector: string | ((row: Locator) => Locator);\n maxPages: number;\n autoScroll: boolean;\n concurrency?: RowIterationMode;\n debug?: TableConfig['debug'];\n headerTransformer: (args: { text: string, index: number, locator: Locator, seenHeaders: Set<string> }) => string | Promise<string>;\n onReset: (context: TableContext) => Promise<void>;\n strategies: TableStrategies;\n}\n\n\nexport interface FillOptions {\n /**\n * Custom input mappers for specific columns.\n * Maps column names to functions that return the input locator for that cell.\n */\n inputMappers?: Record<string, (cell: Locator) => Locator>;\n}\n\n\n\n/** Callback context passed to forEach, map, and filter. */\nexport type RowIterationContext<T = any> = {\n row: SmartRow<T>;\n rowIndex: number;\n stop: () => void;\n};\n\n/** Concurrency modes for row iteration. */\nexport type RowIterationMode = 'parallel' | 'sequential' | 'synchronized';\n\n/** Shared options for forEach, map, and filter. */\nexport type RowIterationOptions = {\n /** Maximum number of pages to iterate. Defaults to config.maxPages. */\n maxPages?: number;\n /**\n * @deprecated Use 'concurrency' mode instead.\n * - parallel: true -> concurrency: 'parallel'\n * - parallel: false -> concurrency: 'sequential'\n */\n parallel?: boolean;\n /**\n * Concurrency strategy for iteration.\n * - 'parallel': Full parallel execution of both navigation and actions.\n * - 'synchronized': Parallel navigation (lock-step) with serial actions.\n * - 'sequential': Strictly serial one-at-a-time execution. No parallel navigation.\n * @default 'parallel' (for map), 'sequential' (for forEach/filter)\n */\n concurrency?: RowIterationMode;\n /**\n * Deduplication strategy. Use when rows may repeat across iterations\n * (e.g. infinite scroll tables). Returns a unique key per row.\n */\n dedupe?: DedupeStrategy;\n /**\n * When true, use goNextBulk (if present) to advance pages during iteration.\n * @default false \u2014 uses goNext for one-page-at-a-time advancement\n */\n useBulkPagination?: boolean;\n};\n\nexport interface TableResult<T = any> extends AsyncIterable<{ row: SmartRow<T>; rowIndex: number }> {\n /**\n * Represents the current page index of the table's DOM.\n * Starts at 0. Automatically maintained by the library during pagination and bringIntoView.\n */\n currentPageIndex: number;\n\n /**\n * Initializes the table by resolving headers. Must be called before using sync methods.\n * @param options Optional timeout for header resolution (default: 3000ms)\n */\n init(options?: { timeout?: number }): Promise<TableResult>;\n\n /**\n * SYNC: Checks if the table has been initialized.\n * @returns true if init() has been called and completed, false otherwise\n */\n isInitialized(): boolean;\n\n getHeaders: () => Promise<string[]>;\n getHeaderCell: (columnName: string) => Promise<Locator>;\n\n /**\n * Finds a row by filters on the current page only. Returns immediately (sync).\n * Throws error if table is not initialized.\n * @note The returned SmartRow may have `rowIndex` as 0 when the match is not the first row.\n * Use getRowByIndex(index) when you need a known index (e.g. for bringIntoView()).\n */\n getRow: (\n filters: Record<string, FilterValue>,\n options?: { exact?: boolean }\n ) => SmartRow;\n\n /**\n * Gets a row by 0-based index on the current page.\n * Throws error if table is not initialized.\n * @param index 0-based row index\n */\n getRowByIndex: (\n index: number\n ) => SmartRow;\n\n /**\n * ASYNC: Searches for a single row across pages using pagination.\n * Auto-initializes the table if not already initialized.\n * @param filters - The filter criteria to match\n * @param options - Search options including exact match and max pages\n */\n findRow: (\n filters: Record<string, FilterValue>,\n options?: { exact?: boolean, maxPages?: number }\n ) => Promise<SmartRow>;\n\n /**\n * ASYNC: Searches for all matching rows across pages using pagination.\n * Auto-initializes the table if not already initialized.\n * @param filters - The filter criteria to match (omit or pass {} for all rows)\n * @param options - Search options including exact match and max pages\n */\n findRows: (\n filters?: Record<string, FilterValue>,\n options?: { exact?: boolean, maxPages?: number }\n ) => Promise<SmartRowArray<T>>;\n\n /**\n * Navigates to a specific column using the configured CellNavigationStrategy.\n */\n scrollToColumn: (columnName: string) => Promise<void>;\n\n\n\n /**\n * Resets the table state (clears cache, flags) and invokes the onReset strategy.\n */\n reset: () => Promise<void>;\n\n /**\n * Revalidates the table's structure (headers, columns) without resetting pagination or state.\n * Useful when columns change visibility or order dynamically.\n */\n revalidate: () => Promise<void>;\n\n /**\n * Iterates every row across all pages, calling the callback for side effects.\n * Execution is sequential by default (safe for interactions like clicking/filling).\n * Call `stop()` in the callback to end iteration early.\n *\n * @param callback - Function receiving { row, rowIndex, stop }\n * @param options - maxPages, concurrency, dedupe, useBulkPagination (`parallel` is deprecated; use `concurrency`)\n *\n * @example\n * await table.forEach(async ({ row, stop }) => {\n * if (await row.getCell('Status').innerText() === 'Done') stop();\n * await row.getCell('Checkbox').click();\n * });\n */\n forEach(\n callback: (ctx: RowIterationContext<T>) => void | Promise<void>,\n options?: RowIterationOptions\n ): Promise<void>;\n\n /**\n * Transforms every row across all pages into a value. Returns a flat array.\n * Execution is parallel within each page by default (safe for reads).\n * Call `stop()` to halt after the current page finishes.\n *\n * > **\u26A0\uFE0F UI Interactions:** `map` defaults to `concurrency: 'parallel'`. If your callback opens popovers,\n * > fills inputs, or otherwise mutates UI state, pass `concurrency: 'sequential'` (or `'synchronized'`\n * > when navigation must stay lock-step) to avoid overlapping interactions.\n *\n * @param callback - Function receiving { row, rowIndex, stop }\n * @param options - maxPages, concurrency, dedupe, useBulkPagination (`parallel` is deprecated; use `concurrency`)\n *\n * @example\n * // Data extraction \u2014 parallel is safe\n * const emails = await table.map(({ row }) => row.getCell('Email').innerText());\n *\n * @example\n * // UI interactions \u2014 use sequential (or synchronized) concurrency\n * const assignees = await table.map(async ({ row }) => {\n * await row.getCell('Assignee').locator('button').click();\n * const name = await page.locator('.popover .name').innerText();\n * await page.keyboard.press('Escape');\n * return name;\n * }, { concurrency: 'sequential' });\n */\n map<R>(\n callback: (ctx: RowIterationContext<T>) => R | Promise<R>,\n options?: RowIterationOptions\n ): Promise<R[]>;\n\n /**\n * Filters rows across all pages by an async predicate. Returns a SmartRowArray.\n * Rows are returned as-is \u2014 call `bringIntoView()` on each if needed.\n * Execution is sequential by default.\n *\n * @param predicate - Function receiving { row, rowIndex, stop }\n * @param options - maxPages, concurrency, dedupe, useBulkPagination (`parallel` is deprecated; use `concurrency`)\n *\n * @example\n * const active = await table.filter(async ({ row }) =>\n * await row.getCell('Status').innerText() === 'Active'\n * );\n */\n filter(\n predicate: (ctx: RowIterationContext<T>) => boolean | Promise<boolean>,\n options?: RowIterationOptions\n ): Promise<SmartRowArray<T>>;\n\n /**\n * Provides access to sorting actions and assertions.\n */\n sorting: {\n /**\n * Applies the configured sorting strategy to the specified column.\n * @param columnName The name of the column to sort.\n * @param direction The direction to sort ('asc' or 'desc').\n */\n apply(columnName: string, direction: 'asc' | 'desc'): Promise<void>;\n /**\n * Gets the current sort state of a column using the configured sorting strategy.\n * @param columnName The name of the column to check.\n * @returns A promise that resolves to 'asc', 'desc', or 'none'.\n */\n getState(columnName: string): Promise<'asc' | 'desc' | 'none'>;\n };\n\n /**\n * Generate an AI-friendly configuration prompt for debugging.\n * Outputs table HTML and TypeScript definitions to help AI assistants generate config.\n * Automatically throws an Error containing the prompt.\n */\n generateConfig: () => Promise<void>;\n\n /**\n * @deprecated Use `generateConfig()` instead. Will be removed in v7.0.0.\n */\n generateConfigPrompt: () => Promise<void>;\n}\n";
6
+ export declare const TYPE_CONTEXT = "\n/**\n * Flexible selector type - can be a CSS string, function returning a Locator, or Locator itself.\n * @example\n * // String selector\n * rowSelector: 'tbody tr'\n * \n * // Function selector\n * rowSelector: (root) => root.locator('[role=\"row\"]')\n */\nexport type Selector = string | ((root: Locator | Page) => Locator) | ((root: Locator) => Locator);\n\n/**\n * Value used to filter rows.\n * - string/number/RegExp: filter by text content of the cell.\n * - function: filter by custom locator logic within the cell.\n * @example\n * // Text filter\n * { Name: 'John' }\n * \n * // Custom locator filter (e.g. checkbox is checked)\n * { Status: (cell) => cell.locator('input:checked') }\n */\nexport type FilterValue = string | RegExp | number | ((cell: Locator) => Locator);\n\n/**\n * Function to get a cell locator given row, column info.\n * Replaces the old cellResolver.\n */\nexport type GetCellLocatorFn = (args: {\n row: Locator;\n /** The root locator passed to useTable(). Useful for re-querying stale row locators. */\n root: Locator;\n columnName: string;\n columnIndex: number;\n rowIndex?: number;\n page: Page;\n config: FinalTableConfig<any>;\n}) => Locator;\n\n/**\n * Hook called before each cell value is read in toJSON (and columnOverrides.read).\n * Use this to scroll off-screen columns into view in horizontally virtualized tables,\n * wait for lazy-rendered content, or perform any pre-read setup.\n *\n * @example\n * // Scroll the column header into view to trigger horizontal virtualization render\n * strategies: {\n * beforeCellRead: async ({ columnName, getHeaderCell }) => {\n * const header = await getHeaderCell(columnName);\n * await header.scrollIntoViewIfNeeded();\n * }\n * }\n */\nexport type BeforeCellReadFn = (args: {\n /** The resolved cell locator */\n cell: Locator;\n columnName: string;\n columnIndex: number;\n row: Locator;\n page: Page;\n root: Locator;\n /** Resolves a column name to its header cell locator */\n getHeaderCell: (columnName: string) => Promise<Locator>;\n}) => Promise<void>;\n\n/**\n * Function to get the currently active/focused cell.\n * Returns null if no cell is active.\n */\nexport type GetActiveCellFn = (args: TableContext) => Promise<{\n rowIndex: number;\n columnIndex: number;\n columnName?: string;\n locator: Locator;\n} | null>;\n\n/**\n * Viewport oracle strategies for virtualized tables.\n *\n * These tell the library *what is currently in the DOM* rather than *how to move*.\n * When present, the cell-reading engine uses them to jump directly to a target\n * row/column instead of stepping blindly with navigation primitives.\n *\n * This is the primary fix for the 2D scroll hazard: scrolling right to bring a\n * column into view can knock rows out of the vertical viewport (and vice versa).\n * With `getVisibleRowRange` the engine detects this and calls `scrollToRow` to\n * restore the row before reading \u2014 eliminating the hazard without polling loops.\n *\n * All members are optional. Supply whichever the underlying grid exposes:\n * - Range oracles alone enable hazard detection with graceful fallback to navigation primitives.\n * - Scroll primitives alone enable direct jumps without range awareness.\n * - Both together give the most reliable, fastest path.\n *\n * @example\n * // MUI DataGrid via apiRef\n * strategies: {\n * viewport: {\n * getVisibleRowRange: async ({ root }) =>\n * root.evaluate(el => {\n * const api = (el as any).__muiDataGrid__;\n * return { first: api.getFirstVisibleRow(), last: api.getLastVisibleRow() };\n * }),\n * scrollToRow: async ({ root }, rowIndex) =>\n * root.evaluate((el, idx) =>\n * (el as any).__muiDataGrid__.scrollToIndexes({ rowIndex: idx }), rowIndex),\n * scrollToColumn: async ({ root }, colIndex) =>\n * root.evaluate((el, idx) =>\n * (el as any).__muiDataGrid__.scrollToIndexes({ colIndex: idx }), colIndex),\n * }\n * }\n *\n * @example\n * // aria-rowindex / aria-colindex DOM fallback (works without internal API access)\n * strategies: {\n * viewport: {\n * getVisibleRowRange: async ({ root }) =>\n * root.evaluate(el => {\n * const rows = [...el.querySelectorAll('[role=\"row\"][aria-rowindex]')];\n * const idxs = rows.map(r => Number(r.getAttribute('aria-rowindex')) - 1);\n * return { first: Math.min(...idxs), last: Math.max(...idxs) };\n * }),\n * }\n * }\n */\nexport interface ViewportStrategy {\n /**\n * Returns the 0-based index range of rows currently rendered in the DOM.\n * Used to detect when a target row has been scrolled out of view and needs recovery.\n */\n getVisibleRowRange?: (context: TableContext) => Promise<{ first: number; last: number }>;\n\n /**\n * Returns the 0-based index range of columns currently rendered in the DOM.\n * Used to detect when a target column is not yet mounted before reading.\n */\n getVisibleColumnRange?: (context: TableContext) => Promise<{ first: number; last: number }>;\n\n /**\n * Scrolls or jumps directly to make a row visible by 0-based index.\n * Replaces blind goDown()/goUp() step loops for grids that expose a scroll API.\n */\n scrollToRow?: (context: TableContext, rowIndex: number) => Promise<void>;\n\n /**\n * Scrolls or jumps directly to make a column visible by 0-based index.\n * Replaces blind goRight()/goLeft() step loops for grids that expose a scroll API.\n */\n scrollToColumn?: (context: TableContext, colIndex: number) => Promise<void>;\n\n /**\n * When true, disables the automatic memoization of getVisibleColumnRange and\n * getVisibleRowRange results. By default the library caches each range value and\n * invalidates it after the corresponding scroll call, eliminating redundant DOM\n * evaluate() round-trips between scrolls.\n */\n disableCache?: boolean;\n}\n\n\n/**\n * SmartRow - A Playwright Locator with table-aware methods.\n * \n * Extends all standard Locator methods (click, isVisible, etc.) with table-specific functionality.\n * \n * @example\n * const row = table.getRow({ Name: 'John Doe' });\n * await row.click(); // Standard Locator method\n * const email = row.getCell('Email'); // Table-aware method\n * const data = await row.toJSON(); // Extract all row data\n * await row.smartFill({ Name: 'Jane', Status: 'Active' }); // Fill form fields\n */\nexport type SmartRow<T = any> = Locator & {\n /** Optional row index (0-based) if known */\n rowIndex?: number;\n\n /** Optional page index this row was found on (0-based) */\n tablePageIndex?: number;\n\n /** Reference to the parent TableResult */\n table: TableResult<T>;\n\n /**\n * Get a cell locator by column name.\n * @param column - Column name (case-sensitive)\n * @returns Locator for the cell\n * @example\n * const emailCell = row.getCell('Email');\n * await expect(emailCell).toHaveText('john@example.com');\n */\n getCell(column: string): Locator;\n\n /**\n * Extract all cell data as a key-value object.\n * @param options - Optional configuration\n * @param options.columns - Specific columns to extract (extracts all if not specified)\n * @returns Promise resolving to row data\n * @example\n * const data = await row.toJSON();\n * // { Name: 'John', Email: 'john@example.com', ... }\n * \n * const partial = await row.toJSON({ columns: ['Name', 'Email'] });\n * // { Name: 'John', Email: 'john@example.com' }\n */\n toJSON(options?: { columns?: string[] }): Promise<T>;\n\n /**\n * Scrolls/paginates to bring this row into view.\n * Only works if rowIndex is known (e.g., from getRowByIndex).\n * @throws Error if rowIndex is unknown\n */\n bringIntoView(): Promise<void>;\n\n /**\n * Intelligently fills form fields in the row.\n * Automatically detects input types (text, select, checkbox, contenteditable).\n * \n * @param data - Column-value pairs to fill\n * @param options - Optional configuration\n * @param options.inputMappers - Custom input selectors per column\n * @example\n * // Auto-detection\n * await row.smartFill({ Name: 'John', Status: 'Active', Subscribe: true });\n * \n * // Custom input mappers\n * await row.smartFill(\n * { Name: 'John' },\n * { inputMappers: { Name: (cell) => cell.locator('.custom-input') } }\n * );\n */\n smartFill: (data: Partial<T> | Record<string, any>, options?: FillOptions) => Promise<void>;\n\n /**\n * Returns whether the row exists in the DOM (i.e. is not a sentinel row).\n */\n wasFound(): boolean;\n};\n\nexport type StrategyContext = TableContext & {\n rowLocator?: Locator;\n rowIndex?: number;\n};\n\n/**\n * Defines the contract for a sorting strategy.\n */\nexport interface SortingStrategy {\n /**\n * Performs the sort action on a column.\n */\n doSort(options: {\n columnName: string;\n direction: 'asc' | 'desc';\n context: StrategyContext;\n }): Promise<void>;\n\n /**\n * Retrieves the current sort state of a column.\n */\n getSortState(options: {\n columnName: string;\n context: StrategyContext;\n }): Promise<'asc' | 'desc' | 'none'>;\n}\n\n/**\n * Debug configuration for development and troubleshooting\n */\nexport type DebugConfig = {\n /**\n * Slow down operations for debugging\n * - number: Apply same delay to all operations (ms)\n * - object: Granular delays per operation type\n */\n slow?: number | {\n pagination?: number;\n getCell?: number;\n findRow?: number;\n default?: number;\n };\n /**\n * Log level for debug output\n * - 'verbose': All logs (verbose, info, error)\n * - 'info': Info and error logs only\n * - 'error': Error logs only\n * - 'none': No logs\n */\n logLevel?: 'verbose' | 'info' | 'error' | 'none';\n};\n\nexport interface TableContext<T = any> {\n root: Locator;\n config: FinalTableConfig<T>;\n page: Page;\n resolve: (selector: Selector, parent: Locator | Page) => Locator;\n /** Resolves a column name to its header cell locator. Available after table is initialized. */\n getHeaderCell?: (columnName: string) => Promise<Locator>;\n /** Returns all column names in order. Available after table is initialized. */\n getHeaders?: () => Promise<string[]>;\n /** Scrolls the table horizontally to bring the given column's header into view. */\n scrollToColumn?: (columnName: string) => Promise<void>;\n}\n\nexport interface PaginationPrimitives {\n /** Classic \"Next Page\" or \"Scroll Down\" */\n goNext?: (context: TableContext) => Promise<boolean>;\n\n /** Classic \"Previous Page\" or \"Scroll Up\" */\n goPrevious?: (context: TableContext) => Promise<boolean>;\n\n /** Bulk skip forward multiple pages at once. Returns number of pages skipped. */\n goNextBulk?: (context: TableContext) => Promise<boolean | number>;\n\n /** Bulk skip backward multiple pages at once. Returns number of pages skipped. */\n goPreviousBulk?: (context: TableContext) => Promise<boolean | number>;\n\n /** Jump to first page / scroll to top */\n goToFirst?: (context: TableContext) => Promise<boolean>;\n\n /**\n * Jump to specific page index (0-indexed).\n * Can be full-range (e.g. page number input: any page works) or windowed (e.g. only visible links 6\u201314).\n * Return false when the page is not reachable in the current UI; the library will step toward the target (goNextBulk/goNext or goPreviousBulk/goPrevious) and retry goToPage until it succeeds.\n */\n goToPage?: (pageIndex: number, context: TableContext) => Promise<boolean>;\n\n /** How many pages one goNextBulk() advances. Used by navigation path planner for optimal bringIntoView. */\n nextBulkPages?: number;\n\n /** How many pages one goPreviousBulk() goes back. Used by navigation path planner for optimal bringIntoView. */\n previousBulkPages?: number;\n}\n\nexport type PaginationStrategy = PaginationPrimitives;\n\nexport type DedupeStrategy = (row: SmartRow) => string | number | Promise<string | number>;\n\n\n\nexport type FillStrategy = (options: {\n row: SmartRow;\n columnName: string;\n value: any;\n index: number;\n page: Page;\n rootLocator: Locator;\n config: FinalTableConfig<any>;\n table: TableResult; // The parent table instance\n fillOptions?: FillOptions;\n}) => Promise<void>;\n\nexport interface ColumnOverride<TValue = any> {\n /** \n * How to extract the value from the cell.\n * `context` provides access to the parent row, permitting multi-cell logic or bypassing the default cell locator.\n */\n read?: (cell: Locator) => Promise<TValue> | TValue;\n\n /** \n * How to fill the cell with a new value. (Replaces smartFill default logic)\n * Provides the current value (via `read`) if a `write` wants to check state first.\n */\n write?: (params: {\n cell: Locator;\n targetValue: TValue;\n currentValue?: TValue;\n row: SmartRow<any>;\n }) => Promise<void>;\n}\n\nexport type { HeaderStrategy } from './strategies/headers';\n\n/**\n * Strategy to resolve column names (string or regex) to their index.\n */\nexport type { ColumnResolutionStrategy } from './strategies/resolution';\n\n/**\n * Strategy to filter rows based on criteria. Applied when using getRow/findRow/findRows with filters.\n * The default engine handles string, RegExp, number, and function (cell) => Locator filters.\n */\nexport interface FilterStrategy {\n apply(options: {\n rows: Locator;\n filter: { column: string, value: FilterValue };\n colIndex: number;\n tableContext: TableContext;\n }): Locator;\n}\n\n/**\n * Strategy to check if the table or rows are loading. Used after pagination/sort to wait for content.\n * E.g. isHeaderLoading for init stability; isTableLoading after sort/pagination.\n */\nexport interface LoadingStrategy {\n isTableLoading?: (context: TableContext) => Promise<boolean>;\n isRowLoading?: (row: SmartRow) => Promise<boolean>;\n isHeaderLoading?: (context: TableContext) => Promise<boolean>;\n}\n\n/**\n * Organized container for all table interaction strategies.\n */\nexport interface TableStrategies {\n /** Strategy for discovering/scanning headers */\n header?: HeaderStrategy;\n /** Primitive navigation functions (goUp, goDown, goLeft, goRight, goHome) */\n navigation?: NavigationPrimitives;\n\n /** Strategy for filling form inputs */\n fill?: FillStrategy;\n /** Strategy for paginating through data */\n pagination?: PaginationStrategy;\n /** Strategy for sorting columns */\n sorting?: SortingStrategy;\n /** Strategy for deduplicating rows during iteration/scrolling */\n dedupe?: DedupeStrategy;\n /** Function to get a cell locator */\n getCellLocator?: GetCellLocatorFn;\n /** Function to get the currently active/focused cell */\n getActiveCell?: GetActiveCellFn;\n /**\n * Strategy for filtering rows. If present, FilterEngine will delegate filter application\n * to this pluggable strategy.\n */\n filter?: FilterStrategy;\n /**\n * Hook called before each cell value is read in toJSON and columnOverrides.read.\n * Fires for both the default innerText extraction and custom read mappers.\n * Useful for scrolling off-screen columns into view in horizontally virtualized tables.\n */\n beforeCellRead?: BeforeCellReadFn;\n /**\n * Strategy for detecting loading states. Use this for table-, row-, and header-level readiness.\n * E.g. after sort/pagination, the engine uses loading.isTableLoading when present.\n */\n loading?: LoadingStrategy;\n\n /**\n * Viewport oracle strategies for 2D virtualized tables (e.g. MUI DataGrid, AG Grid,\n * Braintrust-style grids where both rows and columns are virtualized simultaneously).\n *\n * When present, the cell-reading engine uses these to jump directly to the target\n * row/column and to detect the 2D scroll hazard (scrolling to reveal a column can\n * knock rows out of the vertical viewport, and vice versa).\n *\n * Completely optional and additive \u2014 existing `navigation` primitives remain the fallback.\n */\n viewport?: ViewportStrategy;\n}\n\n\nexport interface TableConfig<T = any> {\n /** Selector for the table headers */\n headerSelector?: string | ((root: Locator) => Locator);\n /** Selector for the table rows */\n rowSelector?: string;\n /** Selector for the cells within a row */\n cellSelector?: string | ((row: Locator) => Locator);\n /** Number of pages to scan for verification */\n maxPages?: number;\n /**\n * Default concurrency strategy for iteration methods.\n * Can be overridden by the options passed to forEach, map, or filter.\n */\n concurrency?: RowIterationMode;\n /** Hook to rename columns dynamically */\n headerTransformer?: (args: { text: string, index: number, locator: Locator, seenHeaders: Set<string> }) => string | Promise<string>;\n /** Automatically scroll to table on init */\n autoScroll?: boolean;\n /** Debug options for development and troubleshooting */\n debug?: DebugConfig;\n /** Reset hook */\n onReset?: (context: TableContext) => Promise<void>;\n /** All interaction strategies */\n strategies?: TableStrategies;\n\n /**\n * Unified interface for reading and writing data to specific columns.\n * Overrides both default extraction (toJSON) and filling (smartFill) logic.\n */\n columnOverrides?: Partial<Record<keyof T, ColumnOverride<T[keyof T]>>>;\n}\n\nexport interface FinalTableConfig<T = any> extends TableConfig<T> {\n headerSelector: string | ((root: Locator) => Locator);\n rowSelector: string;\n cellSelector: string | ((row: Locator) => Locator);\n maxPages: number;\n autoScroll: boolean;\n concurrency?: RowIterationMode;\n debug?: TableConfig['debug'];\n headerTransformer: (args: { text: string, index: number, locator: Locator, seenHeaders: Set<string> }) => string | Promise<string>;\n onReset: (context: TableContext) => Promise<void>;\n strategies: TableStrategies;\n}\n\n\nexport interface FillOptions {\n /**\n * Custom input mappers for specific columns.\n * Maps column names to functions that return the input locator for that cell.\n */\n inputMappers?: Record<string, (cell: Locator) => Locator>;\n}\n\n\n\n/** Callback context passed to forEach, map, and filter. */\nexport type RowIterationContext<T = any> = {\n row: SmartRow<T>;\n rowIndex: number;\n stop: () => void;\n};\n\n/** Concurrency modes for row iteration. */\nexport type RowIterationMode = 'parallel' | 'sequential' | 'synchronized';\n\n/** Shared options for forEach, map, and filter. */\nexport type RowIterationOptions = {\n /** Maximum number of pages to iterate. Defaults to config.maxPages. */\n maxPages?: number;\n /**\n * Concurrency strategy for iteration.\n * - 'parallel': Full parallel execution of both navigation and actions.\n * - 'synchronized': Parallel navigation (lock-step) with serial actions.\n * - 'sequential': Strictly serial one-at-a-time execution. No parallel navigation.\n * @default 'parallel' (for map), 'sequential' (for forEach/filter)\n */\n concurrency?: RowIterationMode;\n /**\n * Deduplication strategy. Use when rows may repeat across iterations\n * (e.g. infinite scroll tables). Returns a unique key per row.\n */\n dedupe?: DedupeStrategy;\n /**\n * When true, use goNextBulk (if present) to advance pages during iteration.\n * @default false \u2014 uses goNext for one-page-at-a-time advancement\n */\n useBulkPagination?: boolean;\n};\n\nexport interface TableResult<T = any> extends AsyncIterable<{ row: SmartRow<T>; rowIndex: number }> {\n /**\n * Represents the current page index of the table's DOM.\n * Starts at 0. Automatically maintained by the library during pagination and bringIntoView.\n */\n currentPageIndex: number;\n\n /**\n * Initializes the table by resolving headers. Must be called before using sync methods.\n * @param options Optional timeout for header resolution (default: 3000ms)\n */\n init(options?: { timeout?: number }): Promise<TableResult>;\n\n /**\n * SYNC: Checks if the table has been initialized.\n * @returns true if init() has been called and completed, false otherwise\n */\n isInitialized(): boolean;\n\n getHeaders: () => Promise<string[]>;\n getHeaderCell: (columnName: string) => Promise<Locator>;\n\n /**\n * Finds a row by filters on the current page only. Returns immediately (sync).\n * Throws error if table is not initialized.\n * @note The returned SmartRow may have `rowIndex` as 0 when the match is not the first row.\n * Use getRowByIndex(index) when you need a known index (e.g. for bringIntoView()).\n */\n getRow: (\n filters: Record<string, FilterValue>,\n options?: { exact?: boolean }\n ) => SmartRow;\n\n /**\n * Gets a row by 0-based index on the current page.\n * Throws error if table is not initialized.\n * @param index 0-based row index\n */\n getRowByIndex: (\n index: number\n ) => SmartRow;\n\n /**\n * ASYNC: Searches for a single row across pages using pagination.\n * Auto-initializes the table if not already initialized.\n * @param filters - The filter criteria to match\n * @param options - Search options including exact match and max pages\n */\n findRow: (\n filters: Record<string, FilterValue>,\n options?: { exact?: boolean, maxPages?: number }\n ) => Promise<SmartRow>;\n\n /**\n * ASYNC: Searches for all matching rows across pages using pagination.\n * Auto-initializes the table if not already initialized.\n * @param filters - The filter criteria to match (omit or pass {} for all rows)\n * @param options - Search options including exact match and max pages\n */\n findRows: (\n filters?: Record<string, FilterValue>,\n options?: { exact?: boolean, maxPages?: number }\n ) => Promise<SmartRowArray<T>>;\n\n /**\n * Navigates to a specific column using the configured CellNavigationStrategy.\n */\n scrollToColumn: (columnName: string) => Promise<void>;\n\n\n\n /**\n * Resets the table state (clears cache, flags) and invokes the onReset strategy.\n */\n reset: () => Promise<void>;\n\n /**\n * Revalidates the table's structure (headers, columns) without resetting pagination or state.\n * Useful when columns change visibility or order dynamically.\n */\n revalidate: () => Promise<void>;\n\n /**\n * Iterates every row across all pages, calling the callback for side effects.\n * Execution is sequential by default (safe for interactions like clicking/filling).\n * Call `stop()` in the callback to end iteration early.\n *\n * @param callback - Function receiving { row, rowIndex, stop }\n * @param options - maxPages, concurrency, dedupe, useBulkPagination\n *\n * @example\n * await table.forEach(async ({ row, stop }) => {\n * if (await row.getCell('Status').innerText() === 'Done') stop();\n * await row.getCell('Checkbox').click();\n * });\n */\n forEach(\n callback: (ctx: RowIterationContext<T>) => void | Promise<void>,\n options?: RowIterationOptions\n ): Promise<void>;\n\n /**\n * Transforms every row across all pages into a value. Returns a flat array.\n * Execution is parallel within each page by default (safe for reads).\n * Call `stop()` to halt after the current page finishes.\n *\n * > **\u26A0\uFE0F UI Interactions:** `map` defaults to `concurrency: 'parallel'`. If your callback opens popovers,\n * > fills inputs, or otherwise mutates UI state, pass `concurrency: 'sequential'` (or `'synchronized'`\n * > when navigation must stay lock-step) to avoid overlapping interactions.\n *\n * @param callback - Function receiving { row, rowIndex, stop }\n * @param options - maxPages, concurrency, dedupe, useBulkPagination\n *\n * @example\n * // Data extraction \u2014 parallel is safe\n * const emails = await table.map(({ row }) => row.getCell('Email').innerText());\n *\n * @example\n * // UI interactions \u2014 use sequential (or synchronized) concurrency\n * const assignees = await table.map(async ({ row }) => {\n * await row.getCell('Assignee').locator('button').click();\n * const name = await page.locator('.popover .name').innerText();\n * await page.keyboard.press('Escape');\n * return name;\n * }, { concurrency: 'sequential' });\n */\n map<R>(\n callback: (ctx: RowIterationContext<T>) => R | Promise<R>,\n options?: RowIterationOptions\n ): Promise<R[]>;\n\n /**\n * Filters rows across all pages by an async predicate. Returns a SmartRowArray.\n * Rows are returned as-is \u2014 call `bringIntoView()` on each if needed.\n * Execution is sequential by default.\n *\n * @param predicate - Function receiving { row, rowIndex, stop }\n * @param options - maxPages, concurrency, dedupe, useBulkPagination\n *\n * @example\n * const active = await table.filter(async ({ row }) =>\n * await row.getCell('Status').innerText() === 'Active'\n * );\n */\n filter(\n predicate: (ctx: RowIterationContext<T>) => boolean | Promise<boolean>,\n options?: RowIterationOptions\n ): Promise<SmartRowArray<T>>;\n\n /**\n * Provides access to sorting actions and assertions.\n */\n sorting: {\n /**\n * Applies the configured sorting strategy to the specified column.\n * @param columnName The name of the column to sort.\n * @param direction The direction to sort ('asc' or 'desc').\n */\n apply(columnName: string, direction: 'asc' | 'desc'): Promise<void>;\n /**\n * Gets the current sort state of a column using the configured sorting strategy.\n * @param columnName The name of the column to check.\n * @returns A promise that resolves to 'asc', 'desc', or 'none'.\n */\n getState(columnName: string): Promise<'asc' | 'desc' | 'none'>;\n };\n\n /**\n * Generate an AI-friendly configuration prompt for debugging.\n * Outputs table HTML and TypeScript definitions to help AI assistants generate config.\n * Automatically throws an Error containing the prompt.\n */\n generateConfig: () => Promise<void>;\n\n /**\n * @deprecated Use `generateConfig()` instead. Will be removed in v7.0.0.\n */\n generateConfigPrompt: () => Promise<void>;\n}\n";
@@ -37,10 +37,13 @@ export type FilterValue = string | RegExp | number | ((cell: Locator) => Locator
37
37
  */
38
38
  export type GetCellLocatorFn = (args: {
39
39
  row: Locator;
40
+ /** The root locator passed to useTable(). Useful for re-querying stale row locators. */
41
+ root: Locator;
40
42
  columnName: string;
41
43
  columnIndex: number;
42
44
  rowIndex?: number;
43
45
  page: Page;
46
+ config: FinalTableConfig<any>;
44
47
  }) => Locator;
45
48
 
46
49
  /**
@@ -80,6 +83,88 @@ export type GetActiveCellFn = (args: TableContext) => Promise<{
80
83
  locator: Locator;
81
84
  } | null>;
82
85
 
86
+ /**
87
+ * Viewport oracle strategies for virtualized tables.
88
+ *
89
+ * These tell the library *what is currently in the DOM* rather than *how to move*.
90
+ * When present, the cell-reading engine uses them to jump directly to a target
91
+ * row/column instead of stepping blindly with navigation primitives.
92
+ *
93
+ * This is the primary fix for the 2D scroll hazard: scrolling right to bring a
94
+ * column into view can knock rows out of the vertical viewport (and vice versa).
95
+ * With \`getVisibleRowRange\` the engine detects this and calls \`scrollToRow\` to
96
+ * restore the row before reading — eliminating the hazard without polling loops.
97
+ *
98
+ * All members are optional. Supply whichever the underlying grid exposes:
99
+ * - Range oracles alone enable hazard detection with graceful fallback to navigation primitives.
100
+ * - Scroll primitives alone enable direct jumps without range awareness.
101
+ * - Both together give the most reliable, fastest path.
102
+ *
103
+ * @example
104
+ * // MUI DataGrid via apiRef
105
+ * strategies: {
106
+ * viewport: {
107
+ * getVisibleRowRange: async ({ root }) =>
108
+ * root.evaluate(el => {
109
+ * const api = (el as any).__muiDataGrid__;
110
+ * return { first: api.getFirstVisibleRow(), last: api.getLastVisibleRow() };
111
+ * }),
112
+ * scrollToRow: async ({ root }, rowIndex) =>
113
+ * root.evaluate((el, idx) =>
114
+ * (el as any).__muiDataGrid__.scrollToIndexes({ rowIndex: idx }), rowIndex),
115
+ * scrollToColumn: async ({ root }, colIndex) =>
116
+ * root.evaluate((el, idx) =>
117
+ * (el as any).__muiDataGrid__.scrollToIndexes({ colIndex: idx }), colIndex),
118
+ * }
119
+ * }
120
+ *
121
+ * @example
122
+ * // aria-rowindex / aria-colindex DOM fallback (works without internal API access)
123
+ * strategies: {
124
+ * viewport: {
125
+ * getVisibleRowRange: async ({ root }) =>
126
+ * root.evaluate(el => {
127
+ * const rows = [...el.querySelectorAll('[role="row"][aria-rowindex]')];
128
+ * const idxs = rows.map(r => Number(r.getAttribute('aria-rowindex')) - 1);
129
+ * return { first: Math.min(...idxs), last: Math.max(...idxs) };
130
+ * }),
131
+ * }
132
+ * }
133
+ */
134
+ export interface ViewportStrategy {
135
+ /**
136
+ * Returns the 0-based index range of rows currently rendered in the DOM.
137
+ * Used to detect when a target row has been scrolled out of view and needs recovery.
138
+ */
139
+ getVisibleRowRange?: (context: TableContext) => Promise<{ first: number; last: number }>;
140
+
141
+ /**
142
+ * Returns the 0-based index range of columns currently rendered in the DOM.
143
+ * Used to detect when a target column is not yet mounted before reading.
144
+ */
145
+ getVisibleColumnRange?: (context: TableContext) => Promise<{ first: number; last: number }>;
146
+
147
+ /**
148
+ * Scrolls or jumps directly to make a row visible by 0-based index.
149
+ * Replaces blind goDown()/goUp() step loops for grids that expose a scroll API.
150
+ */
151
+ scrollToRow?: (context: TableContext, rowIndex: number) => Promise<void>;
152
+
153
+ /**
154
+ * Scrolls or jumps directly to make a column visible by 0-based index.
155
+ * Replaces blind goRight()/goLeft() step loops for grids that expose a scroll API.
156
+ */
157
+ scrollToColumn?: (context: TableContext, colIndex: number) => Promise<void>;
158
+
159
+ /**
160
+ * When true, disables the automatic memoization of getVisibleColumnRange and
161
+ * getVisibleRowRange results. By default the library caches each range value and
162
+ * invalidates it after the corresponding scroll call, eliminating redundant DOM
163
+ * evaluate() round-trips between scrolls.
164
+ */
165
+ disableCache?: boolean;
166
+ }
167
+
83
168
 
84
169
  /**
85
170
  * SmartRow - A Playwright Locator with table-aware methods.
@@ -358,6 +443,18 @@ export interface TableStrategies {
358
443
  * E.g. after sort/pagination, the engine uses loading.isTableLoading when present.
359
444
  */
360
445
  loading?: LoadingStrategy;
446
+
447
+ /**
448
+ * Viewport oracle strategies for 2D virtualized tables (e.g. MUI DataGrid, AG Grid,
449
+ * Braintrust-style grids where both rows and columns are virtualized simultaneously).
450
+ *
451
+ * When present, the cell-reading engine uses these to jump directly to the target
452
+ * row/column and to detect the 2D scroll hazard (scrolling to reveal a column can
453
+ * knock rows out of the vertical viewport, and vice versa).
454
+ *
455
+ * Completely optional and additive — existing \`navigation\` primitives remain the fallback.
456
+ */
457
+ viewport?: ViewportStrategy;
361
458
  }
362
459
 
363
460
 
@@ -431,12 +528,6 @@ export type RowIterationMode = 'parallel' | 'sequential' | 'synchronized';
431
528
  export type RowIterationOptions = {
432
529
  /** Maximum number of pages to iterate. Defaults to config.maxPages. */
433
530
  maxPages?: number;
434
- /**
435
- * @deprecated Use 'concurrency' mode instead.
436
- * - parallel: true -> concurrency: 'parallel'
437
- * - parallel: false -> concurrency: 'sequential'
438
- */
439
- parallel?: boolean;
440
531
  /**
441
532
  * Concurrency strategy for iteration.
442
533
  * - 'parallel': Full parallel execution of both navigation and actions.
@@ -545,7 +636,7 @@ export interface TableResult<T = any> extends AsyncIterable<{ row: SmartRow<T>;
545
636
  * Call \`stop()\` in the callback to end iteration early.
546
637
  *
547
638
  * @param callback - Function receiving { row, rowIndex, stop }
548
- * @param options - maxPages, concurrency, dedupe, useBulkPagination (\`parallel\` is deprecated; use \`concurrency\`)
639
+ * @param options - maxPages, concurrency, dedupe, useBulkPagination
549
640
  *
550
641
  * @example
551
642
  * await table.forEach(async ({ row, stop }) => {
@@ -568,7 +659,7 @@ export interface TableResult<T = any> extends AsyncIterable<{ row: SmartRow<T>;
568
659
  * > when navigation must stay lock-step) to avoid overlapping interactions.
569
660
  *
570
661
  * @param callback - Function receiving { row, rowIndex, stop }
571
- * @param options - maxPages, concurrency, dedupe, useBulkPagination (\`parallel\` is deprecated; use \`concurrency\`)
662
+ * @param options - maxPages, concurrency, dedupe, useBulkPagination
572
663
  *
573
664
  * @example
574
665
  * // Data extraction — parallel is safe
@@ -594,7 +685,7 @@ export interface TableResult<T = any> extends AsyncIterable<{ row: SmartRow<T>;
594
685
  * Execution is sequential by default.
595
686
  *
596
687
  * @param predicate - Function receiving { row, rowIndex, stop }
597
- * @param options - maxPages, concurrency, dedupe, useBulkPagination (\`parallel\` is deprecated; use \`concurrency\`)
688
+ * @param options - maxPages, concurrency, dedupe, useBulkPagination
598
689
  *
599
690
  * @example
600
691
  * const active = await table.filter(async ({ row }) =>