@rickcedwhat/playwright-smart-table 6.20.1-next.6c56f6d → 6.20.1-next.b5aa4bd
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/dist/engine/rowFinder.js +17 -2
- package/dist/filterEngine.d.ts +4 -0
- package/dist/filterEngine.js +15 -4
- package/dist/index.d.ts +6 -2
- package/dist/index.js +5 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/plugins/index.d.ts +51 -10
- package/dist/plugins/index.js +14 -6
- package/dist/presets/glide/index.d.ts +1 -1
- package/dist/presets/glide/index.js +2 -2
- package/dist/presets/rdg.d.ts +1 -1
- package/dist/presets/rdg.js +4 -4
- package/dist/smartRow.js +4 -23
- package/dist/strategies/columns.d.ts +5 -9
- package/dist/strategies/columns.js +0 -10
- package/dist/strategies/filter.d.ts +0 -4
- package/dist/strategies/filter.js +0 -16
- package/dist/strategies/index.d.ts +12 -15
- package/dist/strategies/index.js +6 -5
- package/dist/typeContext.d.ts +1 -1
- package/dist/typeContext.js +9 -1
- package/dist/types.d.ts +9 -1
- package/dist/useTable.js +9 -0
- package/dist/utils/resolveCellLocator.d.ts +35 -0
- package/dist/utils/resolveCellLocator.js +52 -0
- package/package.json +1 -1
package/dist/engine/rowFinder.js
CHANGED
|
@@ -7,6 +7,7 @@ const elementTracker_1 = require("../utils/elementTracker");
|
|
|
7
7
|
const sentinel_1 = require("../utils/sentinel");
|
|
8
8
|
const navigationBarrier_1 = require("../utils/navigationBarrier");
|
|
9
9
|
const rowResolution_1 = require("./rowResolution");
|
|
10
|
+
const resolveCellLocator_1 = require("../utils/resolveCellLocator");
|
|
10
11
|
class RowFinder {
|
|
11
12
|
constructor(rootLocator, config, resolve, filterEngine, tableMapper, makeSmartRow, tableState = { currentPageIndex: 0 }, advancePage = async () => false) {
|
|
12
13
|
this.rootLocator = rootLocator;
|
|
@@ -56,12 +57,26 @@ class RowFinder {
|
|
|
56
57
|
if (colIndex === undefined)
|
|
57
58
|
continue;
|
|
58
59
|
const override = this.config.columnOverrides[colName];
|
|
59
|
-
const cell =
|
|
60
|
+
const cell = (0, resolveCellLocator_1.resolveCellLocator)({
|
|
61
|
+
config: this.config,
|
|
62
|
+
resolve: this.resolve,
|
|
63
|
+
row: rowLocator,
|
|
64
|
+
root: this.rootLocator,
|
|
65
|
+
columnName: colName,
|
|
66
|
+
columnIndex: colIndex,
|
|
67
|
+
});
|
|
60
68
|
const getCell = (name) => {
|
|
61
69
|
const idx = map.get(name);
|
|
62
70
|
if (idx === undefined)
|
|
63
71
|
throw new Error(`Column "${name}" not found`);
|
|
64
|
-
return
|
|
72
|
+
return (0, resolveCellLocator_1.resolveCellLocator)({
|
|
73
|
+
config: this.config,
|
|
74
|
+
resolve: this.resolve,
|
|
75
|
+
row: rowLocator,
|
|
76
|
+
root: this.rootLocator,
|
|
77
|
+
columnName: name,
|
|
78
|
+
columnIndex: idx,
|
|
79
|
+
});
|
|
65
80
|
};
|
|
66
81
|
const context = {
|
|
67
82
|
row: this.makeSmartRow(rowLocator, map, undefined),
|
package/dist/filterEngine.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export declare class FilterEngine {
|
|
|
10
10
|
* Note: `rootLocator` is optional for backward compatibility in call sites that already
|
|
11
11
|
* pass only the page. When strategies.filter is present we construct a TableContext
|
|
12
12
|
* using the provided `rootLocator`.
|
|
13
|
+
*
|
|
14
|
+
* When `strategies.getCellLocator` is set, cells are resolved through that strategy
|
|
15
|
+
* (via a `:scope` row stub) so column-virtualized grids that use `aria-colindex` / etc.
|
|
16
|
+
* are not filtered with fragile `.nth(colIndex)` DOM order.
|
|
13
17
|
*/
|
|
14
18
|
applyFilters(baseRows: Locator, filters: Record<string, FilterValue>, map: Map<string, number>, exact: boolean, page: Page, rootLocator?: Locator): Locator;
|
|
15
19
|
}
|
package/dist/filterEngine.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterEngine = void 0;
|
|
4
4
|
const stringUtils_1 = require("./utils/stringUtils");
|
|
5
|
+
const resolveCellLocator_1 = require("./utils/resolveCellLocator");
|
|
5
6
|
class FilterEngine {
|
|
6
7
|
constructor(config, resolve) {
|
|
7
8
|
this.config = config;
|
|
@@ -13,6 +14,10 @@ class FilterEngine {
|
|
|
13
14
|
* Note: `rootLocator` is optional for backward compatibility in call sites that already
|
|
14
15
|
* pass only the page. When strategies.filter is present we construct a TableContext
|
|
15
16
|
* using the provided `rootLocator`.
|
|
17
|
+
*
|
|
18
|
+
* When `strategies.getCellLocator` is set, cells are resolved through that strategy
|
|
19
|
+
* (via a `:scope` row stub) so column-virtualized grids that use `aria-colindex` / etc.
|
|
20
|
+
* are not filtered with fragile `.nth(colIndex)` DOM order.
|
|
16
21
|
*/
|
|
17
22
|
applyFilters(baseRows, filters, map, exact, page, rootLocator) {
|
|
18
23
|
var _a;
|
|
@@ -41,10 +46,16 @@ class FilterEngine {
|
|
|
41
46
|
});
|
|
42
47
|
continue;
|
|
43
48
|
}
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
// Prefer getCellLocator (column-virtualized presets); else cellSelector.nth.
|
|
50
|
+
// Playwright re-bases the `has` locator into each candidate row.
|
|
51
|
+
const targetCell = (0, resolveCellLocator_1.resolveCellLocatorForFilter)({
|
|
52
|
+
config: this.config,
|
|
53
|
+
resolve: this.resolve,
|
|
54
|
+
page,
|
|
55
|
+
root: rootLocator,
|
|
56
|
+
columnName: colName,
|
|
57
|
+
columnIndex: colIndex,
|
|
58
|
+
});
|
|
48
59
|
if (typeof filterVal === 'function') {
|
|
49
60
|
// Locator-based filter: (cell) => cell.locator(...)
|
|
50
61
|
filtered = filtered.filter({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export { PLAYWRIGHT_SMART_TABLE_VERSION } from './packageVersion';
|
|
2
2
|
export { useTable } from './useTable';
|
|
3
|
-
export type { TableConfig, TableResult, SmartRow, SmartCell, Selector, FilterValue, PaginationPrimitives, SortingStrategy, FillOptions, RowIterationContext, RowIterationOptions, TableContext, StrategyContext, BeforeCellReadFn, GetCellLocatorFn, GetActiveCellFn, DebugConfig, SyntheticColumnDef, ColumnOverride, ColumnOverrideReadContext, } from './types';
|
|
3
|
+
export type { TableConfig, TableResult, SmartRow, SmartCell, Selector, FilterValue, PaginationPrimitives, SortingStrategy, FillOptions, RowIterationContext, RowIterationOptions, TableContext, StrategyContext, BeforeCellReadFn, GetCellLocatorFn, GetActiveCellFn, DebugConfig, SyntheticColumnDef, ColumnOverride, ColumnOverrideReadContext, TableStrategies, LoadingStrategy, ViewportStrategy, FilterStrategy, NavigationPrimitives, DedupeStrategy, ContentReadyStrategy, FillStrategy, PaginationStrategy, HeaderStrategy, } from './types';
|
|
4
4
|
export { Strategies } from './strategies';
|
|
5
5
|
export * as presets from './presets';
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `presets` instead (`presets.muiDataGrid`, `presets.rdg`, `presets.glide`, …).
|
|
8
|
+
* `Plugins` will be removed in v7.0.0.
|
|
9
|
+
* Note: `Plugins.MUI` is the **DataGrid** preset only — for MUI Table use `presets.muiTable`.
|
|
10
|
+
*/
|
|
7
11
|
export { Plugins } from './plugins';
|
|
8
12
|
export { mergeTableConfig } from './utils/mergeTableConfig';
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,11 @@ Object.defineProperty(exports, "useTable", { enumerable: true, get: function ()
|
|
|
42
42
|
var strategies_1 = require("./strategies");
|
|
43
43
|
Object.defineProperty(exports, "Strategies", { enumerable: true, get: function () { return strategies_1.Strategies; } });
|
|
44
44
|
exports.presets = __importStar(require("./presets"));
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Use `presets` instead (`presets.muiDataGrid`, `presets.rdg`, `presets.glide`, …).
|
|
47
|
+
* `Plugins` will be removed in v7.0.0.
|
|
48
|
+
* Note: `Plugins.MUI` is the **DataGrid** preset only — for MUI Table use `presets.muiTable`.
|
|
49
|
+
*/
|
|
46
50
|
var plugins_1 = require("./plugins");
|
|
47
51
|
Object.defineProperty(exports, "Plugins", { enumerable: true, get: function () { return plugins_1.Plugins; } });
|
|
48
52
|
var mergeTableConfig_1 = require("./utils/mergeTableConfig");
|
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.20.1-next.
|
|
6
|
+
export declare const PLAYWRIGHT_SMART_TABLE_VERSION: "6.20.1-next.b5aa4bd";
|
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.20.1-next.
|
|
9
|
+
exports.PLAYWRIGHT_SMART_TABLE_VERSION = "6.20.1-next.b5aa4bd";
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated Use `presets` instead. Plugins will be removed in v7.0.0.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* - Plugins.
|
|
3
|
+
*
|
|
4
|
+
* Compatibility shim over official presets:
|
|
5
|
+
* - `Plugins.MUI` → `presets.muiDataGrid` (**DataGrid only** — not `presets.muiTable`)
|
|
6
|
+
* - `Plugins.RDG` → `presets.rdg`
|
|
7
|
+
* - `Plugins.Glide` → `presets.glide`
|
|
8
|
+
*
|
|
9
|
+
* Prefer: `useTable(loc, { ...presets.muiDataGrid, maxPages: 5 })`.
|
|
10
|
+
* Strategies only: `useTable(loc, { rowSelector: '...', strategies: presets.muiDataGrid.strategies })`.
|
|
6
11
|
*/
|
|
7
12
|
export declare const Plugins: {
|
|
8
13
|
/** @deprecated Use `presets.rdg` */
|
|
9
14
|
RDG: {
|
|
10
|
-
Strategies:
|
|
15
|
+
Strategies: {
|
|
16
|
+
header: (context: import("..").TableContext) => Promise<string[]>;
|
|
17
|
+
getCellLocator: ({ row, columnIndex }: {
|
|
18
|
+
row: import("@playwright/test").Locator;
|
|
19
|
+
columnIndex: number;
|
|
20
|
+
}) => import("@playwright/test").Locator;
|
|
21
|
+
navigation: {
|
|
22
|
+
goRight: ({ root }: import("..").StrategyContext) => Promise<void>;
|
|
23
|
+
goLeft: ({ root }: import("..").StrategyContext) => Promise<void>;
|
|
24
|
+
goDown: ({ root }: import("..").StrategyContext) => Promise<void>;
|
|
25
|
+
goUp: ({ root }: import("..").StrategyContext) => Promise<void>;
|
|
26
|
+
goHome: ({ root }: import("..").StrategyContext) => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
pagination: import("..").PaginationPrimitives;
|
|
29
|
+
};
|
|
11
30
|
headerSelector?: string | ((root: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
|
|
12
31
|
rowSelector?: string | undefined;
|
|
13
32
|
cellSelector?: string | ((row: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
|
|
@@ -22,14 +41,33 @@ export declare const Plugins: {
|
|
|
22
41
|
autoScroll?: boolean | undefined;
|
|
23
42
|
debug?: import("..").DebugConfig | undefined;
|
|
24
43
|
onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
|
|
25
|
-
strategies?: import("
|
|
44
|
+
strategies?: import("..").TableStrategies | undefined;
|
|
26
45
|
columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
|
|
27
46
|
syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
|
|
28
47
|
emptyState?: import("@playwright/test").Locator | undefined;
|
|
29
48
|
};
|
|
30
49
|
/** @deprecated Use `presets.glide` */
|
|
31
50
|
Glide: {
|
|
32
|
-
Strategies:
|
|
51
|
+
Strategies: {
|
|
52
|
+
fillSimple: import("..").FillStrategy;
|
|
53
|
+
fill: import("..").FillStrategy;
|
|
54
|
+
pagination: import("..").PaginationPrimitives;
|
|
55
|
+
header: (context: import("..").StrategyContext, options?: {
|
|
56
|
+
limit?: number;
|
|
57
|
+
selector?: string;
|
|
58
|
+
scrollAmount?: number;
|
|
59
|
+
}) => Promise<string[]>;
|
|
60
|
+
viewport: import("..").ViewportStrategy;
|
|
61
|
+
loading: {
|
|
62
|
+
isHeaderLoading: () => Promise<boolean>;
|
|
63
|
+
};
|
|
64
|
+
getCellLocator: ({ row, columnIndex }: any) => any;
|
|
65
|
+
getActiveCell: ({ page }: any) => Promise<{
|
|
66
|
+
rowIndex: number;
|
|
67
|
+
columnIndex: number;
|
|
68
|
+
locator: any;
|
|
69
|
+
} | null>;
|
|
70
|
+
};
|
|
33
71
|
headerSelector?: string | ((root: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
|
|
34
72
|
rowSelector?: string | undefined;
|
|
35
73
|
cellSelector?: string | ((row: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
|
|
@@ -44,14 +82,17 @@ export declare const Plugins: {
|
|
|
44
82
|
autoScroll?: boolean | undefined;
|
|
45
83
|
debug?: import("..").DebugConfig | undefined;
|
|
46
84
|
onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
|
|
47
|
-
strategies?: import("
|
|
85
|
+
strategies?: import("..").TableStrategies | undefined;
|
|
48
86
|
columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
|
|
49
87
|
syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
|
|
50
88
|
emptyState?: import("@playwright/test").Locator | undefined;
|
|
51
89
|
};
|
|
52
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use `presets.muiDataGrid`.
|
|
92
|
+
* DataGrid only — for MUI `<Table>` use `presets.muiTable`.
|
|
93
|
+
*/
|
|
53
94
|
MUI: {
|
|
54
|
-
Strategies: import("
|
|
95
|
+
Strategies: import("..").TableStrategies | undefined;
|
|
55
96
|
headerSelector?: string | ((root: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
|
|
56
97
|
rowSelector?: string | undefined;
|
|
57
98
|
cellSelector?: string | ((row: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
|
|
@@ -66,7 +107,7 @@ export declare const Plugins: {
|
|
|
66
107
|
autoScroll?: boolean | undefined;
|
|
67
108
|
debug?: import("..").DebugConfig | undefined;
|
|
68
109
|
onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
|
|
69
|
-
strategies?: import("
|
|
110
|
+
strategies?: import("..").TableStrategies | undefined;
|
|
70
111
|
columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
|
|
71
112
|
syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
|
|
72
113
|
emptyState?: import("@playwright/test").Locator | undefined;
|
package/dist/plugins/index.js
CHANGED
|
@@ -4,15 +4,23 @@ exports.Plugins = void 0;
|
|
|
4
4
|
const presets_1 = require("../presets");
|
|
5
5
|
/**
|
|
6
6
|
* @deprecated Use `presets` instead. Plugins will be removed in v7.0.0.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - Plugins.
|
|
7
|
+
*
|
|
8
|
+
* Compatibility shim over official presets:
|
|
9
|
+
* - `Plugins.MUI` → `presets.muiDataGrid` (**DataGrid only** — not `presets.muiTable`)
|
|
10
|
+
* - `Plugins.RDG` → `presets.rdg`
|
|
11
|
+
* - `Plugins.Glide` → `presets.glide`
|
|
12
|
+
*
|
|
13
|
+
* Prefer: `useTable(loc, { ...presets.muiDataGrid, maxPages: 5 })`.
|
|
14
|
+
* Strategies only: `useTable(loc, { rowSelector: '...', strategies: presets.muiDataGrid.strategies })`.
|
|
10
15
|
*/
|
|
11
16
|
exports.Plugins = {
|
|
12
17
|
/** @deprecated Use `presets.rdg` */
|
|
13
|
-
RDG: Object.assign(Object.assign({}, presets_1.rdg), { Strategies: presets_1.rdg.
|
|
18
|
+
RDG: Object.assign(Object.assign({}, presets_1.rdg), { Strategies: presets_1.rdg.Strategies }),
|
|
14
19
|
/** @deprecated Use `presets.glide` */
|
|
15
|
-
Glide: Object.assign(Object.assign({}, presets_1.glide), { Strategies: presets_1.glide.
|
|
16
|
-
/**
|
|
20
|
+
Glide: Object.assign(Object.assign({}, presets_1.glide), { Strategies: presets_1.glide.Strategies }),
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use `presets.muiDataGrid`.
|
|
23
|
+
* DataGrid only — for MUI `<Table>` use `presets.muiTable`.
|
|
24
|
+
*/
|
|
17
25
|
MUI: Object.assign(Object.assign({}, presets_1.muiDataGrid), { Strategies: presets_1.muiDataGrid.strategies }),
|
|
18
26
|
};
|
|
@@ -12,7 +12,7 @@ export declare const GlideStrategies: {
|
|
|
12
12
|
selector?: string;
|
|
13
13
|
scrollAmount?: number;
|
|
14
14
|
}) => Promise<string[]>;
|
|
15
|
-
viewport: import("
|
|
15
|
+
viewport: import("../..").ViewportStrategy;
|
|
16
16
|
loading: {
|
|
17
17
|
isHeaderLoading: () => Promise<boolean>;
|
|
18
18
|
};
|
|
@@ -123,8 +123,8 @@ function createGlide(options = {}) {
|
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Full preset for Glide Data Grid (selectors + default strategies only).
|
|
126
|
-
* Spread: useTable(loc, { ...
|
|
127
|
-
* Strategies only (including fillSimple): useTable(loc, { rowSelector: '...', strategies:
|
|
126
|
+
* Spread: `useTable(loc, { ...presets.glide, maxPages: 5 })`.
|
|
127
|
+
* Strategies only (including fillSimple): `useTable(loc, { rowSelector: '...', strategies: presets.glide.Strategies })`.
|
|
128
128
|
* For a non-64-column grid, use `createGlide({ columnCount })` instead.
|
|
129
129
|
*/
|
|
130
130
|
const GlidePreset = {
|
package/dist/presets/rdg.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Locator } from '@playwright/test';
|
|
2
2
|
import { TableContext, TableConfig, ViewportStrategy, StrategyContext } from '../types';
|
|
3
|
-
/** Full strategies for React Data Grid. Use when you want to supply your own selectors: strategies:
|
|
3
|
+
/** Full strategies for React Data Grid. Use when you want to supply your own selectors: `strategies: presets.rdg.Strategies` */
|
|
4
4
|
export declare const RDGStrategies: {
|
|
5
5
|
header: (context: TableContext) => Promise<string[]>;
|
|
6
6
|
getCellLocator: ({ row, columnIndex }: {
|
package/dist/presets/rdg.js
CHANGED
|
@@ -92,20 +92,20 @@ const rdgNavigation = {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
/** Default strategies for the RDG preset (used when you spread
|
|
95
|
+
/** Default strategies for the RDG preset (used when you spread `presets.rdg`). */
|
|
96
96
|
const RDGDefaultStrategies = {
|
|
97
97
|
header: scrollRightHeaderRDG,
|
|
98
98
|
getCellLocator: rdgGetCellLocator,
|
|
99
99
|
navigation: rdgNavigation,
|
|
100
100
|
pagination: rdgPaginationStrategy
|
|
101
101
|
};
|
|
102
|
-
/** Full strategies for React Data Grid. Use when you want to supply your own selectors: strategies:
|
|
102
|
+
/** Full strategies for React Data Grid. Use when you want to supply your own selectors: `strategies: presets.rdg.Strategies` */
|
|
103
103
|
// fallow-ignore-next-line unused-export
|
|
104
104
|
exports.RDGStrategies = RDGDefaultStrategies;
|
|
105
105
|
/**
|
|
106
106
|
* Full preset for React Data Grid (selectors + default strategies).
|
|
107
|
-
* Spread: useTable(loc, { ...
|
|
108
|
-
* Strategies only: useTable(loc, { rowSelector: '...', strategies:
|
|
107
|
+
* Spread: `useTable(loc, { ...presets.rdg, maxPages: 5 })`.
|
|
108
|
+
* Strategies only: `useTable(loc, { rowSelector: '...', strategies: presets.rdg.Strategies })`.
|
|
109
109
|
*/
|
|
110
110
|
const RDGPreset = {
|
|
111
111
|
rowSelector: '[role="row"].rdg-row',
|
package/dist/smartRow.js
CHANGED
|
@@ -196,6 +196,8 @@ const _navigateToCell = async (params) => {
|
|
|
196
196
|
currCol = ac.columnIndex;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
+
// Column-0 snap is owned by the navigation primitive (scrollLeft=0, Home, etc.).
|
|
200
|
+
// Core must not special-case canvas/Home — that was pre-viewport Glide glue.
|
|
199
201
|
if (index === 0 && nav.snapFirstColumnIntoView) {
|
|
200
202
|
(0, debugUtils_1.logDebug)(config, 'verbose', '_navigateToCell: snapFirstColumnIntoView for column index 0');
|
|
201
203
|
await nav.snapFirstColumnIntoView(context);
|
|
@@ -206,27 +208,6 @@ const _navigateToCell = async (params) => {
|
|
|
206
208
|
currCol = ac.columnIndex;
|
|
207
209
|
}
|
|
208
210
|
}
|
|
209
|
-
// Home moves a11y focus within the current row to column 0. If focus row !== target row
|
|
210
|
-
// (e.g. still on previous row), Home jumps to grid origin and breaks `tr.nth(k)` reads.
|
|
211
|
-
if (typeof rowIndex === 'number' && currRow === rowIndex) {
|
|
212
|
-
await rootLocator.evaluate((el) => {
|
|
213
|
-
var _a;
|
|
214
|
-
const canvas = el.closest('canvas') || ((_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.querySelector('canvas'));
|
|
215
|
-
if (canvas instanceof HTMLCanvasElement) {
|
|
216
|
-
canvas.tabIndex = 0;
|
|
217
|
-
canvas.focus();
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
await page.keyboard.press('Home');
|
|
221
|
-
await page.waitForTimeout(120);
|
|
222
|
-
if (config.strategies.getActiveCell) {
|
|
223
|
-
const ac = await config.strategies.getActiveCell({ config, root: rootLocator, page, resolve });
|
|
224
|
-
if (ac) {
|
|
225
|
-
currRow = ac.rowIndex;
|
|
226
|
-
currCol = ac.columnIndex;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
211
|
}
|
|
231
212
|
let cDiff = index - currCol;
|
|
232
213
|
if (Math.abs(cDiff) > 12 && nav.seekColumnIndex) {
|
|
@@ -253,8 +234,8 @@ const _navigateToCell = async (params) => {
|
|
|
253
234
|
const settleMs = (Number.isFinite(nav.settleMs) && nav.settleMs >= 0) ? nav.settleMs : computed;
|
|
254
235
|
await page.waitForTimeout(settleMs);
|
|
255
236
|
}
|
|
256
|
-
//
|
|
257
|
-
//
|
|
237
|
+
// After horizontal steps, poll until getActiveCell / DOM presence confirms the target
|
|
238
|
+
// (a11y trees and virtual mounts often lag the scroll). Tune via navigation.maxWaitMs.
|
|
258
239
|
const pollIntervalMs = 10;
|
|
259
240
|
const computedMax = Math.min(6000, 250 + horizontalSteps * 25);
|
|
260
241
|
const maxWaitMs = (Number.isFinite(nav.maxWaitMs) && nav.maxWaitMs >= 0) ? nav.maxWaitMs : computedMax;
|
|
@@ -12,7 +12,9 @@ export interface NavigationPrimitives {
|
|
|
12
12
|
goHome?: (context: StrategyContext) => Promise<void>;
|
|
13
13
|
/**
|
|
14
14
|
* After vertical moves, run before horizontal steps when the target column index is 0.
|
|
15
|
-
* Use for horizontally virtualized
|
|
15
|
+
* Use for horizontally virtualized tables so the first column exists in the DOM again
|
|
16
|
+
* (e.g. set scrollLeft = 0). If the table needs keyboard `Home` or canvas focus, put that
|
|
17
|
+
* here — the core orchestrator does not special-case those behaviors.
|
|
16
18
|
* Do not reset vertical scroll here — RDG-style `goHome` is often unsuitable.
|
|
17
19
|
*/
|
|
18
20
|
snapFirstColumnIntoView?: (context: StrategyContext) => Promise<void>;
|
|
@@ -33,7 +35,8 @@ export interface NavigationPrimitives {
|
|
|
33
35
|
maxWaitMs?: number;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
|
-
* @deprecated Use NavigationPrimitives instead.
|
|
38
|
+
* @deprecated Use NavigationPrimitives (`strategies.navigation`) instead. Removed from
|
|
39
|
+
* the public `Strategies` namespace in #428; this type remains for transitional typings.
|
|
37
40
|
* Defines the contract for a cell navigation strategy.
|
|
38
41
|
*/
|
|
39
42
|
export type CellNavigationStrategy = (context: StrategyContext & {
|
|
@@ -46,10 +49,3 @@ export type CellNavigationStrategy = (context: StrategyContext & {
|
|
|
46
49
|
locator: Locator;
|
|
47
50
|
} | null;
|
|
48
51
|
}) => Promise<void>;
|
|
49
|
-
export declare const CellNavigationStrategies: {
|
|
50
|
-
/**
|
|
51
|
-
* Default strategy: Assumes column is accessible or standard scrolling works.
|
|
52
|
-
* No specific action taken other than what Playwright's default locator handling does.
|
|
53
|
-
*/
|
|
54
|
-
default: () => Promise<void>;
|
|
55
|
-
};
|
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CellNavigationStrategies = void 0;
|
|
4
|
-
exports.CellNavigationStrategies = {
|
|
5
|
-
/**
|
|
6
|
-
* Default strategy: Assumes column is accessible or standard scrolling works.
|
|
7
|
-
* No specific action taken other than what Playwright's default locator handling does.
|
|
8
|
-
*/
|
|
9
|
-
default: async () => {
|
|
10
|
-
// No-op
|
|
11
|
-
}
|
|
12
|
-
};
|
|
@@ -2,12 +2,8 @@ import type { FilterStrategy } from '../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Example filter strategies.
|
|
4
4
|
* - default: small convenience wrapper that mirrors the engine's default behavior.
|
|
5
|
-
* - spy(factory): returns a strategy that marks `calledRef.called = true` when invoked.
|
|
6
5
|
*/
|
|
7
6
|
export declare const FilterStrategies: {
|
|
8
7
|
default: FilterStrategy;
|
|
9
|
-
spy: (calledRef?: {
|
|
10
|
-
called?: boolean;
|
|
11
|
-
}) => FilterStrategy;
|
|
12
8
|
};
|
|
13
9
|
export type { FilterStrategy } from '../types';
|
|
@@ -4,7 +4,6 @@ exports.FilterStrategies = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Example filter strategies.
|
|
6
6
|
* - default: small convenience wrapper that mirrors the engine's default behavior.
|
|
7
|
-
* - spy(factory): returns a strategy that marks `calledRef.called = true` when invoked.
|
|
8
7
|
*/
|
|
9
8
|
exports.FilterStrategies = {
|
|
10
9
|
default: {
|
|
@@ -20,19 +19,4 @@ exports.FilterStrategies = {
|
|
|
20
19
|
return rows.filter({ has: targetCell.getByText(textVal, { exact: true }) });
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
|
-
spy: (calledRef = {}) => ({
|
|
24
|
-
apply({ rows, filter, colIndex, tableContext }) {
|
|
25
|
-
calledRef.called = true;
|
|
26
|
-
// Delegate to default behaviour for actual filtering
|
|
27
|
-
const page = tableContext.page;
|
|
28
|
-
const resolve = tableContext.resolve;
|
|
29
|
-
const cellTemplate = resolve(tableContext.config.cellSelector, page);
|
|
30
|
-
const targetCell = cellTemplate.nth(colIndex);
|
|
31
|
-
if (typeof filter.value === 'function') {
|
|
32
|
-
return rows.filter({ has: filter.value(targetCell) });
|
|
33
|
-
}
|
|
34
|
-
const textVal = typeof filter.value === 'number' ? String(filter.value) : filter.value;
|
|
35
|
-
return rows.filter({ has: targetCell.getByText(textVal, { exact: true }) });
|
|
36
|
-
}
|
|
37
|
-
}),
|
|
38
22
|
};
|
|
@@ -3,13 +3,19 @@ export * from './sorting';
|
|
|
3
3
|
export * from './columns';
|
|
4
4
|
export * from './headers';
|
|
5
5
|
export * from './fill';
|
|
6
|
-
export
|
|
6
|
+
export type { ColumnResolutionStrategy } from './resolution';
|
|
7
7
|
export * from './dedupe';
|
|
8
8
|
export * from './loading';
|
|
9
9
|
export * from './stabilization';
|
|
10
10
|
export * from './filter';
|
|
11
11
|
export * from './viewport';
|
|
12
12
|
export * from './contentReady';
|
|
13
|
+
/**
|
|
14
|
+
* Built-in strategy factories.
|
|
15
|
+
* @note `CellNavigation` / `Resolution` removed from this namespace in #428 (dead/no-op).
|
|
16
|
+
* Use `strategies.navigation` (NavigationPrimitives) and header maps instead.
|
|
17
|
+
* `Filter.spy` was test-only and is no longer shipped.
|
|
18
|
+
*/
|
|
13
19
|
export declare const Strategies: {
|
|
14
20
|
Pagination: {
|
|
15
21
|
click: (selectors: {
|
|
@@ -27,21 +33,18 @@ export declare const Strategies: {
|
|
|
27
33
|
detectCurrentPage?: (root: import("@playwright/test").Locator) => number | Promise<number>;
|
|
28
34
|
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
29
35
|
timeout?: number;
|
|
30
|
-
}) => import("
|
|
36
|
+
}) => import("..").PaginationStrategy;
|
|
31
37
|
infiniteScroll: (options?: {
|
|
32
38
|
action?: "scroll" | "js-scroll";
|
|
33
39
|
scrollTarget?: import("..").Selector;
|
|
34
40
|
scrollAmount?: number;
|
|
35
41
|
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
36
42
|
timeout?: number;
|
|
37
|
-
}) => import("
|
|
43
|
+
}) => import("..").PaginationStrategy;
|
|
38
44
|
};
|
|
39
45
|
Sorting: {
|
|
40
46
|
AriaSort: () => import("..").SortingStrategy;
|
|
41
47
|
};
|
|
42
|
-
CellNavigation: {
|
|
43
|
-
default: () => Promise<void>;
|
|
44
|
-
};
|
|
45
48
|
Header: {
|
|
46
49
|
visible: ({ config, resolve, root }: import("..").StrategyContext) => Promise<string[]>;
|
|
47
50
|
horizontalScroll: (options?: {
|
|
@@ -51,13 +54,10 @@ export declare const Strategies: {
|
|
|
51
54
|
}) => import("./headers").HeaderStrategy;
|
|
52
55
|
};
|
|
53
56
|
Fill: {
|
|
54
|
-
default: ({ row, columnName, value, fillOptions, config, table }: Parameters<import("
|
|
55
|
-
};
|
|
56
|
-
Resolution: {
|
|
57
|
-
default: import("./resolution").ColumnResolutionStrategy;
|
|
57
|
+
default: ({ row, columnName, value, fillOptions, config, table }: Parameters<import("..").FillStrategy>[0]) => Promise<void>;
|
|
58
58
|
};
|
|
59
59
|
Dedupe: {
|
|
60
|
-
byTopPosition: (tolerance?: number) => import("
|
|
60
|
+
byTopPosition: (tolerance?: number) => import("..").DedupeStrategy;
|
|
61
61
|
};
|
|
62
62
|
Loading: {
|
|
63
63
|
Table: {
|
|
@@ -94,12 +94,9 @@ export declare const Strategies: {
|
|
|
94
94
|
};
|
|
95
95
|
Filter: {
|
|
96
96
|
default: import("./filter").FilterStrategy;
|
|
97
|
-
spy: (calledRef?: {
|
|
98
|
-
called?: boolean;
|
|
99
|
-
}) => import("./filter").FilterStrategy;
|
|
100
97
|
};
|
|
101
98
|
Viewport: {
|
|
102
|
-
dataAttribute: (options?: import("./viewport").DataAttributeViewportOptions) => import("
|
|
99
|
+
dataAttribute: (options?: import("./viewport").DataAttributeViewportOptions) => import("..").ViewportStrategy;
|
|
103
100
|
};
|
|
104
101
|
ContentReady: {
|
|
105
102
|
textStable: (options?: {
|
package/dist/strategies/index.js
CHANGED
|
@@ -17,10 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.Strategies = void 0;
|
|
18
18
|
const pagination_1 = require("./pagination");
|
|
19
19
|
const sorting_1 = require("./sorting");
|
|
20
|
-
const columns_1 = require("./columns");
|
|
21
20
|
const headers_1 = require("./headers");
|
|
22
21
|
const fill_1 = require("./fill");
|
|
23
|
-
const resolution_1 = require("./resolution");
|
|
24
22
|
const dedupe_1 = require("./dedupe");
|
|
25
23
|
const loading_1 = require("./loading");
|
|
26
24
|
const stabilization_1 = require("./stabilization");
|
|
@@ -32,20 +30,23 @@ __exportStar(require("./sorting"), exports);
|
|
|
32
30
|
__exportStar(require("./columns"), exports);
|
|
33
31
|
__exportStar(require("./headers"), exports);
|
|
34
32
|
__exportStar(require("./fill"), exports);
|
|
35
|
-
__exportStar(require("./resolution"), exports);
|
|
36
33
|
__exportStar(require("./dedupe"), exports);
|
|
37
34
|
__exportStar(require("./loading"), exports);
|
|
38
35
|
__exportStar(require("./stabilization"), exports);
|
|
39
36
|
__exportStar(require("./filter"), exports);
|
|
40
37
|
__exportStar(require("./viewport"), exports);
|
|
41
38
|
__exportStar(require("./contentReady"), exports);
|
|
39
|
+
/**
|
|
40
|
+
* Built-in strategy factories.
|
|
41
|
+
* @note `CellNavigation` / `Resolution` removed from this namespace in #428 (dead/no-op).
|
|
42
|
+
* Use `strategies.navigation` (NavigationPrimitives) and header maps instead.
|
|
43
|
+
* `Filter.spy` was test-only and is no longer shipped.
|
|
44
|
+
*/
|
|
42
45
|
exports.Strategies = {
|
|
43
46
|
Pagination: pagination_1.PaginationStrategies,
|
|
44
47
|
Sorting: sorting_1.SortingStrategies,
|
|
45
|
-
CellNavigation: columns_1.CellNavigationStrategies,
|
|
46
48
|
Header: headers_1.HeaderStrategies,
|
|
47
49
|
Fill: fill_1.FillStrategies,
|
|
48
|
-
Resolution: resolution_1.ResolutionStrategies,
|
|
49
50
|
Dedupe: dedupe_1.DedupeStrategies,
|
|
50
51
|
Loading: loading_1.LoadingStrategies,
|
|
51
52
|
Stabilization: stabilization_1.StabilizationStrategies,
|
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 * Return type for `resolveRowIndex`. A plain number gives the logical index only;\n * `{ index, selector }` additionally provides a CSS selector the library uses to\n * build a self-healing row locator that survives virtual-scroll DOM recycling.\n */\nexport type RowIndexResult = number | { index: number; selector: string };\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 DOM positions (0-based, document order \u2014 indices into the resolved\n * `rowSelector` set) of rows currently within the scroll container's visible bounds.\n * Unlike `getVisibleRowRange` (a logical min/max), this identifies the exact rows, so\n * `map`/`forEach`/`filter` can skip overscan rows during collection (see #353 / #357).\n * Geometry-based and inclusive (any overlap counts as visible). When the container can't\n * be measured, return all positions so no rows are filtered.\n */\n getVisibleRowIndices?: (context: TableContext) => Promise<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 * // Atomic: snapshot all cell values in a single evaluate \u2014 zero inter-column stagger.\n * // Requires cellSelector to be a CSS string (not a function).\n * // Column overrides ARE supported (run against a frozen off-screen reconstruction).\n * // Uses textContent (not layout-dependent innerText) for non-override columns.\n * const coherent = await row.toJSON({ atomic: true });\n */\n toJSON(options?: { columns?: string[]; atomic?: boolean }): 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 * Get the resolved value of any column \u2014 real, override, or synthetic.\n * @param column - Column name (case-sensitive)\n * @returns The column value as a string\n */\n getValue(column: string): Promise<string>;\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\nexport type ContentReadyStrategy = (row: Locator, page: Page) => Promise<void>;\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\n/** Context passed as the second argument to {@link ColumnOverride.read}. */\nexport interface ColumnOverrideReadContext {\n /**\n * The parent row. Use for multi-cell or row-derived values \u2014 e.g. a synthetic column\n * that reads an `a[href]` or a `data-*` attribute from the row rather than a cell:\n * `read: (_cell, { row }) => row.evaluate(el => el.querySelector('a')?.href)`.\n */\n row: SmartRow;\n /** The column being read. */\n columnName: string;\n /** The column's 0-based index in the resolved header map. */\n columnIndex: number;\n /**\n * Get a Locator for another cell in the same row by column name.\n * Returns raw cell Locators, not override-processed values.\n *\n * In atomic mode, the Locator points at the frozen reconstructed cell \u2014 coherent with\n * every other cell from the same snapshot. In non-atomic mode, it points at the live cell.\n *\n * @example\n * read: async (_cell, { getCell }) => {\n * const name = (await getCell('Name').innerText()).trim();\n * const href = await getCell('Name').locator('a').getAttribute('href') || '';\n * return `${name} | ${href}`;\n * }\n */\n getCell: (columnName: string) => Locator;\n}\n\nexport interface SyntheticColumnDef<T = any> {\n compute: (row: SmartRow<T>) => Promise<string | number> | string | number;\n}\n\nexport interface ColumnOverride<TValue = any> {\n /**\n * How to extract the value from the cell.\n * The second `context` argument provides the parent `row` (for multi-cell or row-derived\n * values), plus `columnName` and `columnIndex`. Backwards-compatible: existing\n * single-argument `read(cell)` implementations keep working.\n */\n read?: (cell: Locator, context: ColumnOverrideReadContext) => 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 * Honored by findRows AND by map/forEach/filter, where the wait runs before the dedupe\n * strategy so content-based dedupe keys see the row's final loaded state.\n * When not set (backward-compatible behavior): findRows skips loading rows immediately;\n * map/forEach/filter process them as-is.\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 /** Max ms to wait for sort stabilization when isTableLoading is set. @default 10000 */\n sortStabilizationTimeout?: number;\n /** Polling interval (ms) while waiting for sort stabilization. @default 100 */\n sortStabilizationPollInterval?: number;\n /** Fallback delay (ms) after sort when no isTableLoading is configured. @default 200 */\n sortStabilizationFallbackDelay?: number;\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 * Resolve the stable data-model index for a row locator.\n *\n * Called by `findRow` / `findRows` to convert a DOM row into the index used for\n * virtual-scroll positioning. Useful for grids where DOM position resets to 0 on\n * each page while the grid itself maintains a monotone counter (e.g. MUI DataGrid's\n * `data-rowindex` attribute).\n *\n * Return `undefined` to fall back to DOM position.\n *\n * When the index maps to a DOM attribute, return `{ index, selector }` instead of\n * a plain number. The library uses the CSS selector to build a **self-healing row\n * locator** that re-queries the DOM on every action \u2014 surviving virtual-scroll\n * recycling for `getCell`, `smartFill`, and `toJSON` without manual re-pinning.\n *\n * @example\n * // MUI DataGrid: self-healing via data-rowindex attribute\n * resolveRowIndex: async (row) => {\n * const v = await row.getAttribute('data-rowindex').catch(() => null);\n * if (v === null || isNaN(Number(v))) return undefined;\n * return { index: Number(v), selector: `[data-rowindex=\"${v}\"]` };\n * }\n */\n resolveRowIndex?: (row: Locator) => Promise<RowIndexResult | undefined>;\n\n /**\n * Waits until a row's content has stabilized before cloning in\n * `toJSON({ atomic: true })`. Needed for recycling virtualizers where the\n * framework updates element positions synchronously but renders cell content\n * asynchronously (e.g. react-window, react-virtuoso with React concurrent mode).\n *\n * Without this, the clone captures stale content from the previous occupant of the\n * DOM slot \u2014 the element is at the correct position but React hasn't re-rendered yet.\n *\n * Use `Strategies.ContentReady.textStable()` for the built-in text-polling strategy.\n *\n * @example\n * strategies: {\n * contentReady: Strategies.ContentReady.textStable({ timeout: 500 }),\n * }\n */\n contentReady?: ContentReadyStrategy;\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 /** Hook called after reset completes (after goToFirst, cache clear, and autoInit). */\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 /**\n * Computed columns with no DOM presence. Each key becomes a virtual column name\n * available in `toJSON()`, `getValue()`, and `findRow()`/`findRows()` filters.\n * The `compute` function receives the full SmartRow and must only read real or\n * override columns (no chaining between synthetics).\n */\n syntheticColumns?: Record<string, SyntheticColumnDef<T>>;\n\n /**\n * Locator for an empty-state element that replaces the table when there are no results.\n * If header resolution fails during init() and this locator is visible, init() succeeds\n * and isEmpty() returns true. All row operations still throw normally.\n */\n emptyState?: Locator;\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 /**\n * The row's logical/data-model index. When a `resolveRowIndex` strategy is configured\n * (e.g. MUI DataGrid's `data-rowindex`) this is the grid's true row index; otherwise it\n * equals `index`. Use this for `row.bringIntoView()` and position math on virtualized\n * tables \u2014 it is stable across scrolling/dedupe, unlike the visit-order `index`.\n */\n rowIndex: number;\n /**\n * 0-based enumeration counter \u2014 the order this row was visited (contiguous within the run).\n * Not a DOM position or grid identity. Use `rowIndex` for the row's data-model index.\n */\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 /**\n * SYNC: Returns true if init() resolved via the emptyState path \u2014 the table's\n * empty-state locator was visible when header resolution failed.\n * Row operations still throw normally; use this to branch before calling them.\n */\n isEmpty(): 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 sync path cannot compute a real `rowIndex`, so the returned SmartRow's\n * `rowIndex` is `undefined` (virtual-scroll positioning via `bringIntoView()` is limited).\n * Use `findRow()` (async) when you need a row with an accurate `rowIndex`.\n */\n getRow: (\n filters: Record<string, FilterValue>,\n options?: { exact?: boolean }\n ) => SmartRow<T>;\n\n /**\n * Gets a row by its 0-based position in the currently-rendered DOM (sync, no scroll).\n * Throws if the table is not initialized.\n *\n * For button-paginated tables this is the i-th row on the current page. For virtualized\n * tables the render window shifts as you scroll, so `getRowByIndex(i)` returns whatever\n * row currently sits at DOM position `i` \u2014 NOT the logical/absolute row `i` in the dataset\n * once the list has scrolled. For the row with a specific logical/data-model index on a\n * virtualized table, use the async `findRowByIndex(i)` instead (it scrolls to the row);\n * to iterate by logical identity, use `map` / `findRows` (with a `dedupe` strategy).\n *\n * Resolution is lazy: an out-of-range index yields a SmartRow whose operations fail when\n * it is used, rather than throwing here.\n *\n * @param index 0-based position within the current render window\n */\n getRowByIndex: (\n index: number\n ) => SmartRow<T>;\n\n /**\n * ASYNC: Returns the row with a specific logical/data-model index, scrolling/paginating to\n * reach it. Unlike the sync `getRowByIndex` (render-window position), this resolves the true\n * data-model row `index` on virtualized tables.\n *\n * Reaches the row via, in order: a currently-mounted match, the viewport's random-access\n * `scrollToRow` fast path, then advancing pages (on infinite-scroll tables a \"page\" is a\n * scroll step) up to `maxPages`.\n *\n * Requires a `strategies.resolveRowIndex` to identify rows by logical index \u2014 throws if one\n * is not configured. Also throws if the row cannot be reached (no silent wrong-row fallback).\n *\n * @param index 0-based logical/data-model row index\n * @param options - `maxPages` bounds how far to scroll/paginate (defaults to config.maxPages)\n */\n findRowByIndex: (\n index: number,\n options?: { maxPages?: number }\n ) => Promise<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 (exact, maxPages). `useBulkPagination` defaults to `false`: pages advance one at a time via `goNext` so no intermediate page is skipped. Set it to `true` to opt into `goNextBulk` (faster, but skips the rows on jumped-over 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, optionally filtered.\n * Without arguments, counts all rows. With filters, counts only matching rows.\n * Paginates when pagination is configured.\n */\n countRows: (filters?: Record<string, FilterValue>, options?: { exact?: boolean; maxPages?: number }) => 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: calls goToFirst (if configured), clears cache, re-inits headers, then calls onReset.\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 * Shorthand for `map()` + `reset()`. Iterates every row across all pages, applies the\n * callback (defaults to `row.toJSON()`), then resets the table back to page 1 \u2014 even if\n * the callback throws.\n *\n * @param callback - Optional map function. Defaults to `({ row }) => row.toJSON()`.\n * @param options - Same options as `map()`.\n *\n * @example\n * // Zero-arg: returns toJSON() for every row\n * const rows = await table.toArray();\n *\n * @example\n * // Custom callback\n * const names = await table.toArray(({ row }) => row.getCell('Name').innerText());\n *\n * @example\n * // With options\n * const rows = await table.toArray(({ row }) => row.toJSON(), { concurrency: 'parallel' });\n */\n toArray<R = Record<string, unknown>>(\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 * Return type for `resolveRowIndex`. A plain number gives the logical index only;\n * `{ index, selector }` additionally provides a CSS selector the library uses to\n * build a self-healing row locator that survives virtual-scroll DOM recycling.\n */\nexport type RowIndexResult = number | { index: number; selector: string };\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 DOM positions (0-based, document order \u2014 indices into the resolved\n * `rowSelector` set) of rows currently within the scroll container's visible bounds.\n * Unlike `getVisibleRowRange` (a logical min/max), this identifies the exact rows, so\n * `map`/`forEach`/`filter` can skip overscan rows during collection (see #353 / #357).\n * Geometry-based and inclusive (any overlap counts as visible). When the container can't\n * be measured, return all positions so no rows are filtered.\n */\n getVisibleRowIndices?: (context: TableContext) => Promise<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 * // Atomic: snapshot all cell values in a single evaluate \u2014 zero inter-column stagger.\n * // Requires cellSelector to be a CSS string (not a function).\n * // Column overrides ARE supported (run against a frozen off-screen reconstruction).\n * // Uses textContent (not layout-dependent innerText) for non-override columns.\n * const coherent = await row.toJSON({ atomic: true });\n */\n toJSON(options?: { columns?: string[]; atomic?: boolean }): 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 * Get the resolved value of any column \u2014 real, override, or synthetic.\n * @param column - Column name (case-sensitive)\n * @returns The column value as a string\n */\n getValue(column: string): Promise<string>;\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\nexport type ContentReadyStrategy = (row: Locator, page: Page) => Promise<void>;\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\n/** Context passed as the second argument to {@link ColumnOverride.read}. */\nexport interface ColumnOverrideReadContext {\n /**\n * The parent row. Use for multi-cell or row-derived values \u2014 e.g. a synthetic column\n * that reads an `a[href]` or a `data-*` attribute from the row rather than a cell:\n * `read: (_cell, { row }) => row.evaluate(el => el.querySelector('a')?.href)`.\n */\n row: SmartRow;\n /** The column being read. */\n columnName: string;\n /** The column's 0-based index in the resolved header map. */\n columnIndex: number;\n /**\n * Get a Locator for another cell in the same row by column name.\n * Returns raw cell Locators, not override-processed values.\n *\n * In atomic mode, the Locator points at the frozen reconstructed cell \u2014 coherent with\n * every other cell from the same snapshot. In non-atomic mode, it points at the live cell.\n *\n * @example\n * read: async (_cell, { getCell }) => {\n * const name = (await getCell('Name').innerText()).trim();\n * const href = await getCell('Name').locator('a').getAttribute('href') || '';\n * return `${name} | ${href}`;\n * }\n */\n getCell: (columnName: string) => Locator;\n}\n\nexport interface SyntheticColumnDef<T = any> {\n compute: (row: SmartRow<T>) => Promise<string | number> | string | number;\n}\n\nexport interface ColumnOverride<TValue = any> {\n /**\n * How to extract the value from the cell.\n * The second `context` argument provides the parent `row` (for multi-cell or row-derived\n * values), plus `columnName` and `columnIndex`. Backwards-compatible: existing\n * single-argument `read(cell)` implementations keep working.\n */\n read?: (cell: Locator, context: ColumnOverrideReadContext) => 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';\nexport type { NavigationPrimitives, CellNavigationStrategy } from './strategies/columns';\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 * Honored by findRows AND by map/forEach/filter, where the wait runs before the dedupe\n * strategy so content-based dedupe keys see the row's final loaded state.\n * When not set (backward-compatible behavior): findRows skips loading rows immediately;\n * map/forEach/filter process them as-is.\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 /** Max ms to wait for sort stabilization when isTableLoading is set. @default 10000 */\n sortStabilizationTimeout?: number;\n /** Polling interval (ms) while waiting for sort stabilization. @default 100 */\n sortStabilizationPollInterval?: number;\n /** Fallback delay (ms) after sort when no isTableLoading is configured. @default 200 */\n sortStabilizationFallbackDelay?: number;\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 * Resolve the stable data-model index for a row locator.\n *\n * Called by `findRow` / `findRows` to convert a DOM row into the index used for\n * virtual-scroll positioning. Useful for grids where DOM position resets to 0 on\n * each page while the grid itself maintains a monotone counter (e.g. MUI DataGrid's\n * `data-rowindex` attribute).\n *\n * Return `undefined` to fall back to DOM position.\n *\n * When the index maps to a DOM attribute, return `{ index, selector }` instead of\n * a plain number. The library uses the CSS selector to build a **self-healing row\n * locator** that re-queries the DOM on every action \u2014 surviving virtual-scroll\n * recycling for `getCell`, `smartFill`, and `toJSON` without manual re-pinning.\n *\n * @example\n * // MUI DataGrid: self-healing via data-rowindex attribute\n * resolveRowIndex: async (row) => {\n * const v = await row.getAttribute('data-rowindex').catch(() => null);\n * if (v === null || isNaN(Number(v))) return undefined;\n * return { index: Number(v), selector: `[data-rowindex=\"${v}\"]` };\n * }\n */\n resolveRowIndex?: (row: Locator) => Promise<RowIndexResult | undefined>;\n\n /**\n * Waits until a row's content has stabilized before cloning in\n * `toJSON({ atomic: true })`. Needed for recycling virtualizers where the\n * framework updates element positions synchronously but renders cell content\n * asynchronously (e.g. react-window, react-virtuoso with React concurrent mode).\n *\n * Without this, the clone captures stale content from the previous occupant of the\n * DOM slot \u2014 the element is at the correct position but React hasn't re-rendered yet.\n *\n * Use `Strategies.ContentReady.textStable()` for the built-in text-polling strategy.\n *\n * @example\n * strategies: {\n * contentReady: Strategies.ContentReady.textStable({ timeout: 500 }),\n * }\n */\n contentReady?: ContentReadyStrategy;\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 /** Hook called after reset completes (after goToFirst, cache clear, and autoInit). */\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 /**\n * Computed columns with no DOM presence. Each key becomes a virtual column name\n * available in `toJSON()`, `getValue()`, and `findRow()`/`findRows()` filters.\n * The `compute` function receives the full SmartRow and must only read real or\n * override columns (no chaining between synthetics).\n */\n syntheticColumns?: Record<string, SyntheticColumnDef<T>>;\n\n /**\n * Locator for an empty-state element that replaces the table when there are no results.\n * If header resolution fails during init() and this locator is visible, init() succeeds\n * and isEmpty() returns true. All row operations still throw normally.\n */\n emptyState?: Locator;\n}\n\n/**\n * @internal Resolved config after defaults are applied. Prefer {@link TableConfig} in public code.\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 /**\n * The row's logical/data-model index. When a `resolveRowIndex` strategy is configured\n * (e.g. MUI DataGrid's `data-rowindex`) this is the grid's true row index; otherwise it\n * equals `index`. Use this for `row.bringIntoView()` and position math on virtualized\n * tables \u2014 it is stable across scrolling/dedupe, unlike the visit-order `index`.\n */\n rowIndex: number;\n /**\n * 0-based enumeration counter \u2014 the order this row was visited (contiguous within the run).\n * Not a DOM position or grid identity. Use `rowIndex` for the row's data-model index.\n */\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 /**\n * SYNC: Returns true if init() resolved via the emptyState path \u2014 the table's\n * empty-state locator was visible when header resolution failed.\n * Row operations still throw normally; use this to branch before calling them.\n */\n isEmpty(): 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 sync path cannot compute a real `rowIndex`, so the returned SmartRow's\n * `rowIndex` is `undefined` (virtual-scroll positioning via `bringIntoView()` is limited).\n * Use `findRow()` (async) when you need a row with an accurate `rowIndex`.\n * @note Cannot filter by `syntheticColumns` or `columnOverrides.read` keys \u2014 those need\n * async evaluation via `findRow()` / `findRows()`. DOM filters use `strategies.getCellLocator`\n * when configured (column-virtualized grids), otherwise `cellSelector` + column index.\n */\n getRow: (\n filters: Record<string, FilterValue>,\n options?: { exact?: boolean }\n ) => SmartRow<T>;\n\n /**\n * Gets a row by its 0-based position in the currently-rendered DOM (sync, no scroll).\n * Throws if the table is not initialized.\n *\n * For button-paginated tables this is the i-th row on the current page. For virtualized\n * tables the render window shifts as you scroll, so `getRowByIndex(i)` returns whatever\n * row currently sits at DOM position `i` \u2014 NOT the logical/absolute row `i` in the dataset\n * once the list has scrolled. For the row with a specific logical/data-model index on a\n * virtualized table, use the async `findRowByIndex(i)` instead (it scrolls to the row);\n * to iterate by logical identity, use `map` / `findRows` (with a `dedupe` strategy).\n *\n * Resolution is lazy: an out-of-range index yields a SmartRow whose operations fail when\n * it is used, rather than throwing here.\n *\n * @param index 0-based position within the current render window\n */\n getRowByIndex: (\n index: number\n ) => SmartRow<T>;\n\n /**\n * ASYNC: Returns the row with a specific logical/data-model index, scrolling/paginating to\n * reach it. Unlike the sync `getRowByIndex` (render-window position), this resolves the true\n * data-model row `index` on virtualized tables.\n *\n * Reaches the row via, in order: a currently-mounted match, the viewport's random-access\n * `scrollToRow` fast path, then advancing pages (on infinite-scroll tables a \"page\" is a\n * scroll step) up to `maxPages`.\n *\n * Requires a `strategies.resolveRowIndex` to identify rows by logical index \u2014 throws if one\n * is not configured. Also throws if the row cannot be reached (no silent wrong-row fallback).\n *\n * @param index 0-based logical/data-model row index\n * @param options - `maxPages` bounds how far to scroll/paginate (defaults to config.maxPages)\n */\n findRowByIndex: (\n index: number,\n options?: { maxPages?: number }\n ) => Promise<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 (exact, maxPages). `useBulkPagination` defaults to `false`: pages advance one at a time via `goNext` so no intermediate page is skipped. Set it to `true` to opt into `goNextBulk` (faster, but skips the rows on jumped-over pages).\n */\n findRows: (\n filters?: Record<string, FilterValue>,\n options?: { exact?: boolean, maxPages?: number, useBulkPagination?: boolean }\n ) => Promise<SmartRowArray<T>>;\n\n /**\n * Resolves the named column and scrolls its header cell into view.\n */\n scrollToColumn: (columnName: string) => Promise<void>;\n\n /**\n * Counts the number of rows, optionally filtered.\n * Without arguments, counts all rows. With filters, counts only matching rows.\n * Paginates when pagination is configured.\n */\n countRows: (filters?: Record<string, FilterValue>, options?: { exact?: boolean; maxPages?: number }) => 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 * @deprecated Use `mapColumn` (or `map`) instead. Will be removed in v7.0.0.\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: calls goToFirst (if configured), clears cache, re-inits headers, then calls onReset.\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 * Shorthand for `map()` + `reset()`. Iterates every row across all pages, applies the\n * callback (defaults to `row.toJSON()`), then resets the table back to page 1 \u2014 even if\n * the callback throws.\n *\n * @param callback - Optional map function. Defaults to `({ row }) => row.toJSON()`.\n * @param options - Same options as `map()`.\n *\n * @example\n * // Zero-arg: returns toJSON() for every row\n * const rows = await table.toArray();\n *\n * @example\n * // Custom callback\n * const names = await table.toArray(({ row }) => row.getCell('Name').innerText());\n *\n * @example\n * // With options\n * const rows = await table.toArray(({ row }) => row.toJSON(), { concurrency: 'parallel' });\n */\n toArray<R = Record<string, unknown>>(\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
|
@@ -511,6 +511,7 @@ export interface ColumnOverride<TValue = any> {
|
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
export type { HeaderStrategy } from './strategies/headers';
|
|
514
|
+
export type { NavigationPrimitives, CellNavigationStrategy } from './strategies/columns';
|
|
514
515
|
|
|
515
516
|
/**
|
|
516
517
|
* Strategy to resolve column names (string or regex) to their index.
|
|
@@ -735,6 +736,9 @@ export interface TableConfig<T = any> {
|
|
|
735
736
|
emptyState?: Locator;
|
|
736
737
|
}
|
|
737
738
|
|
|
739
|
+
/**
|
|
740
|
+
* @internal Resolved config after defaults are applied. Prefer {@link TableConfig} in public code.
|
|
741
|
+
*/
|
|
738
742
|
export interface FinalTableConfig<T = any> extends TableConfig<T> {
|
|
739
743
|
headerSelector: string | ((root: Locator) => Locator);
|
|
740
744
|
rowSelector: string;
|
|
@@ -841,6 +845,9 @@ export interface TableResult<T = any> extends AsyncIterable<{ row: SmartRow<T>;
|
|
|
841
845
|
* @note The sync path cannot compute a real \`rowIndex\`, so the returned SmartRow's
|
|
842
846
|
* \`rowIndex\` is \`undefined\` (virtual-scroll positioning via \`bringIntoView()\` is limited).
|
|
843
847
|
* Use \`findRow()\` (async) when you need a row with an accurate \`rowIndex\`.
|
|
848
|
+
* @note Cannot filter by \`syntheticColumns\` or \`columnOverrides.read\` keys — those need
|
|
849
|
+
* async evaluation via \`findRow()\` / \`findRows()\`. DOM filters use \`strategies.getCellLocator\`
|
|
850
|
+
* when configured (column-virtualized grids), otherwise \`cellSelector\` + column index.
|
|
844
851
|
*/
|
|
845
852
|
getRow: (
|
|
846
853
|
filters: Record<string, FilterValue>,
|
|
@@ -910,7 +917,7 @@ export interface TableResult<T = any> extends AsyncIterable<{ row: SmartRow<T>;
|
|
|
910
917
|
) => Promise<SmartRowArray<T>>;
|
|
911
918
|
|
|
912
919
|
/**
|
|
913
|
-
*
|
|
920
|
+
* Resolves the named column and scrolls its header cell into view.
|
|
914
921
|
*/
|
|
915
922
|
scrollToColumn: (columnName: string) => Promise<void>;
|
|
916
923
|
|
|
@@ -930,6 +937,7 @@ export interface TableResult<T = any> extends AsyncIterable<{ row: SmartRow<T>;
|
|
|
930
937
|
mapColumn<R = string>(columnName: string, options?: RowIterationOptions): Promise<R[]>;
|
|
931
938
|
|
|
932
939
|
/**
|
|
940
|
+
* @deprecated Use \`mapColumn\` (or \`map\`) instead. Will be removed in v7.0.0.
|
|
933
941
|
* Iterates over rows and extracts the value of a single column as strings.
|
|
934
942
|
* @param columnName - The name of the column to extract
|
|
935
943
|
* @param options - Iteration options
|
package/dist/types.d.ts
CHANGED
|
@@ -468,6 +468,7 @@ export interface ColumnOverride<TValue = any> {
|
|
|
468
468
|
import { HeaderStrategy } from './strategies/headers';
|
|
469
469
|
export type { HeaderStrategy } from './strategies/headers';
|
|
470
470
|
import { NavigationPrimitives } from './strategies/columns';
|
|
471
|
+
export type { NavigationPrimitives, CellNavigationStrategy } from './strategies/columns';
|
|
471
472
|
/**
|
|
472
473
|
* Strategy to resolve column names (string or regex) to their index.
|
|
473
474
|
*/
|
|
@@ -675,6 +676,9 @@ export interface TableConfig<T = any> {
|
|
|
675
676
|
*/
|
|
676
677
|
emptyState?: Locator;
|
|
677
678
|
}
|
|
679
|
+
/**
|
|
680
|
+
* @internal Resolved config after defaults are applied. Prefer {@link TableConfig} in public code.
|
|
681
|
+
*/
|
|
678
682
|
export interface FinalTableConfig<T = any> extends TableConfig<T> {
|
|
679
683
|
headerSelector: string | ((root: Locator) => Locator);
|
|
680
684
|
rowSelector: string;
|
|
@@ -780,6 +784,9 @@ export interface TableResult<T = any> extends AsyncIterable<{
|
|
|
780
784
|
* @note The sync path cannot compute a real `rowIndex`, so the returned SmartRow's
|
|
781
785
|
* `rowIndex` is `undefined` (virtual-scroll positioning via `bringIntoView()` is limited).
|
|
782
786
|
* Use `findRow()` (async) when you need a row with an accurate `rowIndex`.
|
|
787
|
+
* @note Cannot filter by `syntheticColumns` or `columnOverrides.read` keys — those need
|
|
788
|
+
* async evaluation via `findRow()` / `findRows()`. DOM filters use `strategies.getCellLocator`
|
|
789
|
+
* when configured (column-virtualized grids), otherwise `cellSelector` + column index.
|
|
783
790
|
*/
|
|
784
791
|
getRow: (filters: Record<string, FilterValue>, options?: {
|
|
785
792
|
exact?: boolean;
|
|
@@ -841,7 +848,7 @@ export interface TableResult<T = any> extends AsyncIterable<{
|
|
|
841
848
|
useBulkPagination?: boolean;
|
|
842
849
|
}) => Promise<SmartRowArray<T>>;
|
|
843
850
|
/**
|
|
844
|
-
*
|
|
851
|
+
* Resolves the named column and scrolls its header cell into view.
|
|
845
852
|
*/
|
|
846
853
|
scrollToColumn: (columnName: string) => Promise<void>;
|
|
847
854
|
/**
|
|
@@ -861,6 +868,7 @@ export interface TableResult<T = any> extends AsyncIterable<{
|
|
|
861
868
|
*/
|
|
862
869
|
mapColumn<R = string>(columnName: string, options?: RowIterationOptions): Promise<R[]>;
|
|
863
870
|
/**
|
|
871
|
+
* @deprecated Use `mapColumn` (or `map`) instead. Will be removed in v7.0.0.
|
|
864
872
|
* Iterates over rows and extracts the value of a single column as strings.
|
|
865
873
|
* @param columnName - The name of the column to extract
|
|
866
874
|
* @param options - Iteration options
|
package/dist/useTable.js
CHANGED
|
@@ -437,6 +437,10 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
437
437
|
return (text || '').trim();
|
|
438
438
|
}, options);
|
|
439
439
|
},
|
|
440
|
+
/**
|
|
441
|
+
* @deprecated Use `mapColumn` (or `map`) instead. Will be removed in v7.0.0.
|
|
442
|
+
* Iterates over rows and extracts the value of a single column as strings.
|
|
443
|
+
*/
|
|
440
444
|
getColumnValues: async (columnName, options = {}) => {
|
|
441
445
|
log(`getColumnValues: column="${columnName}" options=${safeStringify(options)}`);
|
|
442
446
|
const values = await result.mapColumn(columnName, options);
|
|
@@ -472,6 +476,11 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
472
476
|
throw new Error(`getRow() cannot filter by synthetic column(s): ${syntheticKeys.join(', ')}. ` +
|
|
473
477
|
`Use findRow() instead — synthetic columns require async evaluation.`);
|
|
474
478
|
}
|
|
479
|
+
const overrideKeys = Object.keys(filters).filter(k => { var _a, _b; return (_b = (_a = config.columnOverrides) === null || _a === void 0 ? void 0 : _a[k]) === null || _b === void 0 ? void 0 : _b.read; });
|
|
480
|
+
if (overrideKeys.length > 0) {
|
|
481
|
+
throw new Error(`getRow() cannot filter by columnOverrides.read column(s): ${overrideKeys.join(', ')}. ` +
|
|
482
|
+
`Use findRow() instead — override columns require async evaluation.`);
|
|
483
|
+
}
|
|
475
484
|
const map = tableMapper.getMapSync();
|
|
476
485
|
if (!map)
|
|
477
486
|
throw new Error('Initialization Error: You attempted to access a row before the table structure was mapped. Please call "await table.init()" once before using synchronous row access.');
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Locator, Page } from '@playwright/test';
|
|
2
|
+
import type { FinalTableConfig, Selector } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a cell locator for a concrete row — prefers `strategies.getCellLocator`,
|
|
5
|
+
* otherwise `cellSelector` + `.nth(columnIndex)`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveCellLocator(args: {
|
|
8
|
+
config: FinalTableConfig;
|
|
9
|
+
resolve: (selector: Selector, parent: Locator | Page) => Locator;
|
|
10
|
+
row: Locator;
|
|
11
|
+
root: Locator;
|
|
12
|
+
columnName: string;
|
|
13
|
+
columnIndex: number;
|
|
14
|
+
rowIndex?: number;
|
|
15
|
+
page?: Page;
|
|
16
|
+
}): Locator;
|
|
17
|
+
/**
|
|
18
|
+
* Cell locator for Playwright `rows.filter({ has })`.
|
|
19
|
+
*
|
|
20
|
+
* When `getCellLocator` is set, pass `page.locator(':scope')` as the row so the
|
|
21
|
+
* strategy's `row.locator(...)` chain stays relative to each candidate row under
|
|
22
|
+
* `filter({ has })`. Using the rows collection or a document-rooted parent nests
|
|
23
|
+
* the row selector and matches nothing.
|
|
24
|
+
*
|
|
25
|
+
* Without `getCellLocator`, keeps the historical page-scoped `cellSelector.nth(i)`
|
|
26
|
+
* template that Playwright re-bases into each row.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveCellLocatorForFilter(args: {
|
|
29
|
+
config: FinalTableConfig;
|
|
30
|
+
resolve: (selector: Selector, parent: Locator | Page) => Locator;
|
|
31
|
+
page: Page;
|
|
32
|
+
root?: Locator;
|
|
33
|
+
columnName: string;
|
|
34
|
+
columnIndex: number;
|
|
35
|
+
}): Locator;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveCellLocator = resolveCellLocator;
|
|
4
|
+
exports.resolveCellLocatorForFilter = resolveCellLocatorForFilter;
|
|
5
|
+
/**
|
|
6
|
+
* Resolve a cell locator for a concrete row — prefers `strategies.getCellLocator`,
|
|
7
|
+
* otherwise `cellSelector` + `.nth(columnIndex)`.
|
|
8
|
+
*/
|
|
9
|
+
function resolveCellLocator(args) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const { config, resolve, row, root, columnName, columnIndex, rowIndex } = args;
|
|
12
|
+
const page = (_a = args.page) !== null && _a !== void 0 ? _a : root.page();
|
|
13
|
+
if ((_b = config.strategies) === null || _b === void 0 ? void 0 : _b.getCellLocator) {
|
|
14
|
+
return config.strategies.getCellLocator({
|
|
15
|
+
row,
|
|
16
|
+
root,
|
|
17
|
+
columnName,
|
|
18
|
+
columnIndex,
|
|
19
|
+
rowIndex,
|
|
20
|
+
page,
|
|
21
|
+
config,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return resolve(config.cellSelector, row).nth(columnIndex);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Cell locator for Playwright `rows.filter({ has })`.
|
|
28
|
+
*
|
|
29
|
+
* When `getCellLocator` is set, pass `page.locator(':scope')` as the row so the
|
|
30
|
+
* strategy's `row.locator(...)` chain stays relative to each candidate row under
|
|
31
|
+
* `filter({ has })`. Using the rows collection or a document-rooted parent nests
|
|
32
|
+
* the row selector and matches nothing.
|
|
33
|
+
*
|
|
34
|
+
* Without `getCellLocator`, keeps the historical page-scoped `cellSelector.nth(i)`
|
|
35
|
+
* template that Playwright re-bases into each row.
|
|
36
|
+
*/
|
|
37
|
+
function resolveCellLocatorForFilter(args) {
|
|
38
|
+
var _a;
|
|
39
|
+
const { config, resolve, page, root, columnName, columnIndex } = args;
|
|
40
|
+
if ((_a = config.strategies) === null || _a === void 0 ? void 0 : _a.getCellLocator) {
|
|
41
|
+
const scopeRow = page.locator(':scope');
|
|
42
|
+
return config.strategies.getCellLocator({
|
|
43
|
+
row: scopeRow,
|
|
44
|
+
root: root !== null && root !== void 0 ? root : scopeRow,
|
|
45
|
+
columnName,
|
|
46
|
+
columnIndex,
|
|
47
|
+
page,
|
|
48
|
+
config,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return resolve(config.cellSelector, page).nth(columnIndex);
|
|
52
|
+
}
|
package/package.json
CHANGED