@rickcedwhat/playwright-smart-table 6.1.0 → 6.1.1
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/{examples/glide-strategies → strategies/glide}/columns.d.ts +1 -1
- package/dist/{examples/glide-strategies → strategies/glide}/headers.d.ts +1 -1
- package/dist/{src/strategies → strategies}/glide.js +2 -2
- package/dist/strategies/index.d.ts +29 -2
- package/dist/strategies/index.js +6 -0
- package/dist/strategies/pagination.d.ts +26 -4
- package/dist/strategies/pagination.js +52 -23
- package/dist/typeContext.d.ts +1 -1
- package/dist/typeContext.js +28 -4
- package/dist/types.d.ts +33 -2
- package/dist/useTable.d.ts +28 -3
- package/dist/useTable.js +92 -36
- package/package.json +1 -1
- package/dist/src/filterEngine.d.ts +0 -11
- package/dist/src/filterEngine.js +0 -39
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -18
- package/dist/src/smartRow.d.ts +0 -7
- package/dist/src/smartRow.js +0 -160
- package/dist/src/strategies/columns.d.ts +0 -18
- package/dist/src/strategies/columns.js +0 -21
- package/dist/src/strategies/fill.d.ts +0 -7
- package/dist/src/strategies/fill.js +0 -88
- package/dist/src/strategies/headers.d.ts +0 -13
- package/dist/src/strategies/headers.js +0 -30
- package/dist/src/strategies/index.d.ts +0 -54
- package/dist/src/strategies/index.js +0 -43
- package/dist/src/strategies/pagination.d.ts +0 -33
- package/dist/src/strategies/pagination.js +0 -79
- package/dist/src/strategies/resolution.d.ts +0 -22
- package/dist/src/strategies/resolution.js +0 -30
- package/dist/src/strategies/sorting.d.ts +0 -12
- package/dist/src/strategies/sorting.js +0 -68
- package/dist/src/strategies/validation.d.ts +0 -22
- package/dist/src/strategies/validation.js +0 -54
- package/dist/src/strategies/virtualizedPagination.d.ts +0 -32
- package/dist/src/strategies/virtualizedPagination.js +0 -80
- package/dist/src/typeContext.d.ts +0 -6
- package/dist/src/typeContext.js +0 -465
- package/dist/src/types.d.ts +0 -458
- package/dist/src/types.js +0 -2
- package/dist/src/useTable.d.ts +0 -44
- package/dist/src/useTable.js +0 -641
- package/dist/src/utils/debugUtils.d.ts +0 -17
- package/dist/src/utils/debugUtils.js +0 -62
- package/dist/src/utils/smartRowArray.d.ts +0 -14
- package/dist/src/utils/smartRowArray.js +0 -22
- package/dist/src/utils/stringUtils.d.ts +0 -22
- package/dist/src/utils/stringUtils.js +0 -73
- package/dist/src/utils.d.ts +0 -7
- package/dist/src/utils.js +0 -29
- package/dist/utils/traceUtils.d.ts +0 -11
- package/dist/utils/traceUtils.js +0 -47
- /package/dist/{src/plugins.d.ts → plugins.d.ts} +0 -0
- /package/dist/{src/plugins.js → plugins.js} +0 -0
- /package/dist/{src/strategies → strategies}/dedupe.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/dedupe.js +0 -0
- /package/dist/{examples/glide-strategies → strategies/glide}/columns.js +0 -0
- /package/dist/{examples/glide-strategies → strategies/glide}/headers.js +0 -0
- /package/dist/{src/strategies → strategies}/glide.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/loading.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/loading.js +0 -0
- /package/dist/{src/strategies → strategies}/rdg.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/rdg.js +0 -0
- /package/dist/{src/strategies → strategies}/stabilization.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/stabilization.js +0 -0
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FillStrategies = void 0;
|
|
13
|
-
exports.FillStrategies = {
|
|
14
|
-
/**
|
|
15
|
-
* Default strategy: Detects input type and fills accordingly (Text, Select, Checkbox, ContentEditable).
|
|
16
|
-
*/
|
|
17
|
-
default: (_a) => __awaiter(void 0, [_a], void 0, function* ({ row, columnName, value, fillOptions }) {
|
|
18
|
-
var _b;
|
|
19
|
-
const cell = row.getCell(columnName);
|
|
20
|
-
// Use custom input mapper for this column if provided, otherwise auto-detect
|
|
21
|
-
let inputLocator;
|
|
22
|
-
if ((_b = fillOptions === null || fillOptions === void 0 ? void 0 : fillOptions.inputMappers) === null || _b === void 0 ? void 0 : _b[columnName]) {
|
|
23
|
-
inputLocator = fillOptions.inputMappers[columnName](cell);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// Auto-detect input type
|
|
27
|
-
// Check for text input
|
|
28
|
-
const textInput = cell.locator('input[type="text"], input:not([type]), textarea').first();
|
|
29
|
-
const textInputCount = yield textInput.count().catch(() => 0);
|
|
30
|
-
// Check for select
|
|
31
|
-
const select = cell.locator('select').first();
|
|
32
|
-
const selectCount = yield select.count().catch(() => 0);
|
|
33
|
-
// Check for checkbox/radio
|
|
34
|
-
const checkbox = cell.locator('input[type="checkbox"], input[type="radio"], [role="checkbox"]').first();
|
|
35
|
-
const checkboxCount = yield checkbox.count().catch(() => 0);
|
|
36
|
-
// Check for contenteditable or div-based inputs
|
|
37
|
-
const contentEditable = cell.locator('[contenteditable="true"]').first();
|
|
38
|
-
const contentEditableCount = yield contentEditable.count().catch(() => 0);
|
|
39
|
-
// Determine which input to use (prioritize by commonality)
|
|
40
|
-
if (textInputCount > 0 && selectCount === 0 && checkboxCount === 0) {
|
|
41
|
-
inputLocator = textInput;
|
|
42
|
-
}
|
|
43
|
-
else if (selectCount > 0) {
|
|
44
|
-
inputLocator = select;
|
|
45
|
-
}
|
|
46
|
-
else if (checkboxCount > 0) {
|
|
47
|
-
inputLocator = checkbox;
|
|
48
|
-
}
|
|
49
|
-
else if (contentEditableCount > 0) {
|
|
50
|
-
inputLocator = contentEditable;
|
|
51
|
-
}
|
|
52
|
-
else if (textInputCount > 0) {
|
|
53
|
-
// Fallback to text input even if others exist
|
|
54
|
-
inputLocator = textInput;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// No input found - try to click the cell itself (might trigger an editor)
|
|
58
|
-
inputLocator = cell;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Fill based on value type and input type
|
|
62
|
-
const inputTag = yield inputLocator.evaluate((el) => el.tagName.toLowerCase()).catch(() => 'unknown');
|
|
63
|
-
const inputType = yield inputLocator.getAttribute('type').catch(() => null);
|
|
64
|
-
const isContentEditable = yield inputLocator.getAttribute('contenteditable').catch(() => null);
|
|
65
|
-
// console.log(`[SmartTable] Filling "${columnName}" with value "${value}" (input: ${inputTag}, type: ${inputType})`);
|
|
66
|
-
if (inputType === 'checkbox' || inputType === 'radio') {
|
|
67
|
-
// Boolean value for checkbox/radio
|
|
68
|
-
const shouldBeChecked = Boolean(value);
|
|
69
|
-
const isChecked = yield inputLocator.isChecked().catch(() => false);
|
|
70
|
-
if (isChecked !== shouldBeChecked) {
|
|
71
|
-
yield inputLocator.click();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else if (inputTag === 'select') {
|
|
75
|
-
// Select dropdown
|
|
76
|
-
yield inputLocator.selectOption(String(value));
|
|
77
|
-
}
|
|
78
|
-
else if (isContentEditable === 'true') {
|
|
79
|
-
// Contenteditable div
|
|
80
|
-
yield inputLocator.click();
|
|
81
|
-
yield inputLocator.fill(String(value));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
// Text input, textarea, or generic
|
|
85
|
-
yield inputLocator.fill(String(value));
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StrategyContext } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Defines the contract for a header retrieval strategy.
|
|
4
|
-
* Returns a list of unique header names found in the table.
|
|
5
|
-
*/
|
|
6
|
-
export type HeaderStrategy = (context: StrategyContext) => Promise<string[]>;
|
|
7
|
-
export declare const HeaderStrategies: {
|
|
8
|
-
/**
|
|
9
|
-
* Default strategy: Returns only the headers currently visible in the DOM.
|
|
10
|
-
* This is fast but won't find virtualized columns off-screen.
|
|
11
|
-
*/
|
|
12
|
-
visible: ({ config, resolve, root }: StrategyContext) => Promise<string[]>;
|
|
13
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HeaderStrategies = void 0;
|
|
13
|
-
exports.HeaderStrategies = {
|
|
14
|
-
/**
|
|
15
|
-
* Default strategy: Returns only the headers currently visible in the DOM.
|
|
16
|
-
* This is fast but won't find virtualized columns off-screen.
|
|
17
|
-
*/
|
|
18
|
-
visible: (_a) => __awaiter(void 0, [_a], void 0, function* ({ config, resolve, root }) {
|
|
19
|
-
const headerLoc = resolve(config.headerSelector, root);
|
|
20
|
-
try {
|
|
21
|
-
// Wait for at least one header to be visible
|
|
22
|
-
yield headerLoc.first().waitFor({ state: 'visible', timeout: 3000 });
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
// Ignore hydration/timeout issues, return what we have
|
|
26
|
-
}
|
|
27
|
-
const texts = yield headerLoc.allInnerTexts();
|
|
28
|
-
return texts.map(t => t.trim());
|
|
29
|
-
})
|
|
30
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export * from './pagination';
|
|
2
|
-
export * from './sorting';
|
|
3
|
-
export * from './columns';
|
|
4
|
-
export * from './headers';
|
|
5
|
-
export * from './fill';
|
|
6
|
-
export * from './resolution';
|
|
7
|
-
export * from './dedupe';
|
|
8
|
-
export * from './loading';
|
|
9
|
-
export declare const Strategies: {
|
|
10
|
-
Pagination: {
|
|
11
|
-
clickNext: (nextButtonSelector: import("..").Selector, options?: {
|
|
12
|
-
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
13
|
-
timeout?: number;
|
|
14
|
-
}) => import("..").PaginationStrategy;
|
|
15
|
-
infiniteScroll: (options?: {
|
|
16
|
-
action?: "scroll" | "js-scroll";
|
|
17
|
-
scrollTarget?: import("..").Selector;
|
|
18
|
-
scrollAmount?: number;
|
|
19
|
-
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
20
|
-
timeout?: number;
|
|
21
|
-
}) => import("..").PaginationStrategy;
|
|
22
|
-
};
|
|
23
|
-
Sorting: {
|
|
24
|
-
AriaSort: () => import("..").SortingStrategy;
|
|
25
|
-
};
|
|
26
|
-
CellNavigation: {
|
|
27
|
-
default: () => Promise<void>;
|
|
28
|
-
};
|
|
29
|
-
Header: {
|
|
30
|
-
visible: ({ config, resolve, root }: import("..").StrategyContext) => Promise<string[]>;
|
|
31
|
-
};
|
|
32
|
-
Fill: {
|
|
33
|
-
default: ({ row, columnName, value, fillOptions }: Parameters<import("..").FillStrategy>[0]) => Promise<void>;
|
|
34
|
-
};
|
|
35
|
-
Resolution: {
|
|
36
|
-
default: import("./resolution").ColumnResolutionStrategy;
|
|
37
|
-
};
|
|
38
|
-
Dedupe: {
|
|
39
|
-
byTopPosition: (tolerance?: number) => import("..").DedupeStrategy;
|
|
40
|
-
};
|
|
41
|
-
Loading: {
|
|
42
|
-
Table: {
|
|
43
|
-
hasSpinner: (selector?: string) => ({ root }: import("..").TableContext) => Promise<boolean>;
|
|
44
|
-
custom: (fn: (context: import("..").TableContext) => Promise<boolean>) => (context: import("..").TableContext) => Promise<boolean>;
|
|
45
|
-
never: () => Promise<boolean>;
|
|
46
|
-
};
|
|
47
|
-
Row: {
|
|
48
|
-
hasClass: (className?: string) => (row: import("..").SmartRow) => Promise<boolean>;
|
|
49
|
-
hasText: (text?: string | RegExp) => (row: import("..").SmartRow) => Promise<boolean>;
|
|
50
|
-
hasEmptyCells: () => (row: import("..").SmartRow) => Promise<boolean>;
|
|
51
|
-
never: () => Promise<boolean>;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Strategies = void 0;
|
|
18
|
-
const pagination_1 = require("./pagination");
|
|
19
|
-
const sorting_1 = require("./sorting");
|
|
20
|
-
const columns_1 = require("./columns");
|
|
21
|
-
const headers_1 = require("./headers");
|
|
22
|
-
const fill_1 = require("./fill");
|
|
23
|
-
const resolution_1 = require("./resolution");
|
|
24
|
-
const dedupe_1 = require("./dedupe");
|
|
25
|
-
const loading_1 = require("./loading");
|
|
26
|
-
__exportStar(require("./pagination"), exports);
|
|
27
|
-
__exportStar(require("./sorting"), exports);
|
|
28
|
-
__exportStar(require("./columns"), exports);
|
|
29
|
-
__exportStar(require("./headers"), exports);
|
|
30
|
-
__exportStar(require("./fill"), exports);
|
|
31
|
-
__exportStar(require("./resolution"), exports);
|
|
32
|
-
__exportStar(require("./dedupe"), exports);
|
|
33
|
-
__exportStar(require("./loading"), exports);
|
|
34
|
-
exports.Strategies = {
|
|
35
|
-
Pagination: pagination_1.PaginationStrategies,
|
|
36
|
-
Sorting: sorting_1.SortingStrategies,
|
|
37
|
-
CellNavigation: columns_1.CellNavigationStrategies,
|
|
38
|
-
Header: headers_1.HeaderStrategies,
|
|
39
|
-
Fill: fill_1.FillStrategies,
|
|
40
|
-
Resolution: resolution_1.ResolutionStrategies,
|
|
41
|
-
Dedupe: dedupe_1.DedupeStrategies,
|
|
42
|
-
Loading: loading_1.LoadingStrategies,
|
|
43
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { PaginationStrategy, Selector } from '../types';
|
|
2
|
-
import { StabilizationStrategy } from './stabilization';
|
|
3
|
-
export declare const PaginationStrategies: {
|
|
4
|
-
/**
|
|
5
|
-
* Strategy: Clicks a "Next" button and waits for stabilization.
|
|
6
|
-
* @param nextButtonSelector Selector for the next page button.
|
|
7
|
-
* @param options.stabilization Strategy to determine when the page has updated.
|
|
8
|
-
* Defaults to `contentChanged({ scope: 'first' })`.
|
|
9
|
-
* @param options.timeout Timeout for the click action.
|
|
10
|
-
*/
|
|
11
|
-
clickNext: (nextButtonSelector: Selector, options?: {
|
|
12
|
-
stabilization?: StabilizationStrategy;
|
|
13
|
-
timeout?: number;
|
|
14
|
-
}) => PaginationStrategy;
|
|
15
|
-
/**
|
|
16
|
-
* Strategy: Infinite Scroll (generic).
|
|
17
|
-
* Supports both simple "Scroll to Bottom" and "Virtualized Scroll".
|
|
18
|
-
*
|
|
19
|
-
* @param options.action 'scroll' (mouse wheel) or 'js-scroll' (direct scrollTop).
|
|
20
|
-
* @param options.scrollTarget Selector for the scroll container (defaults to table root).
|
|
21
|
-
* @param options.scrollAmount Amount to scroll in pixels (default 500).
|
|
22
|
-
* @param options.stabilization Strategy to determine if new content loaded.
|
|
23
|
-
* Defaults to `rowCountIncreased` (simple append).
|
|
24
|
-
* Use `contentChanged` for virtualization.
|
|
25
|
-
*/
|
|
26
|
-
infiniteScroll: (options?: {
|
|
27
|
-
action?: "scroll" | "js-scroll";
|
|
28
|
-
scrollTarget?: Selector;
|
|
29
|
-
scrollAmount?: number;
|
|
30
|
-
stabilization?: StabilizationStrategy;
|
|
31
|
-
timeout?: number;
|
|
32
|
-
}) => PaginationStrategy;
|
|
33
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PaginationStrategies = void 0;
|
|
13
|
-
const stabilization_1 = require("./stabilization");
|
|
14
|
-
exports.PaginationStrategies = {
|
|
15
|
-
/**
|
|
16
|
-
* Strategy: Clicks a "Next" button and waits for stabilization.
|
|
17
|
-
* @param nextButtonSelector Selector for the next page button.
|
|
18
|
-
* @param options.stabilization Strategy to determine when the page has updated.
|
|
19
|
-
* Defaults to `contentChanged({ scope: 'first' })`.
|
|
20
|
-
* @param options.timeout Timeout for the click action.
|
|
21
|
-
*/
|
|
22
|
-
clickNext: (nextButtonSelector, options = {}) => {
|
|
23
|
-
return (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
var _a;
|
|
25
|
-
const { root, resolve, page } = context;
|
|
26
|
-
const nextBtn = resolve(nextButtonSelector, root).first();
|
|
27
|
-
if (!(yield nextBtn.isVisible()) || !(yield nextBtn.isEnabled())) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
// Default stabilization: Wait for first row content to change
|
|
31
|
-
const stabilization = (_a = options.stabilization) !== null && _a !== void 0 ? _a : stabilization_1.StabilizationStrategies.contentChanged({ scope: 'first', timeout: options.timeout });
|
|
32
|
-
// Stabilization: Wrap action
|
|
33
|
-
const success = yield stabilization(context, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
yield nextBtn.click({ timeout: 2000 }).catch(() => { });
|
|
35
|
-
}));
|
|
36
|
-
return success;
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* Strategy: Infinite Scroll (generic).
|
|
41
|
-
* Supports both simple "Scroll to Bottom" and "Virtualized Scroll".
|
|
42
|
-
*
|
|
43
|
-
* @param options.action 'scroll' (mouse wheel) or 'js-scroll' (direct scrollTop).
|
|
44
|
-
* @param options.scrollTarget Selector for the scroll container (defaults to table root).
|
|
45
|
-
* @param options.scrollAmount Amount to scroll in pixels (default 500).
|
|
46
|
-
* @param options.stabilization Strategy to determine if new content loaded.
|
|
47
|
-
* Defaults to `rowCountIncreased` (simple append).
|
|
48
|
-
* Use `contentChanged` for virtualization.
|
|
49
|
-
*/
|
|
50
|
-
infiniteScroll: (options = {}) => {
|
|
51
|
-
return (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
const { root, resolve, page } = context;
|
|
54
|
-
const scrollTarget = options.scrollTarget
|
|
55
|
-
? resolve(options.scrollTarget, root)
|
|
56
|
-
: root;
|
|
57
|
-
// Default stabilization: Wait for row count to increase (Append mode)
|
|
58
|
-
const stabilization = (_a = options.stabilization) !== null && _a !== void 0 ? _a : stabilization_1.StabilizationStrategies.rowCountIncreased({ timeout: options.timeout });
|
|
59
|
-
const amount = (_b = options.scrollAmount) !== null && _b !== void 0 ? _b : 500;
|
|
60
|
-
const doScroll = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
-
const box = yield scrollTarget.boundingBox();
|
|
62
|
-
// Action: Scroll
|
|
63
|
-
if (options.action === 'js-scroll' || !box) {
|
|
64
|
-
yield scrollTarget.evaluate((el, y) => {
|
|
65
|
-
el.scrollTop += y;
|
|
66
|
-
}, amount);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// Mouse Wheel
|
|
70
|
-
yield page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
|
71
|
-
yield page.mouse.wheel(0, amount);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
// Stabilization: Wait
|
|
75
|
-
const success = yield stabilization(context, doScroll);
|
|
76
|
-
return success;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { StrategyContext } from '../types';
|
|
2
|
-
export interface ColumnResolutionStrategy {
|
|
3
|
-
/**
|
|
4
|
-
* Resolves a column name (string or Regex) to a column index.
|
|
5
|
-
* Returns undefined if not found.
|
|
6
|
-
*/
|
|
7
|
-
resolveIndex(options: {
|
|
8
|
-
query: string | RegExp;
|
|
9
|
-
headerMap: Map<string, number>;
|
|
10
|
-
context: StrategyContext;
|
|
11
|
-
}): number | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Resolves a column name to a clean string name (for error messages or debugging).
|
|
14
|
-
*/
|
|
15
|
-
resolveName(options: {
|
|
16
|
-
query: string | RegExp;
|
|
17
|
-
headerMap: Map<string, number>;
|
|
18
|
-
}): string;
|
|
19
|
-
}
|
|
20
|
-
export declare const ResolutionStrategies: {
|
|
21
|
-
default: ColumnResolutionStrategy;
|
|
22
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResolutionStrategies = void 0;
|
|
4
|
-
exports.ResolutionStrategies = {
|
|
5
|
-
default: {
|
|
6
|
-
resolveIndex: ({ query, headerMap }) => {
|
|
7
|
-
// 1. Exact / String Match
|
|
8
|
-
if (typeof query === 'string') {
|
|
9
|
-
if (headerMap.has(query))
|
|
10
|
-
return headerMap.get(query);
|
|
11
|
-
}
|
|
12
|
-
// 2. Regex Match
|
|
13
|
-
if (query instanceof RegExp) {
|
|
14
|
-
for (const [colName, idx] of headerMap.entries()) {
|
|
15
|
-
if (query.test(colName))
|
|
16
|
-
return idx;
|
|
17
|
-
}
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
// 3. (Optional) Fuzzy String Match fallback could go here
|
|
21
|
-
// But for strict default strategy, we might want to keep it simple first
|
|
22
|
-
// The original code didn't do fuzzy *resolution* logic inside the get(), it just did strict get().
|
|
23
|
-
// The fuzzy logic was only for *suggestions* on error.
|
|
24
|
-
return undefined;
|
|
25
|
-
},
|
|
26
|
-
resolveName: ({ query }) => {
|
|
27
|
-
return query.toString();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SortingStrategy } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* A collection of pre-built sorting strategies.
|
|
4
|
-
*/
|
|
5
|
-
export declare const SortingStrategies: {
|
|
6
|
-
/**
|
|
7
|
-
* A sorting strategy that interacts with column headers based on ARIA attributes.
|
|
8
|
-
* - `doSort`: Clicks the header repeatedly until the desired `aria-sort` state is achieved.
|
|
9
|
-
* - `getSortState`: Reads the `aria-sort` attribute from the header.
|
|
10
|
-
*/
|
|
11
|
-
AriaSort: () => SortingStrategy;
|
|
12
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SortingStrategies = void 0;
|
|
13
|
-
/**
|
|
14
|
-
* A collection of pre-built sorting strategies.
|
|
15
|
-
*/
|
|
16
|
-
exports.SortingStrategies = {
|
|
17
|
-
/**
|
|
18
|
-
* A sorting strategy that interacts with column headers based on ARIA attributes.
|
|
19
|
-
* - `doSort`: Clicks the header repeatedly until the desired `aria-sort` state is achieved.
|
|
20
|
-
* - `getSortState`: Reads the `aria-sort` attribute from the header.
|
|
21
|
-
*/
|
|
22
|
-
AriaSort: () => {
|
|
23
|
-
return {
|
|
24
|
-
doSort(_a) {
|
|
25
|
-
return __awaiter(this, arguments, void 0, function* ({ columnName, direction, context }) {
|
|
26
|
-
const { resolve, config, root } = context;
|
|
27
|
-
const headerLoc = resolve(config.headerSelector, root);
|
|
28
|
-
const headers = yield headerLoc.all();
|
|
29
|
-
const headerTexts = yield Promise.all(headers.map(h => h.innerText()));
|
|
30
|
-
const columnIndex = headerTexts.findIndex(text => text.trim() === columnName);
|
|
31
|
-
if (columnIndex === -1) {
|
|
32
|
-
throw new Error(`[AriaSort] Header with text "${columnName}" not found.`);
|
|
33
|
-
}
|
|
34
|
-
const targetHeader = headers[columnIndex];
|
|
35
|
-
// Click repeatedly to cycle through sort states
|
|
36
|
-
for (let i = 0; i < 3; i++) { // Max 3 clicks to prevent infinite loops (none -> asc -> desc)
|
|
37
|
-
const currentState = yield targetHeader.getAttribute('aria-sort');
|
|
38
|
-
const mappedState = currentState === 'ascending' ? 'asc' : currentState === 'descending' ? 'desc' : 'none';
|
|
39
|
-
if (mappedState === direction) {
|
|
40
|
-
return; // Desired state achieved
|
|
41
|
-
}
|
|
42
|
-
yield targetHeader.click();
|
|
43
|
-
}
|
|
44
|
-
throw new Error(`[AriaSort] Could not achieve sort direction "${direction}" for column "${columnName}" after 3 clicks.`);
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
getSortState(_a) {
|
|
48
|
-
return __awaiter(this, arguments, void 0, function* ({ columnName, context }) {
|
|
49
|
-
const { resolve, config, root } = context;
|
|
50
|
-
const headerLoc = resolve(config.headerSelector, root);
|
|
51
|
-
const headers = yield headerLoc.all();
|
|
52
|
-
const headerTexts = yield Promise.all(headers.map(h => h.innerText()));
|
|
53
|
-
const columnIndex = headerTexts.findIndex(text => text.trim() === columnName);
|
|
54
|
-
if (columnIndex === -1) {
|
|
55
|
-
return 'none'; // Header not found, so it's not sorted
|
|
56
|
-
}
|
|
57
|
-
const targetHeader = headers[columnIndex];
|
|
58
|
-
const ariaSort = yield targetHeader.getAttribute('aria-sort');
|
|
59
|
-
if (ariaSort === 'ascending')
|
|
60
|
-
return 'asc';
|
|
61
|
-
if (ariaSort === 'descending')
|
|
62
|
-
return 'desc';
|
|
63
|
-
return 'none';
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { PaginationStrategy, SortingStrategy, FillStrategy } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Validates that a pagination strategy returns a boolean.
|
|
4
|
-
* @param result - The result from a pagination strategy
|
|
5
|
-
* @param strategyName - Name of the strategy for error messages
|
|
6
|
-
*/
|
|
7
|
-
export declare function validatePaginationResult(result: any, strategyName?: string): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Validates that a pagination strategy is properly configured.
|
|
10
|
-
* @param strategy - The pagination strategy to validate
|
|
11
|
-
*/
|
|
12
|
-
export declare function validatePaginationStrategy(strategy: any): strategy is PaginationStrategy;
|
|
13
|
-
/**
|
|
14
|
-
* Validates that a sorting strategy has the required methods.
|
|
15
|
-
* @param strategy - The sorting strategy to validate
|
|
16
|
-
*/
|
|
17
|
-
export declare function validateSortingStrategy(strategy: any): strategy is SortingStrategy;
|
|
18
|
-
/**
|
|
19
|
-
* Validates that a fill strategy is properly configured.
|
|
20
|
-
* @param strategy - The fill strategy to validate
|
|
21
|
-
*/
|
|
22
|
-
export declare function validateFillStrategy(strategy: any): strategy is FillStrategy;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validatePaginationResult = validatePaginationResult;
|
|
4
|
-
exports.validatePaginationStrategy = validatePaginationStrategy;
|
|
5
|
-
exports.validateSortingStrategy = validateSortingStrategy;
|
|
6
|
-
exports.validateFillStrategy = validateFillStrategy;
|
|
7
|
-
/**
|
|
8
|
-
* Validates that a pagination strategy returns a boolean.
|
|
9
|
-
* @param result - The result from a pagination strategy
|
|
10
|
-
* @param strategyName - Name of the strategy for error messages
|
|
11
|
-
*/
|
|
12
|
-
function validatePaginationResult(result, strategyName = 'Custom Pagination Strategy') {
|
|
13
|
-
if (typeof result !== 'boolean') {
|
|
14
|
-
throw new Error(`[${strategyName}] Pagination strategy must return a boolean (true if paginated, false if no more pages). ` +
|
|
15
|
-
`Received: ${typeof result} (${JSON.stringify(result)})`);
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Validates that a pagination strategy is properly configured.
|
|
21
|
-
* @param strategy - The pagination strategy to validate
|
|
22
|
-
*/
|
|
23
|
-
function validatePaginationStrategy(strategy) {
|
|
24
|
-
if (typeof strategy !== 'function') {
|
|
25
|
-
throw new Error(`Pagination strategy must be a function. Received: ${typeof strategy}`);
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Validates that a sorting strategy has the required methods.
|
|
31
|
-
* @param strategy - The sorting strategy to validate
|
|
32
|
-
*/
|
|
33
|
-
function validateSortingStrategy(strategy) {
|
|
34
|
-
if (!strategy || typeof strategy !== 'object') {
|
|
35
|
-
throw new Error(`Sorting strategy must be an object with 'doSort' and 'getSortState' methods. Received: ${typeof strategy}`);
|
|
36
|
-
}
|
|
37
|
-
if (typeof strategy.doSort !== 'function') {
|
|
38
|
-
throw new Error(`Sorting strategy must have a 'doSort' method. Missing or not a function.`);
|
|
39
|
-
}
|
|
40
|
-
if (typeof strategy.getSortState !== 'function') {
|
|
41
|
-
throw new Error(`Sorting strategy must have a 'getSortState' method. Missing or not a function.`);
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Validates that a fill strategy is properly configured.
|
|
47
|
-
* @param strategy - The fill strategy to validate
|
|
48
|
-
*/
|
|
49
|
-
function validateFillStrategy(strategy) {
|
|
50
|
-
if (typeof strategy !== 'function') {
|
|
51
|
-
throw new Error(`Fill strategy must be a function. Received: ${typeof strategy}`);
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { PaginationStrategy } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Strategies for handling virtualized pagination where:
|
|
4
|
-
* 1. The total row count might not change (DOM recycling).
|
|
5
|
-
* 2. We need to check for *new content* appearing to confirm pagination success.
|
|
6
|
-
*/
|
|
7
|
-
export declare const virtualizedInfiniteScroll: (options?: {
|
|
8
|
-
/** Selector for the scrollable container. Defaults to table root. */
|
|
9
|
-
scrollTarget?: string;
|
|
10
|
-
/** Amount to scroll in pixels. Default 500. */
|
|
11
|
-
scrollAmount?: number;
|
|
12
|
-
/** Timeout to wait for content stability. Default 500ms. */
|
|
13
|
-
stabilityTimeout?: number;
|
|
14
|
-
/** Max retries to detect content change. Default 3. */
|
|
15
|
-
retries?: number;
|
|
16
|
-
/** force use of JS scrollTop property instead of mouse wheel. Default: false */
|
|
17
|
-
useJsScroll?: boolean;
|
|
18
|
-
}) => PaginationStrategy;
|
|
19
|
-
export declare const VirtualizedPaginationStrategies: {
|
|
20
|
-
virtualInfiniteScroll: (options?: {
|
|
21
|
-
/** Selector for the scrollable container. Defaults to table root. */
|
|
22
|
-
scrollTarget?: string;
|
|
23
|
-
/** Amount to scroll in pixels. Default 500. */
|
|
24
|
-
scrollAmount?: number;
|
|
25
|
-
/** Timeout to wait for content stability. Default 500ms. */
|
|
26
|
-
stabilityTimeout?: number;
|
|
27
|
-
/** Max retries to detect content change. Default 3. */
|
|
28
|
-
retries?: number;
|
|
29
|
-
/** force use of JS scrollTop property instead of mouse wheel. Default: false */
|
|
30
|
-
useJsScroll?: boolean;
|
|
31
|
-
}) => PaginationStrategy;
|
|
32
|
-
};
|