@rickcedwhat/playwright-smart-table 6.7.5 → 6.7.7

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.
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MUI = exports.MUIStrategies = void 0;
4
- const pagination_1 = require("./pagination");
5
- /** Default strategies for the MUI preset (used when you spread Plugins.MUI). */
6
- const MUIDefaultStrategies = {
7
- pagination: pagination_1.PaginationStrategies.click({
8
- next: (root) => root.getByRole('button', { name: 'Go to next page' }),
9
- }),
10
- };
11
- /** Full strategies for MUI Data Grid. Use when you want to supply your own selectors: strategies: Plugins.MUI.Strategies */
12
- exports.MUIStrategies = MUIDefaultStrategies;
13
- /**
14
- * Full preset for MUI Data Grid (selectors + headerTransformer + default strategies).
15
- * Spread: useTable(loc, { ...Plugins.MUI, maxPages: 5 }).
16
- * Strategies only: useTable(loc, { rowSelector: '...', strategies: Plugins.MUI.Strategies }).
17
- */
18
- const MUIPreset = {
19
- rowSelector: '.MuiDataGrid-row',
20
- headerSelector: '.MuiDataGrid-columnHeader',
21
- cellSelector: '.MuiDataGrid-cell',
22
- headerTransformer: ({ text }) => (text.includes('__col_') ? 'Actions' : text),
23
- strategies: MUIDefaultStrategies,
24
- };
25
- exports.MUI = Object.defineProperty(MUIPreset, 'Strategies', { get: () => exports.MUIStrategies, enumerable: false });
@@ -1,17 +0,0 @@
1
- import { TableContext, TableConfig } from '../types';
2
- /** Full strategies for React Data Grid. Use when you want to supply your own selectors: strategies: Plugins.RDG.Strategies */
3
- export declare const RDGStrategies: {
4
- header: (context: TableContext) => Promise<string[]>;
5
- getCellLocator: ({ row, columnIndex }: any) => any;
6
- navigation: {
7
- goRight: ({ root, page }: any) => Promise<void>;
8
- goLeft: ({ root, page }: any) => Promise<void>;
9
- goDown: ({ root, page }: any) => Promise<void>;
10
- goUp: ({ root, page }: any) => Promise<void>;
11
- goHome: ({ root, page }: any) => Promise<void>;
12
- };
13
- pagination: import("../types").PaginationPrimitives;
14
- };
15
- export declare const RDG: Partial<TableConfig> & {
16
- Strategies: typeof RDGStrategies;
17
- };
@@ -1,138 +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.RDG = exports.RDGStrategies = void 0;
13
- /**
14
- * Scrolls the grid horizontally to collect all column headers.
15
- * Handles empty headers by labeling them (e.g. "Checkbox").
16
- */
17
- const scrollRightHeaderRDG = (context) => __awaiter(void 0, void 0, void 0, function* () {
18
- const { resolve, config, root, page } = context;
19
- const collectedHeaders = new Set();
20
- const gridHandle = yield root.evaluateHandle((el) => {
21
- return el.querySelector('[role="grid"]') || el.closest('[role="grid"]');
22
- });
23
- const scrollContainer = gridHandle; // RDG usually scrolls the grid container itself
24
- const expectedColumns = yield gridHandle.evaluate(el => el ? parseInt(el.getAttribute('aria-colcount') || '0', 10) : 0);
25
- const getVisible = () => __awaiter(void 0, void 0, void 0, function* () {
26
- const headerLoc = resolve(config.headerSelector, root);
27
- const texts = yield headerLoc.allInnerTexts();
28
- return texts.map(t => {
29
- const trimmed = t.trim();
30
- // Assign a name to empty headers (like selection checkboxes)
31
- return trimmed.length > 0 ? trimmed : 'Checkbox';
32
- });
33
- });
34
- let currentHeaders = yield getVisible();
35
- currentHeaders.forEach(h => collectedHeaders.add(h));
36
- const hasScroll = yield gridHandle.evaluate(el => el ? el.scrollWidth > el.clientWidth : false);
37
- if (hasScroll) {
38
- yield gridHandle.evaluate(el => el.scrollLeft = 0);
39
- yield page.waitForTimeout(200);
40
- let iteration = 0;
41
- // Safety break at 30 iterations to prevent infinite loops
42
- while (collectedHeaders.size < expectedColumns && iteration < 30) {
43
- yield gridHandle.evaluate(el => el.scrollLeft += 500);
44
- yield page.waitForTimeout(300);
45
- const newHeaders = yield getVisible();
46
- newHeaders.forEach(h => collectedHeaders.add(h));
47
- const atEnd = yield gridHandle.evaluate(el => el.scrollLeft >= el.scrollWidth - el.clientWidth - 10);
48
- iteration++;
49
- if (atEnd)
50
- break;
51
- }
52
- yield gridHandle.evaluate(el => el.scrollLeft = 0);
53
- yield page.waitForTimeout(200);
54
- }
55
- return Array.from(collectedHeaders);
56
- });
57
- /**
58
- * Uses a row-relative locator to avoid issues with absolute aria-rowindex
59
- * changing during pagination/scrolling.
60
- */
61
- const rdgGetCellLocator = ({ row, columnIndex }) => {
62
- const ariaColIndex = columnIndex + 1;
63
- return row.locator(`[role="gridcell"][aria-colindex="${ariaColIndex}"]`);
64
- };
65
- /**
66
- * Scrolls the grid vertically to load more virtualized rows.
67
- */
68
- const pagination_1 = require("./pagination");
69
- const stabilization_1 = require("./stabilization");
70
- /**
71
- * Scrolls the grid vertically to load more virtualized rows.
72
- */
73
- const rdgPaginationStrategy = pagination_1.PaginationStrategies.infiniteScroll({
74
- action: 'js-scroll',
75
- scrollAmount: 500,
76
- stabilization: stabilization_1.StabilizationStrategies.contentChanged({ timeout: 5000 })
77
- });
78
- const rdgNavigation = {
79
- goRight: (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page }) {
80
- yield root.evaluate((el) => {
81
- // Find grid container
82
- const grid = el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el;
83
- if (grid)
84
- grid.scrollLeft += 150;
85
- });
86
- }),
87
- goLeft: (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page }) {
88
- yield root.evaluate((el) => {
89
- const grid = el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el;
90
- if (grid)
91
- grid.scrollLeft -= 150;
92
- });
93
- }),
94
- goDown: (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page }) {
95
- yield root.evaluate((el) => {
96
- const grid = el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el;
97
- if (grid)
98
- grid.scrollTop += 35;
99
- });
100
- }),
101
- goUp: (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page }) {
102
- yield root.evaluate((el) => {
103
- const grid = el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el;
104
- if (grid)
105
- grid.scrollTop -= 35;
106
- });
107
- }),
108
- goHome: (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page }) {
109
- yield root.evaluate((el) => {
110
- const grid = el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el;
111
- if (grid) {
112
- grid.scrollLeft = 0;
113
- grid.scrollTop = 0;
114
- }
115
- });
116
- })
117
- };
118
- /** Default strategies for the RDG preset (used when you spread Plugins.RDG). */
119
- const RDGDefaultStrategies = {
120
- header: scrollRightHeaderRDG,
121
- getCellLocator: rdgGetCellLocator,
122
- navigation: rdgNavigation,
123
- pagination: rdgPaginationStrategy
124
- };
125
- /** Full strategies for React Data Grid. Use when you want to supply your own selectors: strategies: Plugins.RDG.Strategies */
126
- exports.RDGStrategies = RDGDefaultStrategies;
127
- /**
128
- * Full preset for React Data Grid (selectors + default strategies).
129
- * Spread: useTable(loc, { ...Plugins.RDG, maxPages: 5 }).
130
- * Strategies only: useTable(loc, { rowSelector: '...', strategies: Plugins.RDG.Strategies }).
131
- */
132
- const RDGPreset = {
133
- rowSelector: '[role="row"].rdg-row',
134
- headerSelector: '[role="columnheader"]',
135
- cellSelector: '[role="gridcell"]',
136
- strategies: RDGDefaultStrategies
137
- };
138
- exports.RDG = Object.defineProperty(RDGPreset, 'Strategies', { get: () => exports.RDGStrategies, enumerable: false });