@rickcedwhat/playwright-smart-table 6.23.1-next.f369c63 → 6.24.0-next.531615

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.
@@ -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.23.1-next.f369c63";
6
+ export declare const PLAYWRIGHT_SMART_TABLE_VERSION: "6.24.0-next.531615";
@@ -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.23.1-next.f369c63";
9
+ exports.PLAYWRIGHT_SMART_TABLE_VERSION = "6.24.0-next.531615";
@@ -56,7 +56,6 @@ const glideFillSimple = async ({ value, page }) => {
56
56
  };
57
57
  const glidePaginationStrategy = pagination_1.PaginationStrategies.infiniteScroll({
58
58
  scrollTarget: 'xpath=//ancestor::body//div[contains(@class, "dvn-scroller")]',
59
- scrollAmount: 500,
60
59
  action: 'js-scroll',
61
60
  stabilization: stabilization_1.StabilizationStrategies.contentChanged({ timeout: 5000 }),
62
61
  timeout: 5000
@@ -50,7 +50,6 @@ const rdgGetCellLocator = ({ row, columnIndex }) => {
50
50
  };
51
51
  const rdgPaginationStrategy = pagination_1.PaginationStrategies.infiniteScroll({
52
52
  action: 'js-scroll',
53
- scrollAmount: 500,
54
53
  stabilization: stabilization_1.StabilizationStrategies.contentChanged({ timeout: 5000 })
55
54
  });
56
55
  const rdgNavigation = {
@@ -30,7 +30,10 @@ export declare const PaginationStrategies: {
30
30
  *
31
31
  * @param options.action 'scroll' (mouse wheel) or 'js-scroll' (direct scrollTop).
32
32
  * @param options.scrollTarget Selector for the scroll container (defaults to table root).
33
- * @param options.scrollAmount Amount to scroll in pixels (default 500).
33
+ * @param options.scrollAmount Amount to scroll in pixels. Defaults to 80% of the scroll target's
34
+ * visible height, so a step never jumps past the rendered window of a virtualized list.
35
+ * An explicit value larger than the visible height logs a one-time warning, because
36
+ * virtualizers never mount the rows that get skipped.
34
37
  * @param options.stabilization Strategy to determine if new content loaded.
35
38
  * Defaults to `rowCountIncreased` (simple append).
36
39
  * Use `contentChanged` for virtualization.
@@ -67,23 +67,46 @@ exports.PaginationStrategies = {
67
67
  *
68
68
  * @param options.action 'scroll' (mouse wheel) or 'js-scroll' (direct scrollTop).
69
69
  * @param options.scrollTarget Selector for the scroll container (defaults to table root).
70
- * @param options.scrollAmount Amount to scroll in pixels (default 500).
70
+ * @param options.scrollAmount Amount to scroll in pixels. Defaults to 80% of the scroll target's
71
+ * visible height, so a step never jumps past the rendered window of a virtualized list.
72
+ * An explicit value larger than the visible height logs a one-time warning, because
73
+ * virtualizers never mount the rows that get skipped.
71
74
  * @param options.stabilization Strategy to determine if new content loaded.
72
75
  * Defaults to `rowCountIncreased` (simple append).
73
76
  * Use `contentChanged` for virtualization.
74
77
  */
75
78
  infiniteScroll: (options = {}) => {
76
- var _a, _b;
79
+ var _a;
77
80
  // Default stabilization: Wait for row count to increase (Append mode)
78
81
  const stabilization = (_a = options.stabilization) !== null && _a !== void 0 ? _a : stabilization_1.StabilizationStrategies.rowCountIncreased({ timeout: options.timeout });
79
- const amount = (_b = options.scrollAmount) !== null && _b !== void 0 ? _b : 500;
82
+ let warnedOversizedStep = false;
80
83
  const createScroller = (directionMultiplier) => {
81
84
  return async (context) => {
82
85
  const { root, resolve, page } = context;
83
86
  const scrollTarget = options.scrollTarget
84
87
  ? resolve(options.scrollTarget, root)
85
88
  : root;
86
- const beforeScrollTop = await scrollTarget.evaluate((el) => el.scrollTop);
89
+ const metrics = await scrollTarget.evaluate((el) => {
90
+ const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
91
+ return {
92
+ scrollTop: el.scrollTop,
93
+ // A non-scrolling target scrolls the page, so the window bounds what is rendered.
94
+ visibleHeight: el.clientHeight > 0 ? Math.min(el.clientHeight, viewportHeight) : viewportHeight,
95
+ isScrollContainer: el.scrollHeight > el.clientHeight + 1,
96
+ };
97
+ });
98
+ const beforeScrollTop = metrics.scrollTop;
99
+ let amount;
100
+ if (options.scrollAmount !== undefined) {
101
+ amount = options.scrollAmount;
102
+ if (!warnedOversizedStep && metrics.isScrollContainer && amount > metrics.visibleHeight) {
103
+ warnedOversizedStep = true;
104
+ console.warn(`[SmartTable] infiniteScroll scrollAmount (${amount}px) is larger than the scroll target's visible height (${Math.round(metrics.visibleHeight)}px). Virtualized lists only render rows near the viewport, so rows between steps are never mounted and will be silently skipped. Omit scrollAmount to step by the visible height, or pass a smaller value.`);
105
+ }
106
+ }
107
+ else {
108
+ amount = Math.floor(metrics.visibleHeight * 0.8) || 500;
109
+ }
87
110
  const doScroll = async () => {
88
111
  const box = await scrollTarget.boundingBox();
89
112
  const scrollValue = amount * directionMultiplier;
@@ -1,4 +1,5 @@
1
1
  import { StrategyContext } from '../types';
2
+ /** @deprecated Not used by the library. Will be removed in v7. */
2
3
  export interface ColumnResolutionStrategy {
3
4
  /**
4
5
  * Resolves a column name (string or Regex) to a column index.
@@ -17,6 +18,3 @@ export interface ColumnResolutionStrategy {
17
18
  headerMap: Map<string, number>;
18
19
  }): string;
19
20
  }
20
- export declare const ResolutionStrategies: {
21
- default: ColumnResolutionStrategy;
22
- };
@@ -1,30 +1,2 @@
1
1
  "use strict";
2
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
- };
@@ -12,7 +12,7 @@ exports.SortingStrategies = {
12
12
  */
13
13
  AriaSort: () => {
14
14
  return {
15
- async doSort({ columnName, direction, context }) {
15
+ async doSort({ columnName, context }) {
16
16
  // getHeaderCell is always present on TableContext after table is initialized
17
17
  const targetHeader = await context.getHeaderCell(columnName);
18
18
  // The table engine handles verify-and-retry. We only provide the trigger here.
package/dist/useTable.js CHANGED
@@ -38,7 +38,7 @@ const smartRowInternals_1 = require("./utils/smartRowInternals");
38
38
  // Helper to safely serialize objects containing functions for logging
39
39
  const safeStringify = (obj) => {
40
40
  try {
41
- return JSON.stringify(obj, (key, value) => {
41
+ return JSON.stringify(obj, (_key, value) => {
42
42
  if (typeof value === 'function') {
43
43
  return '[Function]';
44
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rickcedwhat/playwright-smart-table",
3
- "version": "6.23.1-next.f369c63",
3
+ "version": "6.24.0-next.531615",
4
4
  "description": "Smart, column-aware table interactions for Playwright",
5
5
  "author": "Cedrick Catalan",
6
6
  "license": "MIT",
@@ -53,9 +53,7 @@
53
53
  },
54
54
  "./types": {
55
55
  "types": "./dist/types.d.ts",
56
- "import": "./dist/index.js",
57
- "require": "./dist/index.js",
58
- "default": "./dist/index.js"
56
+ "default": "./dist/types.js"
59
57
  },
60
58
  "./presets": {
61
59
  "types": "./dist/presets/index.d.ts",