@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,104 +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.Glide = exports.GlideStrategies = void 0;
13
- const columns_1 = require("./glide/columns");
14
- const headers_1 = require("./glide/headers");
15
- const pagination_1 = require("../strategies/pagination");
16
- const stabilization_1 = require("../strategies/stabilization");
17
- const glideFillStrategy = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, page }) {
18
- yield page.keyboard.press('Enter');
19
- const textarea = page.locator('textarea.gdg-input');
20
- yield textarea.waitFor({ state: 'visible', timeout: 2000 });
21
- yield page.keyboard.type(String(value));
22
- yield textarea.evaluate((el, expectedValue) => {
23
- return new Promise((resolve) => {
24
- const checkValue = () => {
25
- if (el.value === expectedValue) {
26
- resolve();
27
- }
28
- else {
29
- setTimeout(checkValue, 10);
30
- }
31
- };
32
- checkValue();
33
- });
34
- }, String(value));
35
- yield page.waitForTimeout(50);
36
- yield page.keyboard.press('Enter');
37
- yield textarea.waitFor({ state: 'detached', timeout: 2000 });
38
- yield page.waitForTimeout(300);
39
- });
40
- const glideFillSimple = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, page }) {
41
- yield page.keyboard.press('Enter');
42
- yield page.keyboard.type(String(value));
43
- yield page.keyboard.press('Enter');
44
- });
45
- const glidePaginationStrategy = pagination_1.PaginationStrategies.infiniteScroll({
46
- scrollTarget: 'xpath=//ancestor::body//div[contains(@class, "dvn-scroller")]',
47
- scrollAmount: 500,
48
- action: 'js-scroll',
49
- stabilization: stabilization_1.StabilizationStrategies.contentChanged({ timeout: 5000 }),
50
- timeout: 5000
51
- });
52
- const glideGetCellLocator = ({ row, columnIndex }) => {
53
- return row.locator('td').nth(columnIndex);
54
- };
55
- const glideGetActiveCell = (_a) => __awaiter(void 0, [_a], void 0, function* ({ page }) {
56
- const focused = page.locator('*:focus').first();
57
- if ((yield focused.count()) === 0)
58
- return null;
59
- const id = (yield focused.getAttribute('id')) || '';
60
- const parts = id.split('-');
61
- let rowIndex = -1;
62
- let columnIndex = -1;
63
- if (parts.length >= 4 && parts[0] === 'glide' && parts[1] === 'cell') {
64
- columnIndex = parseInt(parts[2]) - 1;
65
- rowIndex = parseInt(parts[3]);
66
- }
67
- return {
68
- rowIndex,
69
- columnIndex,
70
- locator: focused
71
- };
72
- });
73
- /** Default strategies for the Glide preset (fill only; no fillSimple). */
74
- const GlideDefaultStrategies = {
75
- fill: glideFillStrategy,
76
- pagination: glidePaginationStrategy,
77
- header: headers_1.scrollRightHeader,
78
- navigation: {
79
- goUp: columns_1.glideGoUp,
80
- goDown: columns_1.glideGoDown,
81
- goLeft: columns_1.glideGoLeft,
82
- goRight: columns_1.glideGoRight,
83
- goHome: columns_1.glideGoHome
84
- },
85
- loading: {
86
- isHeaderLoading: () => __awaiter(void 0, void 0, void 0, function* () { return false; })
87
- },
88
- getCellLocator: glideGetCellLocator,
89
- getActiveCell: glideGetActiveCell
90
- };
91
- /** Strategies only for Glide Data Grid. Includes fillSimple; use when you want to supply your own selectors or override fill. */
92
- exports.GlideStrategies = Object.assign(Object.assign({}, GlideDefaultStrategies), { fillSimple: glideFillSimple });
93
- /**
94
- * Full preset for Glide Data Grid (selectors + default strategies only).
95
- * Spread: useTable(loc, { ...Plugins.Glide, maxPages: 5 }).
96
- * Strategies only (including fillSimple): useTable(loc, { rowSelector: '...', strategies: Plugins.Glide.Strategies }).
97
- */
98
- const GlidePreset = {
99
- headerSelector: 'table[role="grid"] thead tr th',
100
- rowSelector: 'table[role="grid"] tbody tr',
101
- cellSelector: 'td',
102
- strategies: GlideDefaultStrategies
103
- };
104
- exports.Glide = Object.defineProperty(GlidePreset, 'Strategies', { get: () => exports.GlideStrategies, enumerable: false });
@@ -1,8 +0,0 @@
1
- import type { TableConfig } from '../types';
2
- /** Full strategies for MUI Data Grid. Use when you want to supply your own selectors: strategies: Plugins.MUI.Strategies */
3
- export declare const MUIStrategies: {
4
- pagination: import("../types").PaginationPrimitives;
5
- };
6
- export declare const MUI: Partial<TableConfig> & {
7
- Strategies: typeof MUIStrategies;
8
- };
@@ -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("../strategies/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,124 +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
- const pagination_1 = require("../strategies/pagination");
14
- const stabilization_1 = require("../strategies/stabilization");
15
- /**
16
- * Scrolls the grid horizontally to collect all column headers.
17
- * Handles empty headers by labeling them (e.g. "Checkbox").
18
- */
19
- const scrollRightHeaderRDG = (context) => __awaiter(void 0, void 0, void 0, function* () {
20
- const { resolve, config, root, page } = context;
21
- const collectedHeaders = new Set();
22
- const gridHandle = yield root.evaluateHandle((el) => {
23
- return el.querySelector('[role="grid"]') || el.closest('[role="grid"]');
24
- });
25
- const expectedColumns = yield gridHandle.evaluate(el => el ? parseInt(el.getAttribute('aria-colcount') || '0', 10) : 0);
26
- const getVisible = () => __awaiter(void 0, void 0, void 0, function* () {
27
- const headerLoc = resolve(config.headerSelector, root);
28
- const texts = yield headerLoc.allInnerTexts();
29
- return texts.map(t => {
30
- const trimmed = t.trim();
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
- while (collectedHeaders.size < expectedColumns && iteration < 30) {
42
- yield gridHandle.evaluate(el => el.scrollLeft += 500);
43
- yield page.waitForTimeout(300);
44
- const newHeaders = yield getVisible();
45
- newHeaders.forEach(h => collectedHeaders.add(h));
46
- const atEnd = yield gridHandle.evaluate(el => el.scrollLeft >= el.scrollWidth - el.clientWidth - 10);
47
- iteration++;
48
- if (atEnd)
49
- break;
50
- }
51
- yield gridHandle.evaluate(el => el.scrollLeft = 0);
52
- yield page.waitForTimeout(200);
53
- }
54
- return Array.from(collectedHeaders);
55
- });
56
- const rdgGetCellLocator = ({ row, columnIndex }) => {
57
- const ariaColIndex = columnIndex + 1;
58
- return row.locator(`[role="gridcell"][aria-colindex="${ariaColIndex}"]`);
59
- };
60
- const rdgPaginationStrategy = pagination_1.PaginationStrategies.infiniteScroll({
61
- action: 'js-scroll',
62
- scrollAmount: 500,
63
- stabilization: stabilization_1.StabilizationStrategies.contentChanged({ timeout: 5000 })
64
- });
65
- const rdgNavigation = {
66
- goRight: (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page }) {
67
- yield root.evaluate((el) => {
68
- const grid = el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el;
69
- if (grid)
70
- grid.scrollLeft += 150;
71
- });
72
- }),
73
- goLeft: (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page }) {
74
- yield root.evaluate((el) => {
75
- const grid = el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el;
76
- if (grid)
77
- grid.scrollLeft -= 150;
78
- });
79
- }),
80
- goDown: (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, page }) {
81
- yield root.evaluate((el) => {
82
- const grid = el.querySelector('[role="grid"]') || el.closest('[role="grid"]') || el;
83
- if (grid)
84
- grid.scrollTop += 35;
85
- });
86
- }),
87
- goUp: (_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.scrollTop -= 35;
92
- });
93
- }),
94
- goHome: (_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.scrollLeft = 0;
99
- grid.scrollTop = 0;
100
- }
101
- });
102
- })
103
- };
104
- /** Default strategies for the RDG preset (used when you spread Plugins.RDG). */
105
- const RDGDefaultStrategies = {
106
- header: scrollRightHeaderRDG,
107
- getCellLocator: rdgGetCellLocator,
108
- navigation: rdgNavigation,
109
- pagination: rdgPaginationStrategy
110
- };
111
- /** Full strategies for React Data Grid. Use when you want to supply your own selectors: strategies: Plugins.RDG.Strategies */
112
- exports.RDGStrategies = RDGDefaultStrategies;
113
- /**
114
- * Full preset for React Data Grid (selectors + default strategies).
115
- * Spread: useTable(loc, { ...Plugins.RDG, maxPages: 5 }).
116
- * Strategies only: useTable(loc, { rowSelector: '...', strategies: Plugins.RDG.Strategies }).
117
- */
118
- const RDGPreset = {
119
- rowSelector: '[role="row"].rdg-row',
120
- headerSelector: '[role="columnheader"]',
121
- cellSelector: '[role="gridcell"]',
122
- strategies: RDGDefaultStrategies
123
- };
124
- exports.RDG = Object.defineProperty(RDGPreset, 'Strategies', { get: () => exports.RDGStrategies, enumerable: false });
package/dist/plugins.d.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * Presets for specific table/grid libraries. Each plugin exposes:
3
- * - Plugins.X — full preset (selectors + headerTransformer if any + strategies). Spread: useTable(loc, { ...Plugins.MUI, maxPages: 5 }).
4
- * - Plugins.X.Strategies — strategies only. Use with your own selectors: useTable(loc, { rowSelector: '...', strategies: Plugins.MUI.Strategies }).
5
- */
6
- export declare const Plugins: {
7
- RDG: Partial<import("./types").TableConfig<any>> & {
8
- Strategies: typeof import("./strategies/rdg").RDGStrategies;
9
- };
10
- Glide: Partial<import("./types").TableConfig<any>> & {
11
- Strategies: typeof import("./strategies/glide").GlideStrategies;
12
- };
13
- MUI: Partial<import("./types").TableConfig<any>> & {
14
- Strategies: typeof import("./strategies/mui").MUIStrategies;
15
- };
16
- };
package/dist/plugins.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Plugins = void 0;
4
- const rdg_1 = require("./strategies/rdg");
5
- const glide_1 = require("./strategies/glide");
6
- const mui_1 = require("./strategies/mui");
7
- /**
8
- * Presets for specific table/grid libraries. Each plugin exposes:
9
- * - Plugins.X — full preset (selectors + headerTransformer if any + strategies). Spread: useTable(loc, { ...Plugins.MUI, maxPages: 5 }).
10
- * - Plugins.X.Strategies — strategies only. Use with your own selectors: useTable(loc, { rowSelector: '...', strategies: Plugins.MUI.Strategies }).
11
- */
12
- exports.Plugins = {
13
- RDG: rdg_1.RDG,
14
- Glide: glide_1.Glide,
15
- MUI: mui_1.MUI,
16
- };
@@ -1,11 +0,0 @@
1
- import { StrategyContext } from '../../types';
2
- /**
3
- * Primitive navigation functions for Glide Data Grid.
4
- * These define HOW to move, not WHEN to move.
5
- * The orchestration logic lives in _navigateToCell.
6
- */
7
- export declare const glideGoUp: (context: StrategyContext) => Promise<void>;
8
- export declare const glideGoDown: (context: StrategyContext) => Promise<void>;
9
- export declare const glideGoLeft: (context: StrategyContext) => Promise<void>;
10
- export declare const glideGoRight: (context: StrategyContext) => Promise<void>;
11
- export declare const glideGoHome: (context: StrategyContext) => Promise<void>;
@@ -1,54 +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.glideGoHome = exports.glideGoRight = exports.glideGoLeft = exports.glideGoDown = exports.glideGoUp = void 0;
13
- /**
14
- * Primitive navigation functions for Glide Data Grid.
15
- * These define HOW to move, not WHEN to move.
16
- * The orchestration logic lives in _navigateToCell.
17
- */
18
- const glideGoUp = (context) => __awaiter(void 0, void 0, void 0, function* () {
19
- yield context.page.keyboard.press('ArrowUp');
20
- });
21
- exports.glideGoUp = glideGoUp;
22
- const glideGoDown = (context) => __awaiter(void 0, void 0, void 0, function* () {
23
- yield context.page.keyboard.press('ArrowDown');
24
- });
25
- exports.glideGoDown = glideGoDown;
26
- const glideGoLeft = (context) => __awaiter(void 0, void 0, void 0, function* () {
27
- yield context.page.keyboard.press('ArrowLeft');
28
- });
29
- exports.glideGoLeft = glideGoLeft;
30
- const glideGoRight = (context) => __awaiter(void 0, void 0, void 0, function* () {
31
- yield context.page.keyboard.press('ArrowRight');
32
- });
33
- exports.glideGoRight = glideGoRight;
34
- const glideGoHome = (context) => __awaiter(void 0, void 0, void 0, function* () {
35
- const { root, page } = context;
36
- // Glide renders to canvas - the accessibility table (root) is inside the canvas
37
- // We need to find and focus the canvas element that contains our root
38
- yield root.evaluate((el) => {
39
- var _a;
40
- // Find the closest canvas ancestor
41
- const canvas = el.closest('canvas') || ((_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.querySelector('canvas'));
42
- if (canvas instanceof HTMLCanvasElement) {
43
- canvas.tabIndex = 0;
44
- canvas.focus();
45
- }
46
- });
47
- yield page.waitForTimeout(100);
48
- // Reset to top-left - Cross-OS sequence (Mac/Windows)
49
- yield page.keyboard.press('Control+Home');
50
- yield page.keyboard.press('Meta+ArrowUp'); // Mac Go-To-Top
51
- yield page.keyboard.press('Home'); // Ensure start of row
52
- yield page.waitForTimeout(150);
53
- });
54
- exports.glideGoHome = glideGoHome;
@@ -1,9 +0,0 @@
1
- import { StrategyContext } from '../../types';
2
- /**
3
- * Scans for headers by finding a scrollable container and setting scrollLeft.
4
- */
5
- export declare const scrollRightHeader: (context: StrategyContext, options?: {
6
- limit?: number;
7
- selector?: string;
8
- scrollAmount?: number;
9
- }) => Promise<string[]>;
@@ -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.scrollRightHeader = void 0;
13
- /**
14
- * Scans for headers by finding a scrollable container and setting scrollLeft.
15
- */
16
- const scrollRightHeader = (context, options) => __awaiter(void 0, void 0, void 0, function* () {
17
- var _a, _b;
18
- const { resolve, config, root, page } = context;
19
- const limit = (_a = options === null || options === void 0 ? void 0 : options.limit) !== null && _a !== void 0 ? _a : 20;
20
- const scrollAmount = (_b = options === null || options === void 0 ? void 0 : options.scrollAmount) !== null && _b !== void 0 ? _b : 300;
21
- const collectedHeaders = new Set();
22
- const getVisible = () => __awaiter(void 0, void 0, void 0, function* () {
23
- const headerLoc = resolve(config.headerSelector, root);
24
- const texts = yield headerLoc.allInnerTexts();
25
- return texts.map(t => t.trim());
26
- });
27
- // Initial capture
28
- let currentHeaders = yield getVisible();
29
- currentHeaders.forEach(h => collectedHeaders.add(h));
30
- // Find scroller using JS for better iframe/shadow support
31
- const scrollerHandle = yield root.evaluateHandle((el, selector) => {
32
- if (selector && el.matches(selector))
33
- return el;
34
- const effectiveSelector = selector || '.dvn-scroller';
35
- const ancestor = el.closest(effectiveSelector);
36
- if (ancestor)
37
- return ancestor;
38
- return document.querySelector(effectiveSelector);
39
- }, options === null || options === void 0 ? void 0 : options.selector);
40
- const isScrollerFound = yield scrollerHandle.evaluate(el => !!el);
41
- if (isScrollerFound) {
42
- yield scrollerHandle.evaluate(el => el.scrollLeft = 0);
43
- yield page.waitForTimeout(200);
44
- for (let i = 0; i < limit; i++) {
45
- const sizeBefore = collectedHeaders.size;
46
- yield scrollerHandle.evaluate((el, amount) => el.scrollLeft += amount, scrollAmount);
47
- yield page.waitForTimeout(300);
48
- const newHeaders = yield getVisible();
49
- newHeaders.forEach(h => collectedHeaders.add(h));
50
- if (collectedHeaders.size === sizeBefore) {
51
- yield scrollerHandle.evaluate((el, amount) => el.scrollLeft += amount, scrollAmount);
52
- yield page.waitForTimeout(300);
53
- const retryHeaders = yield getVisible();
54
- retryHeaders.forEach(h => collectedHeaders.add(h));
55
- if (collectedHeaders.size === sizeBefore)
56
- break;
57
- }
58
- }
59
- }
60
- else {
61
- console.warn("HeaderStrategies.scrollRight: Could not find scroller. Returning visible headers.");
62
- }
63
- // Scroll back to start
64
- yield scrollerHandle.evaluate(el => el.scrollLeft = 0);
65
- yield page.waitForTimeout(200);
66
- return Array.from(collectedHeaders);
67
- });
68
- exports.scrollRightHeader = scrollRightHeader;
@@ -1,31 +0,0 @@
1
- import { FillStrategy, TableConfig } from '../types';
2
- /** Strategies only for Glide Data Grid. Includes fillSimple; use when you want to supply your own selectors or override fill. */
3
- export declare const GlideStrategies: {
4
- fillSimple: FillStrategy;
5
- fill: FillStrategy;
6
- pagination: import("../types").PaginationPrimitives;
7
- header: (context: import("../types").StrategyContext, options?: {
8
- limit?: number;
9
- selector?: string;
10
- scrollAmount?: number;
11
- }) => Promise<string[]>;
12
- navigation: {
13
- goUp: (context: import("../types").StrategyContext) => Promise<void>;
14
- goDown: (context: import("../types").StrategyContext) => Promise<void>;
15
- goLeft: (context: import("../types").StrategyContext) => Promise<void>;
16
- goRight: (context: import("../types").StrategyContext) => Promise<void>;
17
- goHome: (context: import("../types").StrategyContext) => Promise<void>;
18
- };
19
- loading: {
20
- isHeaderLoading: () => Promise<boolean>;
21
- };
22
- getCellLocator: ({ row, columnIndex }: any) => any;
23
- getActiveCell: ({ page }: any) => Promise<{
24
- rowIndex: number;
25
- columnIndex: number;
26
- locator: any;
27
- } | null>;
28
- };
29
- export declare const Glide: Partial<TableConfig> & {
30
- Strategies: typeof GlideStrategies;
31
- };
@@ -1,133 +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.Glide = exports.GlideStrategies = void 0;
13
- const columns_1 = require("./glide/columns");
14
- const headers_1 = require("./glide/headers");
15
- const pagination_1 = require("./pagination");
16
- const stabilization_1 = require("./stabilization");
17
- /**
18
- * Fill strategy for Glide Data Grid with textarea validation.
19
- * This is the default strategy that works with the standard Glide Data Grid editor.
20
- */
21
- const glideFillStrategy = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, page }) {
22
- // Edit Cell
23
- yield page.keyboard.press('Enter');
24
- // Wait for editor to appear
25
- const textarea = page.locator('textarea.gdg-input');
26
- yield textarea.waitFor({ state: 'visible', timeout: 2000 });
27
- yield page.keyboard.type(String(value));
28
- // Wait for textarea value to match what we typed
29
- yield textarea.evaluate((el, expectedValue) => {
30
- return new Promise((resolve) => {
31
- const checkValue = () => {
32
- if (el.value === expectedValue) {
33
- resolve();
34
- }
35
- else {
36
- setTimeout(checkValue, 10);
37
- }
38
- };
39
- checkValue();
40
- });
41
- }, String(value));
42
- // Small delay to let the grid process the value
43
- yield page.waitForTimeout(50);
44
- yield page.keyboard.press('Enter');
45
- // Wait for editor to close (commit completed)
46
- yield textarea.waitFor({ state: 'detached', timeout: 2000 });
47
- // Wait for accessibility layer to sync with canvas state
48
- yield page.waitForTimeout(300);
49
- });
50
- /**
51
- * Simple fill strategy for Glide Data Grid.
52
- * Use this if your Glide implementation doesn't use the standard textarea editor.
53
- * This is faster but may not work for all Glide configurations.
54
- */
55
- const glideFillSimple = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, page }) {
56
- yield page.keyboard.press('Enter');
57
- yield page.keyboard.type(String(value));
58
- yield page.keyboard.press('Enter');
59
- });
60
- const glidePaginationStrategy = pagination_1.PaginationStrategies.infiniteScroll({
61
- scrollTarget: 'xpath=//ancestor::body//div[contains(@class, "dvn-scroller")]',
62
- scrollAmount: 500,
63
- action: 'js-scroll',
64
- stabilization: stabilization_1.StabilizationStrategies.contentChanged({ timeout: 5000 }),
65
- timeout: 5000 // Overall timeout
66
- });
67
- const glideGetCellLocator = ({ row, columnIndex }) => {
68
- // Use relative locator to support virtualization (where rowIndex resets or is offsets)
69
- // The accessibility DOM usually contains 'td' elements with the data.
70
- return row.locator('td').nth(columnIndex);
71
- };
72
- const glideGetActiveCell = (_a) => __awaiter(void 0, [_a], void 0, function* ({ page }) {
73
- // Find the focused cell/element
74
- // Use broad selector for focused element
75
- const focused = page.locator('*:focus').first();
76
- if ((yield focused.count()) === 0)
77
- return null;
78
- // Debug log
79
- if (process.env.DEBUG)
80
- console.log('Found focused element:', yield focused.evaluate((e) => e.outerHTML));
81
- // Try to extract position from ID if possible
82
- const id = (yield focused.getAttribute('id')) || '';
83
- // Expected format: glide-cell-COL-ROW
84
- const parts = id.split('-');
85
- let rowIndex = -1;
86
- let columnIndex = -1;
87
- if (parts.length >= 4 && parts[0] === 'glide' && parts[1] === 'cell') {
88
- columnIndex = parseInt(parts[2]) - 1; // 1-based in ID to 0-based
89
- rowIndex = parseInt(parts[3]);
90
- }
91
- else {
92
- // Fallback: If we can't parse ID, we assume it's the correct cell
93
- // because we just navigated to it.
94
- // Returning -1 indices might be confusing but won't stop smartRow from using the locator.
95
- }
96
- return {
97
- rowIndex,
98
- columnIndex,
99
- locator: focused
100
- };
101
- });
102
- /** Default strategies for the Glide preset (fill only; no fillSimple). */
103
- const GlideDefaultStrategies = {
104
- fill: glideFillStrategy,
105
- pagination: glidePaginationStrategy,
106
- header: headers_1.scrollRightHeader,
107
- navigation: {
108
- goUp: columns_1.glideGoUp,
109
- goDown: columns_1.glideGoDown,
110
- goLeft: columns_1.glideGoLeft,
111
- goRight: columns_1.glideGoRight,
112
- goHome: columns_1.glideGoHome
113
- },
114
- loading: {
115
- isHeaderLoading: () => __awaiter(void 0, void 0, void 0, function* () { return false; }) // Glide renders headers on a canvas, there is no innerText delay
116
- },
117
- getCellLocator: glideGetCellLocator,
118
- getActiveCell: glideGetActiveCell
119
- };
120
- /** Strategies only for Glide Data Grid. Includes fillSimple; use when you want to supply your own selectors or override fill. */
121
- exports.GlideStrategies = Object.assign(Object.assign({}, GlideDefaultStrategies), { fillSimple: glideFillSimple });
122
- /**
123
- * Full preset for Glide Data Grid (selectors + default strategies only).
124
- * Spread: useTable(loc, { ...Plugins.Glide, maxPages: 5 }).
125
- * Strategies only (including fillSimple): useTable(loc, { rowSelector: '...', strategies: Plugins.Glide.Strategies }).
126
- */
127
- const GlidePreset = {
128
- headerSelector: 'table[role="grid"] thead tr th',
129
- rowSelector: 'table[role="grid"] tbody tr',
130
- cellSelector: 'td',
131
- strategies: GlideDefaultStrategies
132
- };
133
- exports.Glide = Object.defineProperty(GlidePreset, 'Strategies', { get: () => exports.GlideStrategies, enumerable: false });
@@ -1,8 +0,0 @@
1
- import type { TableConfig } from '../types';
2
- /** Full strategies for MUI Data Grid. Use when you want to supply your own selectors: strategies: Plugins.MUI.Strategies */
3
- export declare const MUIStrategies: {
4
- pagination: import("../types").PaginationPrimitives;
5
- };
6
- export declare const MUI: Partial<TableConfig> & {
7
- Strategies: typeof MUIStrategies;
8
- };