@rickcedwhat/playwright-smart-table 6.14.0 ā 6.16.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.
- package/README.md +20 -34
- package/dist/engine/rowFinder.d.ts +4 -2
- package/dist/engine/rowFinder.js +22 -49
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/presets/glide/index.d.ts +1 -0
- package/dist/presets/glide/index.js +9 -2
- package/dist/presets/index.d.ts +1 -1
- package/dist/presets/index.js +2 -1
- package/dist/presets/mui.js +0 -2
- package/dist/presets/rdg.d.ts +18 -1
- package/dist/presets/rdg.js +72 -1
- package/dist/smartRow.js +7 -2
- package/dist/strategies/index.d.ts +1 -0
- package/dist/strategies/pagination.d.ts +1 -0
- package/dist/strategies/pagination.js +1 -0
- package/dist/typeContext.d.ts +1 -1
- package/dist/typeContext.js +6 -1
- package/dist/types.d.ts +2 -1
- package/dist/useTable.js +6 -5
- package/package.json +28 -6
package/README.md
CHANGED
|
@@ -1,52 +1,38 @@
|
|
|
1
1
|
# Playwright Smart Table
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Dealing with tables sucks. Locators are brittle, hard to read, and break the moment a column moves or pagination kicks in.**
|
|
4
|
+
|
|
5
|
+
Playwright Smart Table lets you find rows by column name instead of fragile DOM positions. You describe your table ā it does the rest.
|
|
4
6
|
|
|
5
7
|
[](https://www.npmjs.com/package/@rickcedwhat/playwright-smart-table)
|
|
6
8
|
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://coderabbit.ai)
|
|
8
9
|
|
|
9
10
|
## š [Full Documentation ā](https://rickcedwhat.github.io/playwright-smart-table/)
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
13
|
-
## The Problem
|
|
14
|
-
|
|
15
|
-
Testing HTML tables in Playwright is fragile by default:
|
|
16
|
-
|
|
17
14
|
```typescript
|
|
18
|
-
// ā
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const emailIndex = headers.indexOf('Email');
|
|
24
|
-
const email = await row.locator('td').nth(emailIndex).textContent();
|
|
15
|
+
// ā Before ā breaks if columns reorder
|
|
16
|
+
const row = page.locator('tbody tr')
|
|
17
|
+
.filter({ has: page.locator('td:nth-child(1)', { hasText: 'John' }) })
|
|
18
|
+
.filter({ has: page.locator('td:nth-child(2)', { hasText: 'Doe' }) })
|
|
19
|
+
const email = await row.locator('td:nth-child(3)').innerText()
|
|
25
20
|
```
|
|
26
21
|
|
|
27
|
-
## The Solution
|
|
28
|
-
|
|
29
22
|
```typescript
|
|
30
|
-
// ā
|
|
31
|
-
const row = table.getRow({
|
|
32
|
-
const email = await row.getCell('Email').
|
|
33
|
-
|
|
34
|
-
// ā
Search across pages
|
|
35
|
-
const allEngineers = await table.findRows({ Department: 'Engineering' }, { maxPages: 5 });
|
|
36
|
-
|
|
37
|
-
// ā
Iterate with forEach, map, filter, or for await...of
|
|
38
|
-
await table.forEach(async ({ row }) => {
|
|
39
|
-
await row.getCell('Checkbox').click();
|
|
40
|
-
});
|
|
23
|
+
// ā
After ā column-aware, survives reordering
|
|
24
|
+
const row = table.getRow({ firstName: 'John', lastName: 'Doe' })
|
|
25
|
+
const email = await row.getCell('Email').innerText()
|
|
41
26
|
```
|
|
42
27
|
|
|
28
|
+
---
|
|
29
|
+
|
|
43
30
|
## Installation
|
|
44
31
|
|
|
45
32
|
```bash
|
|
46
33
|
npm install @rickcedwhat/playwright-smart-table
|
|
47
34
|
```
|
|
48
35
|
|
|
49
|
-
|
|
50
36
|
## Quick Start
|
|
51
37
|
|
|
52
38
|
```typescript
|
|
@@ -58,14 +44,13 @@ const row = table.getRow({ Name: 'John Doe' });
|
|
|
58
44
|
const email = await row.getCell('Email').innerText();
|
|
59
45
|
```
|
|
60
46
|
|
|
61
|
-
##
|
|
47
|
+
## Features
|
|
62
48
|
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
- šŖ **Full TypeScript support**
|
|
49
|
+
- [Row access](https://rickcedwhat.github.io/playwright-smart-table/guide/query/) ā find rows by column name, not DOM index
|
|
50
|
+
- [Pagination search](https://rickcedwhat.github.io/playwright-smart-table/guide/query/find-rows) ā `findRow` and `findRows` scan across pages automatically
|
|
51
|
+
- [Iteration](https://rickcedwhat.github.io/playwright-smart-table/guide/query/iterate) ā `forEach`, `map`, `filter`, with early exit via `stop()`
|
|
52
|
+
- [Table config](https://rickcedwhat.github.io/playwright-smart-table/guide/describe/) ā plug in any pagination shape, virtual scroll, or custom header logic
|
|
53
|
+
- [Fill / edit cells](https://rickcedwhat.github.io/playwright-smart-table/guide/query/write) ā write values back into table cells
|
|
69
54
|
|
|
70
55
|
---
|
|
71
56
|
|
|
@@ -73,5 +58,6 @@ const email = await row.getCell('Email').innerText();
|
|
|
73
58
|
- [npm Package](https://www.npmjs.com/package/@rickcedwhat/playwright-smart-table)
|
|
74
59
|
- [GitHub Repository](https://github.com/rickcedwhat/playwright-smart-table)
|
|
75
60
|
- [Issues](https://github.com/rickcedwhat/playwright-smart-table/issues)
|
|
61
|
+
- [Discussions](https://github.com/rickcedwhat/playwright-smart-table/discussions) ā questions and ideas
|
|
76
62
|
|
|
77
63
|
MIT Ā© Cedrick Catalan
|
|
@@ -3,6 +3,7 @@ import { FinalTableConfig, Selector, SmartRow, FilterValue } from '../types';
|
|
|
3
3
|
import { FilterEngine } from '../filterEngine';
|
|
4
4
|
import { TableMapper } from './tableMapper';
|
|
5
5
|
import { SmartRowArray } from '../utils/smartRowArray';
|
|
6
|
+
import { NavigationBarrier } from '../utils/navigationBarrier';
|
|
6
7
|
export declare class RowFinder<T = any> {
|
|
7
8
|
private rootLocator;
|
|
8
9
|
private config;
|
|
@@ -10,10 +11,11 @@ export declare class RowFinder<T = any> {
|
|
|
10
11
|
private tableMapper;
|
|
11
12
|
private makeSmartRow;
|
|
12
13
|
private tableState;
|
|
14
|
+
private advancePage;
|
|
13
15
|
private resolve;
|
|
14
|
-
constructor(rootLocator: Locator, config: FinalTableConfig, resolve: (item: Selector, parent: Locator | Page) => Locator, filterEngine: FilterEngine, tableMapper: TableMapper, makeSmartRow: (loc: Locator, map: Map<string, number>, index: number | undefined, tablePageIndex?: number) => SmartRow<T>, tableState?: {
|
|
16
|
+
constructor(rootLocator: Locator, config: FinalTableConfig, resolve: (item: Selector, parent: Locator | Page) => Locator, filterEngine: FilterEngine, tableMapper: TableMapper, makeSmartRow: (loc: Locator, map: Map<string, number>, index: number | undefined, tablePageIndex?: number, barrier?: NavigationBarrier) => SmartRow<T>, tableState?: {
|
|
15
17
|
currentPageIndex: number;
|
|
16
|
-
});
|
|
18
|
+
}, advancePage?: (useBulk: boolean) => Promise<boolean>);
|
|
17
19
|
findRow(filters: Record<string, FilterValue>, options?: {
|
|
18
20
|
exact?: boolean;
|
|
19
21
|
maxPages?: number;
|
package/dist/engine/rowFinder.js
CHANGED
|
@@ -3,17 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RowFinder = void 0;
|
|
4
4
|
const debugUtils_1 = require("../utils/debugUtils");
|
|
5
5
|
const smartRowArray_1 = require("../utils/smartRowArray");
|
|
6
|
-
const validation_1 = require("../strategies/validation");
|
|
7
6
|
const elementTracker_1 = require("../utils/elementTracker");
|
|
8
7
|
const sentinel_1 = require("../utils/sentinel");
|
|
8
|
+
const navigationBarrier_1 = require("../utils/navigationBarrier");
|
|
9
9
|
class RowFinder {
|
|
10
|
-
constructor(rootLocator, config, resolve, filterEngine, tableMapper, makeSmartRow, tableState = { currentPageIndex: 0 }) {
|
|
10
|
+
constructor(rootLocator, config, resolve, filterEngine, tableMapper, makeSmartRow, tableState = { currentPageIndex: 0 }, advancePage = async () => false) {
|
|
11
11
|
this.rootLocator = rootLocator;
|
|
12
12
|
this.config = config;
|
|
13
13
|
this.filterEngine = filterEngine;
|
|
14
14
|
this.tableMapper = tableMapper;
|
|
15
15
|
this.makeSmartRow = makeSmartRow;
|
|
16
16
|
this.tableState = tableState;
|
|
17
|
+
this.advancePage = advancePage;
|
|
17
18
|
this.resolve = resolve;
|
|
18
19
|
}
|
|
19
20
|
async findRow(filters, options = {}) {
|
|
@@ -31,12 +32,12 @@ class RowFinder {
|
|
|
31
32
|
await (0, debugUtils_1.debugDelay)(this.config, 'findRow');
|
|
32
33
|
const sentinel = this.resolve(this.config.rowSelector, this.rootLocator)
|
|
33
34
|
.filter({ hasText: "___SENTINEL_ROW_NOT_FOUND___" + Date.now() });
|
|
34
|
-
const smartRow = this.makeSmartRow(sentinel, await this.tableMapper.getMap(),
|
|
35
|
+
const smartRow = this.makeSmartRow(sentinel, await this.tableMapper.getMap(), undefined);
|
|
35
36
|
smartRow[sentinel_1.SENTINEL_ROW] = true;
|
|
36
37
|
return smartRow;
|
|
37
38
|
}
|
|
38
39
|
async findRows(filters = {}, options) {
|
|
39
|
-
var _a, _b, _c
|
|
40
|
+
var _a, _b, _c;
|
|
40
41
|
const filtersRecord = filters;
|
|
41
42
|
const map = await this.tableMapper.getMap();
|
|
42
43
|
const allRows = [];
|
|
@@ -64,12 +65,16 @@ class RowFinder {
|
|
|
64
65
|
: undefined;
|
|
65
66
|
const onRowLoadingTimeout = (_e = (_d = this.config.strategies.loading) === null || _d === void 0 ? void 0 : _d.onRowLoadingTimeout) !== null && _e !== void 0 ? _e : 'read-as-is';
|
|
66
67
|
let added = 0;
|
|
68
|
+
// One barrier per batch ā synchronizes cell navigation across all rows in this page's results
|
|
69
|
+
const useBarrier = this.config.concurrency === 'synchronized' && newIndices.length > 1;
|
|
70
|
+
const barrier = useBarrier ? new navigationBarrier_1.NavigationBarrier(newIndices.length) : undefined;
|
|
67
71
|
for (const idx of newIndices) {
|
|
68
|
-
const smartRow = this.makeSmartRow(currentRows[idx], map, allRows.length, this.tableState.currentPageIndex);
|
|
72
|
+
const smartRow = this.makeSmartRow(currentRows[idx], map, allRows.length, this.tableState.currentPageIndex, barrier);
|
|
69
73
|
if (isRowLoading && await isRowLoading(smartRow)) {
|
|
70
74
|
if (rowLoadingTimeout === undefined) {
|
|
71
75
|
// No timeout configured (or invalid value) ā legacy skip behavior
|
|
72
76
|
(0, debugUtils_1.logDebug)(this.config, 'verbose', `findRows: page ${this.tableState.currentPageIndex} ā row skipped (isRowLoading=true, no timeout)`);
|
|
77
|
+
barrier === null || barrier === void 0 ? void 0 : barrier.markFinished();
|
|
73
78
|
continue;
|
|
74
79
|
}
|
|
75
80
|
// Wait up to rowLoadingTimeout ms (0 = one immediate re-check, no polling)
|
|
@@ -82,9 +87,12 @@ class RowFinder {
|
|
|
82
87
|
}
|
|
83
88
|
if (!resolved) {
|
|
84
89
|
(0, debugUtils_1.logDebug)(this.config, 'verbose', `findRows: row ${allRows.length} ā still loading after ${rowLoadingTimeout}ms, action: ${onRowLoadingTimeout}`);
|
|
85
|
-
if (onRowLoadingTimeout === 'skip')
|
|
90
|
+
if (onRowLoadingTimeout === 'skip') {
|
|
91
|
+
barrier === null || barrier === void 0 ? void 0 : barrier.markFinished();
|
|
86
92
|
continue;
|
|
93
|
+
}
|
|
87
94
|
if (onRowLoadingTimeout === 'throw') {
|
|
95
|
+
barrier === null || barrier === void 0 ? void 0 : barrier.markFinished();
|
|
88
96
|
throw new Error(`[SmartTable] Row ${allRows.length} did not finish loading within ${rowLoadingTimeout}ms`);
|
|
89
97
|
}
|
|
90
98
|
// 'read-as-is': fall through and add the row
|
|
@@ -102,31 +110,14 @@ class RowFinder {
|
|
|
102
110
|
await collectMatches();
|
|
103
111
|
// Pagination Loop
|
|
104
112
|
while (pagesScanned < effectiveMaxPages && this.config.strategies.pagination) {
|
|
105
|
-
const context = {
|
|
106
|
-
root: this.rootLocator,
|
|
107
|
-
config: this.config,
|
|
108
|
-
resolve: this.resolve,
|
|
109
|
-
page: this.rootLocator.page()
|
|
110
|
-
};
|
|
111
|
-
let paginationResult;
|
|
112
113
|
const useBulk = (options === null || options === void 0 ? void 0 : options.useBulkPagination) !== false && !!((_c = this.config.strategies.pagination) === null || _c === void 0 ? void 0 : _c.goNextBulk);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
else if ((_d = this.config.strategies.pagination) === null || _d === void 0 ? void 0 : _d.goNext) {
|
|
117
|
-
paginationResult = await this.config.strategies.pagination.goNext(context);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
(0, debugUtils_1.logDebug)(this.config, 'verbose', `findRows: no pagination primitive ā stopping`);
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
const didPaginate = (0, validation_1.validatePaginationResult)(paginationResult, 'Pagination Strategy');
|
|
114
|
+
const prevPage = this.tableState.currentPageIndex;
|
|
115
|
+
const didPaginate = await this.advancePage(useBulk);
|
|
124
116
|
if (!didPaginate) {
|
|
125
117
|
(0, debugUtils_1.logDebug)(this.config, 'verbose', `findRows: pagination returned false ā end of data`);
|
|
126
118
|
break;
|
|
127
119
|
}
|
|
128
|
-
const pagesJumped =
|
|
129
|
-
this.tableState.currentPageIndex += pagesJumped;
|
|
120
|
+
const pagesJumped = this.tableState.currentPageIndex - prevPage;
|
|
130
121
|
pagesScanned += pagesJumped;
|
|
131
122
|
(0, debugUtils_1.logDebug)(this.config, 'verbose', `findRows: advanced ${pagesJumped} page(s), now at page ${this.tableState.currentPageIndex}`);
|
|
132
123
|
await (0, debugUtils_1.debugDelay)(this.config, 'pagination');
|
|
@@ -140,7 +131,7 @@ class RowFinder {
|
|
|
140
131
|
return (0, smartRowArray_1.createSmartRowArray)(allRows);
|
|
141
132
|
}
|
|
142
133
|
async findRowLocator(filters, options = {}) {
|
|
143
|
-
var _a, _b;
|
|
134
|
+
var _a, _b, _c;
|
|
144
135
|
const map = await this.tableMapper.getMap();
|
|
145
136
|
const effectiveMaxPages = (_a = options.maxPages) !== null && _a !== void 0 ? _a : this.config.maxPages;
|
|
146
137
|
let pagesScanned = 1;
|
|
@@ -183,29 +174,11 @@ class RowFinder {
|
|
|
183
174
|
return matchedRows.first();
|
|
184
175
|
if (pagesScanned < effectiveMaxPages) {
|
|
185
176
|
(0, debugUtils_1.logDebug)(this.config, 'verbose', `Page ${this.tableState.currentPageIndex}: Not found. Attempting pagination...`);
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
resolve: this.resolve,
|
|
190
|
-
page: this.rootLocator.page()
|
|
191
|
-
};
|
|
192
|
-
let paginationResult;
|
|
193
|
-
const pagination = this.config.strategies.pagination;
|
|
194
|
-
const useBulk = options.useBulkPagination !== false && !!(pagination === null || pagination === void 0 ? void 0 : pagination.goNextBulk);
|
|
195
|
-
if (useBulk && (pagination === null || pagination === void 0 ? void 0 : pagination.goNextBulk)) {
|
|
196
|
-
paginationResult = await pagination.goNextBulk(context);
|
|
197
|
-
}
|
|
198
|
-
else if (pagination === null || pagination === void 0 ? void 0 : pagination.goNext) {
|
|
199
|
-
paginationResult = await pagination.goNext(context);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
(0, debugUtils_1.logDebug)(this.config, 'verbose', `Page ${this.tableState.currentPageIndex}: Pagination failed (no goNext or goNextBulk primitive).`);
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
const didLoadMore = (0, validation_1.validatePaginationResult)(paginationResult, 'Pagination Strategy');
|
|
177
|
+
const useBulk = options.useBulkPagination !== false && !!((_c = this.config.strategies.pagination) === null || _c === void 0 ? void 0 : _c.goNextBulk);
|
|
178
|
+
const prevPage = this.tableState.currentPageIndex;
|
|
179
|
+
const didLoadMore = await this.advancePage(useBulk);
|
|
206
180
|
if (didLoadMore) {
|
|
207
|
-
const pagesJumped =
|
|
208
|
-
this.tableState.currentPageIndex += pagesJumped;
|
|
181
|
+
const pagesJumped = this.tableState.currentPageIndex - prevPage;
|
|
209
182
|
pagesScanned += pagesJumped;
|
|
210
183
|
(0, debugUtils_1.logDebug)(this.config, 'verbose', `findRowLocator: advanced ${pagesJumped} page(s), now at page ${this.tableState.currentPageIndex}`);
|
|
211
184
|
await (0, debugUtils_1.debugDelay)(this.config, 'pagination');
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Generated by scripts/embed-version.mjs from package.json
|
|
4
4
|
*/
|
|
5
5
|
/** Semver of this package. Use in logs or diagnostics to confirm the installed build. */
|
|
6
|
-
export declare const PLAYWRIGHT_SMART_TABLE_VERSION: "6.
|
|
6
|
+
export declare const PLAYWRIGHT_SMART_TABLE_VERSION: "6.16.0";
|
package/dist/packageVersion.js
CHANGED
|
@@ -6,4 +6,4 @@ exports.PLAYWRIGHT_SMART_TABLE_VERSION = void 0;
|
|
|
6
6
|
* Generated by scripts/embed-version.mjs from package.json
|
|
7
7
|
*/
|
|
8
8
|
/** Semver of this package. Use in logs or diagnostics to confirm the installed build. */
|
|
9
|
-
exports.PLAYWRIGHT_SMART_TABLE_VERSION = "6.
|
|
9
|
+
exports.PLAYWRIGHT_SMART_TABLE_VERSION = "6.16.0";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Glide = exports.GlideStrategies = exports.createGlideViewport = void 0;
|
|
3
|
+
exports.glide = exports.Glide = exports.GlideStrategies = exports.createGlideViewport = void 0;
|
|
4
4
|
exports.createGlide = createGlide;
|
|
5
5
|
const headers_1 = require("./headers");
|
|
6
6
|
const pagination_1 = require("../../strategies/pagination");
|
|
@@ -75,9 +75,15 @@ const glideGetActiveCell = async ({ page }) => {
|
|
|
75
75
|
let rowIndex = -1;
|
|
76
76
|
let columnIndex = -1;
|
|
77
77
|
if (parts.length >= 4 && parts[0] === 'glide' && parts[1] === 'cell') {
|
|
78
|
-
columnIndex = parseInt(parts[2]) -
|
|
78
|
+
columnIndex = parseInt(parts[2]); // 0-based in Glide's id format: glide-cell-{col}-{row}
|
|
79
79
|
rowIndex = parseInt(parts[3]);
|
|
80
80
|
}
|
|
81
|
+
else if (id !== '') {
|
|
82
|
+
throw new Error(`Glide preset: focused element has id "${id}" which does not match the expected format "glide-cell-{colIndex}-{rowIndex}". ` +
|
|
83
|
+
`Glide may have changed its internal id format. Please open an issue at https://github.com/rickcedwhat/playwright-smart-table/issues.`);
|
|
84
|
+
}
|
|
85
|
+
if (rowIndex === -1 || columnIndex === -1)
|
|
86
|
+
return null;
|
|
81
87
|
return {
|
|
82
88
|
rowIndex,
|
|
83
89
|
columnIndex,
|
|
@@ -129,3 +135,4 @@ const GlidePreset = {
|
|
|
129
135
|
strategies: GlideDefaultStrategies
|
|
130
136
|
};
|
|
131
137
|
exports.Glide = Object.defineProperty(GlidePreset, 'Strategies', { get: () => exports.GlideStrategies, enumerable: false });
|
|
138
|
+
exports.glide = exports.Glide;
|
package/dist/presets/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { muiTable, muiDataGrid } from './mui';
|
|
2
|
-
export { RDG as rdg } from './rdg';
|
|
2
|
+
export { RDG as rdg, RDG2D as rdg2D } from './rdg';
|
|
3
3
|
export { Glide as glide, createGlide, createGlideViewport } from './glide';
|
|
4
4
|
export type { GlideOptions, GlideViewportOptions } from './glide';
|
package/dist/presets/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGlideViewport = exports.createGlide = exports.glide = exports.rdg = exports.muiDataGrid = exports.muiTable = void 0;
|
|
3
|
+
exports.createGlideViewport = exports.createGlide = exports.glide = exports.rdg2D = exports.rdg = exports.muiDataGrid = exports.muiTable = void 0;
|
|
4
4
|
var mui_1 = require("./mui");
|
|
5
5
|
Object.defineProperty(exports, "muiTable", { enumerable: true, get: function () { return mui_1.muiTable; } });
|
|
6
6
|
Object.defineProperty(exports, "muiDataGrid", { enumerable: true, get: function () { return mui_1.muiDataGrid; } });
|
|
7
7
|
var rdg_1 = require("./rdg");
|
|
8
8
|
Object.defineProperty(exports, "rdg", { enumerable: true, get: function () { return rdg_1.RDG; } });
|
|
9
|
+
Object.defineProperty(exports, "rdg2D", { enumerable: true, get: function () { return rdg_1.RDG2D; } });
|
|
9
10
|
var glide_1 = require("./glide");
|
|
10
11
|
Object.defineProperty(exports, "glide", { enumerable: true, get: function () { return glide_1.Glide; } });
|
|
11
12
|
Object.defineProperty(exports, "createGlide", { enumerable: true, get: function () { return glide_1.createGlide; } });
|
package/dist/presets/mui.js
CHANGED
|
@@ -237,8 +237,6 @@ exports.muiDataGrid = {
|
|
|
237
237
|
else {
|
|
238
238
|
await header.click({ force: true });
|
|
239
239
|
}
|
|
240
|
-
// Sorting can trigger large re-renders/virtualization shifts
|
|
241
|
-
await context.page.waitForTimeout(500);
|
|
242
240
|
// Wait for stabilization (using DataGrid specific overlay check inside helper)
|
|
243
241
|
const displayedRows = context.root.locator('.MuiTablePagination-displayedRows');
|
|
244
242
|
const text = await displayedRows.innerText().catch(() => '');
|
package/dist/presets/rdg.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TableContext, TableConfig } from '../types';
|
|
1
|
+
import { TableContext, TableConfig, ViewportStrategy } from '../types';
|
|
2
2
|
/** Full strategies for React Data Grid. Use when you want to supply your own selectors: strategies: Plugins.RDG.Strategies */
|
|
3
3
|
export declare const RDGStrategies: {
|
|
4
4
|
header: (context: TableContext) => Promise<string[]>;
|
|
@@ -15,3 +15,20 @@ export declare const RDGStrategies: {
|
|
|
15
15
|
export declare const RDG: Partial<TableConfig> & {
|
|
16
16
|
Strategies: typeof RDGStrategies;
|
|
17
17
|
};
|
|
18
|
+
export declare const RDG2DStrategies: {
|
|
19
|
+
viewport: ViewportStrategy;
|
|
20
|
+
header: (context: TableContext) => Promise<string[]>;
|
|
21
|
+
getCellLocator: ({ row, columnIndex }: any) => any;
|
|
22
|
+
navigation: {
|
|
23
|
+
goRight: ({ root, page }: any) => Promise<void>;
|
|
24
|
+
goLeft: ({ root, page }: any) => Promise<void>;
|
|
25
|
+
goDown: ({ root, page }: any) => Promise<void>;
|
|
26
|
+
goUp: ({ root, page }: any) => Promise<void>;
|
|
27
|
+
goHome: ({ root, page }: any) => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
pagination: import("..").PaginationPrimitives;
|
|
30
|
+
};
|
|
31
|
+
export declare const RDG2D: Partial<TableConfig> & {
|
|
32
|
+
Strategies: typeof RDG2DStrategies;
|
|
33
|
+
};
|
|
34
|
+
export { RDG as rdg, RDG2D as rdg2D };
|
package/dist/presets/rdg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RDG = exports.RDGStrategies = void 0;
|
|
3
|
+
exports.rdg2D = exports.rdg = exports.RDG2D = exports.RDG2DStrategies = exports.RDG = exports.RDGStrategies = void 0;
|
|
4
4
|
const pagination_1 = require("../strategies/pagination");
|
|
5
5
|
const stabilization_1 = require("../strategies/stabilization");
|
|
6
6
|
/**
|
|
@@ -114,3 +114,74 @@ const RDGPreset = {
|
|
|
114
114
|
strategies: RDGDefaultStrategies
|
|
115
115
|
};
|
|
116
116
|
exports.RDG = Object.defineProperty(RDGPreset, 'Strategies', { get: () => exports.RDGStrategies, enumerable: false });
|
|
117
|
+
exports.rdg = exports.RDG;
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// rdg2D ā React Data Grid with both rows AND columns virtualized
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
const rdg2DViewportStrategy = {
|
|
122
|
+
getVisibleRowRange: async ({ root }) => {
|
|
123
|
+
return root.evaluate((el) => {
|
|
124
|
+
const rows = [...el.querySelectorAll('[role="row"][aria-rowindex]')];
|
|
125
|
+
const indices = rows.map(r => parseInt(r.getAttribute('aria-rowindex') || '0', 10) - 1);
|
|
126
|
+
if (!indices.length)
|
|
127
|
+
return { first: 0, last: 0 };
|
|
128
|
+
return { first: Math.min(...indices), last: Math.max(...indices) };
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
getVisibleColumnRange: async ({ root }) => {
|
|
132
|
+
return root.evaluate((el) => {
|
|
133
|
+
const cells = [...el.querySelectorAll('[role="gridcell"][aria-colindex]')];
|
|
134
|
+
const indices = cells.map(c => parseInt(c.getAttribute('aria-colindex') || '0', 10) - 1);
|
|
135
|
+
if (!indices.length)
|
|
136
|
+
return { first: 0, last: 0 };
|
|
137
|
+
return { first: Math.min(...indices), last: Math.max(...indices) };
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
scrollToRow: async ({ root }, rowIndex) => {
|
|
141
|
+
await root.evaluate((el, rowIndex) => {
|
|
142
|
+
const grid = (el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el);
|
|
143
|
+
// Try to locate the target row by aria-rowindex (1-based in RDG)
|
|
144
|
+
const ariaIndex = rowIndex + 1;
|
|
145
|
+
const targetRow = el.querySelector(`[role="row"][aria-rowindex="${ariaIndex}"]`);
|
|
146
|
+
if (targetRow) {
|
|
147
|
+
const top = parseInt(targetRow.style.top || '0', 10);
|
|
148
|
+
grid.scrollTop = Math.max(0, top - grid.clientHeight / 3);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Row not in DOM ā estimate position from an actual visible row's height
|
|
152
|
+
const anyRow = el.querySelector('[role="row"][aria-rowindex]');
|
|
153
|
+
const rowHeight = anyRow ? anyRow.getBoundingClientRect().height || 35 : 35;
|
|
154
|
+
grid.scrollTop = Math.max(0, rowIndex * rowHeight - grid.clientHeight / 3);
|
|
155
|
+
}, rowIndex);
|
|
156
|
+
},
|
|
157
|
+
scrollToColumn: async ({ root }, columnIndex) => {
|
|
158
|
+
await root.evaluate((el, columnIndex) => {
|
|
159
|
+
const grid = (el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el);
|
|
160
|
+
// Try to locate the header cell by aria-colindex (1-based in RDG)
|
|
161
|
+
const ariaIndex = columnIndex + 1;
|
|
162
|
+
const header = el.querySelector(`[role="columnheader"][aria-colindex="${ariaIndex}"]`);
|
|
163
|
+
if (header) {
|
|
164
|
+
grid.scrollLeft = header.offsetLeft;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
// Column not visible ā estimate from average width of visible headers
|
|
168
|
+
const headers = [...el.querySelectorAll('[role="columnheader"][aria-colindex]')];
|
|
169
|
+
if (headers.length > 0) {
|
|
170
|
+
const avgWidth = headers.reduce((sum, h) => sum + h.offsetWidth, 0) / headers.length;
|
|
171
|
+
grid.scrollLeft = Math.max(0, columnIndex * avgWidth);
|
|
172
|
+
}
|
|
173
|
+
}, columnIndex);
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
/** Default strategies for the RDG2D preset (extends RDG with viewport recovery). */
|
|
177
|
+
const RDG2DDefaultStrategies = Object.assign(Object.assign({}, RDGDefaultStrategies), { viewport: rdg2DViewportStrategy });
|
|
178
|
+
// fallow-ignore-next-line unused-export
|
|
179
|
+
exports.RDG2DStrategies = RDG2DDefaultStrategies;
|
|
180
|
+
/**
|
|
181
|
+
* Full preset for React Data Grid with 2D virtualization (rows + columns both virtualized).
|
|
182
|
+
* Use instead of `rdg` when horizontal scrolling causes "could not reach cell" errors.
|
|
183
|
+
* The viewport strategy detects when a row is evicted by a horizontal scroll and restores it.
|
|
184
|
+
*/
|
|
185
|
+
const RDG2DPreset = Object.assign(Object.assign({}, RDGPreset), { strategies: RDG2DDefaultStrategies });
|
|
186
|
+
exports.RDG2D = Object.defineProperty(RDG2DPreset, 'Strategies', { get: () => exports.RDG2DStrategies, enumerable: false });
|
|
187
|
+
exports.rdg2D = exports.RDG2D;
|
package/dist/smartRow.js
CHANGED
|
@@ -304,7 +304,8 @@ const _navigateToCell = async (params) => {
|
|
|
304
304
|
else {
|
|
305
305
|
navResult = await navigateUntilReached();
|
|
306
306
|
}
|
|
307
|
-
|
|
307
|
+
// navigateUntilReached may return a Locator it found mid-navigation; duck-type check via .count() (public API) rather than the internal _isLocator flag
|
|
308
|
+
if (navResult && typeof navResult.count === 'function') {
|
|
308
309
|
const loc = navResult;
|
|
309
310
|
if (await loc.count() > 0)
|
|
310
311
|
return loc;
|
|
@@ -488,7 +489,11 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
488
489
|
cellResolved = !(await isCellLoading(targetCell, col, smart));
|
|
489
490
|
}
|
|
490
491
|
if (!cellResolved) {
|
|
491
|
-
(0, debugUtils_1.logDebug)(config, 'verbose', `toJSON: cell "${col}" ā still loading after ${cellLoadingTimeout}ms, action: ${onCellLoadingTimeout}`);
|
|
492
|
+
(0, debugUtils_1.logDebug)(config, 'verbose', `toJSON: cell "${col}" ā still loading after ${cellLoadingTimeout}ms, action: ${typeof onCellLoadingTimeout === 'function' ? 'callback' : onCellLoadingTimeout}`);
|
|
493
|
+
if (typeof onCellLoadingTimeout === 'function') {
|
|
494
|
+
result[col] = await onCellLoadingTimeout(targetCell, col, smart);
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
492
497
|
if (onCellLoadingTimeout === 'skip') {
|
|
493
498
|
result[col] = '';
|
|
494
499
|
continue;
|
|
@@ -23,6 +23,7 @@ export declare const Strategies: {
|
|
|
23
23
|
nextBulkPages?: number;
|
|
24
24
|
previousBulkPages?: number;
|
|
25
25
|
numberOfPages?: number | ((root: import("@playwright/test").Locator) => number | Promise<number>);
|
|
26
|
+
detectCurrentPage?: (root: import("@playwright/test").Locator) => number | Promise<number>;
|
|
26
27
|
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
27
28
|
timeout?: number;
|
|
28
29
|
}) => import("../types").PaginationStrategy;
|
|
@@ -20,6 +20,7 @@ export declare const PaginationStrategies: {
|
|
|
20
20
|
nextBulkPages?: number;
|
|
21
21
|
previousBulkPages?: number;
|
|
22
22
|
numberOfPages?: number | ((root: import("@playwright/test").Locator) => number | Promise<number>);
|
|
23
|
+
detectCurrentPage?: (root: import("@playwright/test").Locator) => number | Promise<number>;
|
|
23
24
|
stabilization?: StabilizationStrategy;
|
|
24
25
|
timeout?: number;
|
|
25
26
|
}) => PaginationStrategy;
|
package/dist/typeContext.d.ts
CHANGED
|
@@ -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 * headerSelector: (root) => root.locator('[role=\"columnheader\"]')\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 *\n * Use this to scroll off-screen columns into view in **horizontally** virtualized tables,\n * wait for lazy-rendered content (popovers, tooltips, async cell renderers), or perform\n * any other pre-read setup that doesn't involve Y-axis scrolling.\n *\n * ---\n *\n * **\u26A0\uFE0F Y-scroll footgun \u2014 do NOT call `scrollIntoViewIfNeeded()` on row-virtualized grids.**\n *\n * `scrollIntoViewIfNeeded` adjusts *both* scroll axes. On grids that recycle DOM nodes\n * based on the Y position (MUI DataGrid, AG Grid, react-window, etc.) calling it will\n * shift the viewport vertically, unmounting the row you are currently reading and\n * silently returning stale or empty cell values for the remainder of the row.\n *\n * Safe uses:\n * - Column-only (X-axis) virtualization where rows are always in the DOM.\n * - Calling `scrollIntoViewIfNeeded` on the **header cell** only, when that header is\n * guaranteed not to trigger a Y-scroll (e.g. sticky header grids).\n *\n * For grids with **both** row and column virtualization, use the `viewport` strategy\n * instead \u2014 it drives explicit `scrollToRow` / `scrollToColumn` calls and is aware of\n * the virtualization lifecycle.\n *\n * @example\n * // Safe: column-only horizontal virtualization (rows always in DOM)\n * strategies: {\n * beforeCellRead: async ({ columnName, getHeaderCell }) => {\n * const header = await getHeaderCell(columnName);\n * await header.scrollIntoViewIfNeeded(); // only scrolls X \u2014 rows stay mounted\n * }\n * }\n *\n * @example\n * // Safe: wait for a lazy-rendered popover/tooltip before reading its text\n * strategies: {\n * beforeCellRead: async ({ cell }) => {\n * await cell.hover();\n * await cell.page().waitForSelector('.cell-tooltip', { state: 'visible' });\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 * SmartCell - A Playwright Locator with table-aware methods for single-cell operations.\n * \n * Extends all standard Locator methods (click, isVisible, etc.).\n */\nexport type SmartCell = Locator & {\n /**\n * Scrolls/paginates to bring this specific cell into view using the configured strategies.\n * Useful when the grid is horizontally virtualized and the column must be scrolled\n * into view before it can be interacted with or read.\n */\n bringIntoView(): Promise<void>;\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 SmartCell (Locator + bringIntoView)\n * @example\n * const emailCell = row.getCell('Email');\n * await emailCell.bringIntoView();\n * await expect(emailCell).toHaveText('john@example.com');\n */\n getCell(column: string): SmartCell;\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 * Works when row position metadata is known (e.g., from getRowByIndex, findRow,\n * findRows, filter, or async iteration).\n * @throws Error if row position metadata 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 /** Jump to last page / scroll to bottom */\n goToLast?: (context: TableContext) => Promise<boolean>;\n\n /**\n * Fetch the total number of pages currently available.\n * Can be used to optimize pagination paths (e.g. jumping to last page and going backwards).\n */\n getTotalPages?: (context: TableContext) => Promise<number | null>;\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 /**\n * Called once during init() to sync the library's page counter with the actual DOM state.\n * Use when a table may open on a page other than the first (e.g. a deep-linked URL that\n * lands on page 5). Returns a 0-indexed page number.\n * @example\n * detectCurrentPage: async (root) => {\n * const text = await root.locator('[aria-current=\"page\"]').textContent();\n * return parseInt(text ?? '1') - 1;\n * }\n */\n detectCurrentPage?: (root: import('@playwright/test').Locator) => number | Promise<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 */\n// fallow-ignore-next-line unused-type\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 * How long (ms) to wait for a loading row to resolve before applying onRowLoadingTimeout.\n * When not set, loading rows are immediately skipped (backward-compatible behavior).\n */\n rowLoadingTimeout?: number;\n\n /**\n * What to do when a row is still loading after rowLoadingTimeout ms.\n * - 'skip': drop the row from results (matches legacy skip behavior)\n * - 'read-as-is': include the row even though it's still loading (default)\n * - 'throw': throw an error with row index and timeout info\n * Defaults to 'read-as-is' when rowLoadingTimeout is set.\n */\n onRowLoadingTimeout?: 'skip' | 'read-as-is' | 'throw';\n\n /**\n * Predicate called before reading each cell. Return true if the cell is still loading.\n * When cellLoadingTimeout is also set, the engine waits up to that many ms for the\n * cell to resolve before applying onCellLoadingTimeout.\n */\n isCellLoading?: (cell: import('@playwright/test').Locator, columnName: string, row: SmartRow) => Promise<boolean>;\n\n /**\n * How long (ms) to wait for a loading cell to resolve before applying onCellLoadingTimeout.\n * When not set and isCellLoading returns true, the cell is read as-is immediately.\n */\n cellLoadingTimeout?: number;\n\n /**\n * What to do when a cell is still loading after cellLoadingTimeout ms.\n * - 'skip': use empty string for this cell value\n * - 'read-as-is': read the cell content even though it's still loading (default)\n * - 'throw': throw an error with column name, row index and timeout info\n * Defaults to 'read-as-is' when cellLoadingTimeout is set.\n */\n onCellLoadingTimeout?: 'skip' | 'read-as-is' | 'throw';\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 /** 0-based iteration counter \u2014 the order this row was visited, not its DOM position or grid identity. @deprecated Use `index` instead. `rowIndex` will be removed in v7.0.0. */\n rowIndex: number;\n /** 0-based iteration counter \u2014 the order this row was visited, not its DOM position or grid identity. */\n index: number;\n /** 0-based page index \u2014 which page this row was collected from. */\n pageIndex: 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; index: number; pageIndex: 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<T>>;\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<T>;\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<T>;\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<T>>;\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, useBulkPagination?: boolean }\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 * Counts the number of rows currently on the page.\n * Does not paginate.\n */\n countRows: () => Promise<number>;\n\n /**\n * Iterates over rows and extracts the value of a single column.\n * More efficient than map + toJSON for single-column extraction.\n * @param columnName - The name of the column to extract\n * @param options - Iteration options\n */\n mapColumn<R = string>(columnName: string, options?: RowIterationOptions): Promise<R[]>;\n\n /**\n * Iterates over rows and extracts the value of a single column as strings.\n * @param columnName - The name of the column to extract\n * @param options - Iteration options\n */\n getColumnValues(columnName: string, options?: RowIterationOptions): Promise<string[]>;\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";
|
|
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 * headerSelector: (root) => root.locator('[role=\"columnheader\"]')\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 *\n * Use this to scroll off-screen columns into view in **horizontally** virtualized tables,\n * wait for lazy-rendered content (popovers, tooltips, async cell renderers), or perform\n * any other pre-read setup that doesn't involve Y-axis scrolling.\n *\n * ---\n *\n * **\u26A0\uFE0F Y-scroll footgun \u2014 do NOT call `scrollIntoViewIfNeeded()` on row-virtualized grids.**\n *\n * `scrollIntoViewIfNeeded` adjusts *both* scroll axes. On grids that recycle DOM nodes\n * based on the Y position (MUI DataGrid, AG Grid, react-window, etc.) calling it will\n * shift the viewport vertically, unmounting the row you are currently reading and\n * silently returning stale or empty cell values for the remainder of the row.\n *\n * Safe uses:\n * - Column-only (X-axis) virtualization where rows are always in the DOM.\n * - Calling `scrollIntoViewIfNeeded` on the **header cell** only, when that header is\n * guaranteed not to trigger a Y-scroll (e.g. sticky header grids).\n *\n * For grids with **both** row and column virtualization, use the `viewport` strategy\n * instead \u2014 it drives explicit `scrollToRow` / `scrollToColumn` calls and is aware of\n * the virtualization lifecycle.\n *\n * @example\n * // Safe: column-only horizontal virtualization (rows always in DOM)\n * strategies: {\n * beforeCellRead: async ({ columnName, getHeaderCell }) => {\n * const header = await getHeaderCell(columnName);\n * await header.scrollIntoViewIfNeeded(); // only scrolls X \u2014 rows stay mounted\n * }\n * }\n *\n * @example\n * // Safe: wait for a lazy-rendered popover/tooltip before reading its text\n * strategies: {\n * beforeCellRead: async ({ cell }) => {\n * await cell.hover();\n * await cell.page().waitForSelector('.cell-tooltip', { state: 'visible' });\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 * SmartCell - A Playwright Locator with table-aware methods for single-cell operations.\n * \n * Extends all standard Locator methods (click, isVisible, etc.).\n */\nexport type SmartCell = Locator & {\n /**\n * Scrolls/paginates to bring this specific cell into view using the configured strategies.\n * Useful when the grid is horizontally virtualized and the column must be scrolled\n * into view before it can be interacted with or read.\n */\n bringIntoView(): Promise<void>;\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 SmartCell (Locator + bringIntoView)\n * @example\n * const emailCell = row.getCell('Email');\n * await emailCell.bringIntoView();\n * await expect(emailCell).toHaveText('john@example.com');\n */\n getCell(column: string): SmartCell;\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 * Works when row position metadata is known (e.g., from getRowByIndex, findRow,\n * findRows, filter, or async iteration).\n * @throws Error if row position metadata 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 /** Jump to last page / scroll to bottom */\n goToLast?: (context: TableContext) => Promise<boolean>;\n\n /**\n * Fetch the total number of pages currently available.\n * Can be used to optimize pagination paths (e.g. jumping to last page and going backwards).\n */\n getTotalPages?: (context: TableContext) => Promise<number | null>;\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 /**\n * Called once during init() to sync the library's page counter with the actual DOM state.\n * Use when a table may open on a page other than the first (e.g. a deep-linked URL that\n * lands on page 5). Returns a 0-indexed page number.\n * @example\n * detectCurrentPage: async (root) => {\n * const text = await root.locator('[aria-current=\"page\"]').textContent();\n * return parseInt(text ?? '1') - 1;\n * }\n */\n detectCurrentPage?: (root: import('@playwright/test').Locator) => number | Promise<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 */\n// fallow-ignore-next-line unused-type\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 * How long (ms) to wait for a loading row to resolve before applying onRowLoadingTimeout.\n * When not set, loading rows are immediately skipped (backward-compatible behavior).\n */\n rowLoadingTimeout?: number;\n\n /**\n * What to do when a row is still loading after rowLoadingTimeout ms.\n * - 'skip': drop the row from results (matches legacy skip behavior)\n * - 'read-as-is': include the row even though it's still loading (default)\n * - 'throw': throw an error with row index and timeout info\n * Defaults to 'read-as-is' when rowLoadingTimeout is set.\n */\n onRowLoadingTimeout?: 'skip' | 'read-as-is' | 'throw';\n\n /**\n * Predicate called before reading each cell. Return true if the cell is still loading.\n * When cellLoadingTimeout is also set, the engine waits up to that many ms for the\n * cell to resolve before applying onCellLoadingTimeout.\n */\n isCellLoading?: (cell: import('@playwright/test').Locator, columnName: string, row: SmartRow) => Promise<boolean>;\n\n /**\n * How long (ms) to wait for a loading cell to resolve before applying onCellLoadingTimeout.\n * When not set and isCellLoading returns true, the cell is read as-is immediately.\n */\n cellLoadingTimeout?: number;\n\n /**\n * What to do when a cell is still loading after cellLoadingTimeout ms.\n * - 'skip': use empty string for this cell value\n * - 'read-as-is': read the cell content even though it's still loading (default)\n * - 'throw': throw an error with column name, row index and timeout info\n * - callback: called with (cell, columnName, row); its return value becomes the cell's string value\n * Defaults to 'read-as-is' when cellLoadingTimeout is set.\n */\n onCellLoadingTimeout?:\n | 'skip'\n | 'read-as-is'\n | 'throw'\n | ((cell: import('@playwright/test').Locator, columnName: string, row: SmartRow) => Promise<string>);\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 /** 0-based iteration counter \u2014 the order this row was visited, not its DOM position or grid identity. @deprecated Use `index` instead. `rowIndex` will be removed in v7.0.0. */\n rowIndex: number;\n /** 0-based iteration counter \u2014 the order this row was visited, not its DOM position or grid identity. */\n index: number;\n /** 0-based page index \u2014 which page this row was collected from. */\n pageIndex: 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; index: number; pageIndex: 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<T>>;\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<T>;\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<T>;\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<T>>;\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, useBulkPagination?: boolean }\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 * Counts the number of rows currently on the page.\n * Does not paginate.\n */\n countRows: () => Promise<number>;\n\n /**\n * Iterates over rows and extracts the value of a single column.\n * More efficient than map + toJSON for single-column extraction.\n * @param columnName - The name of the column to extract\n * @param options - Iteration options\n */\n mapColumn<R = string>(columnName: string, options?: RowIterationOptions): Promise<R[]>;\n\n /**\n * Iterates over rows and extracts the value of a single column as strings.\n * @param columnName - The name of the column to extract\n * @param options - Iteration options\n */\n getColumnValues(columnName: string, options?: RowIterationOptions): Promise<string[]>;\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";
|
package/dist/typeContext.js
CHANGED
|
@@ -506,9 +506,14 @@ export interface LoadingStrategy {
|
|
|
506
506
|
* - 'skip': use empty string for this cell value
|
|
507
507
|
* - 'read-as-is': read the cell content even though it's still loading (default)
|
|
508
508
|
* - 'throw': throw an error with column name, row index and timeout info
|
|
509
|
+
* - callback: called with (cell, columnName, row); its return value becomes the cell's string value
|
|
509
510
|
* Defaults to 'read-as-is' when cellLoadingTimeout is set.
|
|
510
511
|
*/
|
|
511
|
-
onCellLoadingTimeout?:
|
|
512
|
+
onCellLoadingTimeout?:
|
|
513
|
+
| 'skip'
|
|
514
|
+
| 'read-as-is'
|
|
515
|
+
| 'throw'
|
|
516
|
+
| ((cell: import('@playwright/test').Locator, columnName: string, row: SmartRow) => Promise<string>);
|
|
512
517
|
}
|
|
513
518
|
|
|
514
519
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -459,9 +459,10 @@ export interface LoadingStrategy {
|
|
|
459
459
|
* - 'skip': use empty string for this cell value
|
|
460
460
|
* - 'read-as-is': read the cell content even though it's still loading (default)
|
|
461
461
|
* - 'throw': throw an error with column name, row index and timeout info
|
|
462
|
+
* - callback: called with (cell, columnName, row); its return value becomes the cell's string value
|
|
462
463
|
* Defaults to 'read-as-is' when cellLoadingTimeout is set.
|
|
463
464
|
*/
|
|
464
|
-
onCellLoadingTimeout?: 'skip' | 'read-as-is' | 'throw';
|
|
465
|
+
onCellLoadingTimeout?: 'skip' | 'read-as-is' | 'throw' | ((cell: import('@playwright/test').Locator, columnName: string, row: SmartRow) => Promise<string>);
|
|
465
466
|
}
|
|
466
467
|
/**
|
|
467
468
|
* Organized container for all table interaction strategies.
|
package/dist/useTable.js
CHANGED
|
@@ -100,8 +100,6 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
100
100
|
return item(parent);
|
|
101
101
|
return item;
|
|
102
102
|
};
|
|
103
|
-
// Internal State
|
|
104
|
-
let _hasPaginated = false;
|
|
105
103
|
// Helpers
|
|
106
104
|
const log = (msg) => {
|
|
107
105
|
(0, debugUtils_1.logDebug)(config, 'verbose', msg);
|
|
@@ -135,7 +133,7 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
135
133
|
return (0, smartRow_1.default)(rowLocator, map, rowIndex, config, rootLocator, resolve, finalTable, tablePageIndex, barrier);
|
|
136
134
|
};
|
|
137
135
|
const tableState = { currentPageIndex: 0 };
|
|
138
|
-
const rowFinder = new rowFinder_1.RowFinder(rootLocator, config, resolve, filterEngine, tableMapper, _makeSmart, tableState);
|
|
136
|
+
const rowFinder = new rowFinder_1.RowFinder(rootLocator, config, resolve, filterEngine, tableMapper, _makeSmart, tableState, (useBulk) => _advancePage(useBulk));
|
|
139
137
|
/** Builds a full TableContext/StrategyContext with getHeaderCell, getHeaders, scrollToColumn. Set after result is created. */
|
|
140
138
|
let createStrategyContext = () => ({ root: rootLocator, config, page: rootLocator.page(), resolve });
|
|
141
139
|
const _getCleanHtml = async (loc) => {
|
|
@@ -326,7 +324,6 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
326
324
|
else if (hasPaginationInConfig) {
|
|
327
325
|
log("No goToFirst strategy configured. Table may not be on page 1.");
|
|
328
326
|
}
|
|
329
|
-
_hasPaginated = false;
|
|
330
327
|
tableState.currentPageIndex = 0;
|
|
331
328
|
tableMapper.clear();
|
|
332
329
|
log("Table reset complete. Calling autoInit to restore state.");
|
|
@@ -490,7 +487,11 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
490
487
|
log("Generating table config prompt...");
|
|
491
488
|
const html = await _getCleanHtml(rootLocator);
|
|
492
489
|
const separator = "=".repeat(50);
|
|
493
|
-
const
|
|
490
|
+
const maxLen = 10000;
|
|
491
|
+
const truncated = html.length > maxLen;
|
|
492
|
+
const htmlSnippet = truncated ? html.substring(0, maxLen) : html;
|
|
493
|
+
const truncationNote = truncated ? `\n[truncated ā ${html.length} chars total, showing first ${maxLen}]` : '';
|
|
494
|
+
const content = `\n${separator} \nš¤ Paste into your AI assistant š¤\n${separator} \nI am using 'playwright-smart-table'.\nTarget Table Locator: ${rootLocator.toString()} \nGenerate config for: \n\`\`\`html\n${htmlSnippet}${truncationNote}\n\`\`\`\n${separator}\n`;
|
|
494
495
|
await _handlePrompt('Smart Table Config', content);
|
|
495
496
|
},
|
|
496
497
|
generateConfigPrompt: async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rickcedwhat/playwright-smart-table",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.16.0",
|
|
4
4
|
"description": "Smart, column-aware table interactions for Playwright",
|
|
5
5
|
"author": "Cedrick Catalan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,6 +64,23 @@
|
|
|
64
64
|
"./presets/mui": {
|
|
65
65
|
"types": "./dist/presets/mui.d.ts",
|
|
66
66
|
"default": "./dist/presets/mui.js"
|
|
67
|
+
},
|
|
68
|
+
"./presets/rdg": {
|
|
69
|
+
"types": "./dist/presets/rdg.d.ts",
|
|
70
|
+
"default": "./dist/presets/rdg.js"
|
|
71
|
+
},
|
|
72
|
+
"./presets/glide": {
|
|
73
|
+
"types": "./dist/presets/glide/index.d.ts",
|
|
74
|
+
"default": "./dist/presets/glide/index.js"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"typesVersions": {
|
|
78
|
+
"*": {
|
|
79
|
+
"types": ["./dist/types.d.ts"],
|
|
80
|
+
"presets": ["./dist/presets/index.d.ts"],
|
|
81
|
+
"presets/mui": ["./dist/presets/mui.d.ts"],
|
|
82
|
+
"presets/rdg": ["./dist/presets/rdg.d.ts"],
|
|
83
|
+
"presets/glide": ["./dist/presets/glide/index.d.ts"]
|
|
67
84
|
}
|
|
68
85
|
},
|
|
69
86
|
"keywords": [
|
|
@@ -90,14 +107,19 @@
|
|
|
90
107
|
"@stryker-mutator/core": "^9.6.0",
|
|
91
108
|
"@stryker-mutator/vitest-runner": "^9.6.0",
|
|
92
109
|
"@types/node": "^25.5.2",
|
|
93
|
-
"@vitest/coverage-v8": "^3.2.
|
|
94
|
-
"@vitest/ui": "^3.2.
|
|
95
|
-
"happy-dom": "^20.
|
|
110
|
+
"@vitest/coverage-v8": "^3.2.6",
|
|
111
|
+
"@vitest/ui": "^3.2.6",
|
|
112
|
+
"happy-dom": "^20.10.6",
|
|
96
113
|
"husky": "^9.1.7",
|
|
97
114
|
"typescript": "^6.0.2",
|
|
98
115
|
"vitepress": "^1.6.4",
|
|
99
116
|
"vitepress-plugin-tabs": "^0.9.0",
|
|
100
|
-
"vitest": "^3.2.
|
|
117
|
+
"vitest": "^3.2.6"
|
|
101
118
|
},
|
|
102
|
-
"packageManager": "pnpm@10.33.2"
|
|
119
|
+
"packageManager": "pnpm@10.33.2",
|
|
120
|
+
"pnpm": {
|
|
121
|
+
"overrides": {
|
|
122
|
+
"fast-uri": ">=3.1.2"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
103
125
|
}
|