@rickcedwhat/playwright-smart-table 6.16.0 → 6.17.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.
@@ -47,7 +47,7 @@ class RowFinder {
47
47
  const tracker = new elementTracker_1.ElementTracker('findRows');
48
48
  try {
49
49
  const collectMatches = async () => {
50
- var _a, _b, _c, _d, _e;
50
+ var _a, _b, _c, _d, _e, _f;
51
51
  let rowLocators = this.resolve(this.config.rowSelector, this.rootLocator);
52
52
  // Only apply filters if we have them
53
53
  if (Object.keys(filtersRecord).length > 0) {
@@ -69,7 +69,13 @@ class RowFinder {
69
69
  const useBarrier = this.config.concurrency === 'synchronized' && newIndices.length > 1;
70
70
  const barrier = useBarrier ? new navigationBarrier_1.NavigationBarrier(newIndices.length) : undefined;
71
71
  for (const idx of newIndices) {
72
- const smartRow = this.makeSmartRow(currentRows[idx], map, allRows.length, this.tableState.currentPageIndex, barrier);
72
+ // Use the configured strategy (O(1), e.g. MUI data-rowindex) when available.
73
+ // Without a strategy, fall back to sequential position to avoid the O(n)
74
+ // elementHandle scan that resolveRowIndex() would otherwise perform per row.
75
+ const rowIndex = this.config.strategies.resolveRowIndex
76
+ ? ((_f = await this.config.strategies.resolveRowIndex(currentRows[idx])) !== null && _f !== void 0 ? _f : allRows.length)
77
+ : allRows.length;
78
+ const smartRow = this.makeSmartRow(currentRows[idx], map, rowIndex, this.tableState.currentPageIndex, barrier);
73
79
  if (isRowLoading && await isRowLoading(smartRow)) {
74
80
  if (rowLoadingTimeout === undefined) {
75
81
  // No timeout configured (or invalid value) — legacy skip behavior
@@ -192,6 +198,13 @@ class RowFinder {
192
198
  }
193
199
  }
194
200
  async resolveRowIndex(rowLocator) {
201
+ if (this.config.strategies.resolveRowIndex) {
202
+ const result = await this.config.strategies.resolveRowIndex(rowLocator);
203
+ if (result !== undefined)
204
+ return result;
205
+ // Strategy returned undefined — fall through to DOM scan below.
206
+ }
207
+ // Fallback: find the row's position in the current DOM order.
195
208
  const allRows = await this.resolve(this.config.rowSelector, this.rootLocator).all();
196
209
  const targetHandle = await rowLocator.elementHandle();
197
210
  if (!targetHandle)
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export { Strategies } from './strategies';
5
5
  export * as presets from './presets';
6
6
  /** @deprecated Use `presets` instead. Plugins will be removed in v7.0.0. */
7
7
  export { Plugins } from './plugins';
8
+ export { mergeTableConfig } from './utils/mergeTableConfig';
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Plugins = exports.presets = exports.Strategies = exports.useTable = exports.PLAYWRIGHT_SMART_TABLE_VERSION = void 0;
36
+ exports.mergeTableConfig = exports.Plugins = exports.presets = exports.Strategies = exports.useTable = exports.PLAYWRIGHT_SMART_TABLE_VERSION = void 0;
37
37
  var packageVersion_1 = require("./packageVersion");
38
38
  Object.defineProperty(exports, "PLAYWRIGHT_SMART_TABLE_VERSION", { enumerable: true, get: function () { return packageVersion_1.PLAYWRIGHT_SMART_TABLE_VERSION; } });
39
39
  var useTable_1 = require("./useTable");
@@ -45,3 +45,5 @@ exports.presets = __importStar(require("./presets"));
45
45
  /** @deprecated Use `presets` instead. Plugins will be removed in v7.0.0. */
46
46
  var plugins_1 = require("./plugins");
47
47
  Object.defineProperty(exports, "Plugins", { enumerable: true, get: function () { return plugins_1.Plugins; } });
48
+ var mergeTableConfig_1 = require("./utils/mergeTableConfig");
49
+ Object.defineProperty(exports, "mergeTableConfig", { enumerable: true, get: function () { return mergeTableConfig_1.mergeTableConfig; } });
@@ -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.16.0";
6
+ export declare const PLAYWRIGHT_SMART_TABLE_VERSION: "6.17.1";
@@ -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.16.0";
9
+ exports.PLAYWRIGHT_SMART_TABLE_VERSION = "6.17.1";
@@ -1,4 +1,5 @@
1
- export { muiTable, muiDataGrid } from './mui';
1
+ export { muiTable, muiDataGrid, createMuiTable, createMuiDataGrid } from './mui';
2
+ export type { MuiButtonLabels } from './mui';
2
3
  export { RDG as rdg, RDG2D as rdg2D } from './rdg';
3
4
  export { Glide as glide, createGlide, createGlideViewport } from './glide';
4
5
  export type { GlideOptions, GlideViewportOptions } from './glide';
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createGlideViewport = exports.createGlide = exports.glide = exports.rdg2D = exports.rdg = exports.muiDataGrid = exports.muiTable = void 0;
3
+ exports.createGlideViewport = exports.createGlide = exports.glide = exports.rdg2D = exports.rdg = exports.createMuiDataGrid = exports.createMuiTable = exports.muiDataGrid = exports.muiTable = void 0;
4
4
  var mui_1 = require("./mui");
5
5
  Object.defineProperty(exports, "muiTable", { enumerable: true, get: function () { return mui_1.muiTable; } });
6
6
  Object.defineProperty(exports, "muiDataGrid", { enumerable: true, get: function () { return mui_1.muiDataGrid; } });
7
+ Object.defineProperty(exports, "createMuiTable", { enumerable: true, get: function () { return mui_1.createMuiTable; } });
8
+ Object.defineProperty(exports, "createMuiDataGrid", { enumerable: true, get: function () { return mui_1.createMuiDataGrid; } });
7
9
  var rdg_1 = require("./rdg");
8
10
  Object.defineProperty(exports, "rdg", { enumerable: true, get: function () { return rdg_1.RDG; } });
9
11
  Object.defineProperty(exports, "rdg2D", { enumerable: true, get: function () { return rdg_1.RDG2D; } });
@@ -1,16 +1,28 @@
1
1
  import { TableConfig } from '../types';
2
+ /** Aria-labels for MUI pagination buttons. Override for non-English locales. */
3
+ export interface MuiButtonLabels {
4
+ nextPage?: string;
5
+ previousPage?: string;
6
+ firstPage?: string;
7
+ }
2
8
  /**
3
- * Preset configuration for the standard Material UI `<Table />` component.
9
+ * Creates a preset configuration for the standard Material UI `<Table />` component.
4
10
  *
5
- * Handles:
6
- * - Selectors for `.MuiTableRow-root`, `.MuiTableCell-head`, etc.
7
- * - Pagination via the standard `.MuiTablePagination-actions` footer.
8
- * - Sorting via the `.MuiTableSortLabel-root` header classes.
9
- * - Virtualized DOM deduplication (falls back to cell text if unvirtualized).
11
+ * @param opts.buttonLabels - Override aria-labels for pagination buttons (use for non-English locales).
12
+ *
13
+ * @example
14
+ * // French locale
15
+ * const table = useTable(loc, createMuiTable({ buttonLabels: { nextPage: 'Page suivante', previousPage: 'Page précédente' } }));
10
16
  */
17
+ export declare function createMuiTable(opts?: {
18
+ buttonLabels?: MuiButtonLabels;
19
+ }): Partial<TableConfig>;
20
+ /** Default preset for MUI `<Table />`. For non-English locales use `createMuiTable({ buttonLabels })`. */
11
21
  export declare const muiTable: Partial<TableConfig>;
12
22
  /**
13
- * Preset configuration for the MUI DataGrid component (@mui/x-data-grid).
23
+ * Creates a preset configuration for the MUI DataGrid component (@mui/x-data-grid).
24
+ *
25
+ * @param opts.buttonLabels - Override aria-labels for pagination buttons (use for non-English locales).
14
26
  *
15
27
  * Handles:
16
28
  * - Selectors for `.MuiDataGrid-row`, `.MuiDataGrid-cell`, and `.MuiDataGrid-columnHeader`.
@@ -19,4 +31,8 @@ export declare const muiTable: Partial<TableConfig>;
19
31
  * - Vertical Virtualization deduplication using `data-rowindex`.
20
32
  * - Horizontal Virtualization support via `aria-colindex`.
21
33
  */
34
+ export declare function createMuiDataGrid(opts?: {
35
+ buttonLabels?: MuiButtonLabels;
36
+ }): Partial<TableConfig>;
37
+ /** Default preset for MUI DataGrid. For non-English locales use `createMuiDataGrid({ buttonLabels })`. */
22
38
  export declare const muiDataGrid: Partial<TableConfig>;