@guiexpert/table 1.1.72 → 1.1.75

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.
@@ -38,6 +38,7 @@ export declare abstract class AbstractAreaModel<T> implements AreaModelIf, HasDe
38
38
  abstract externalFilterChanged<T>(predictFn: FilterFunction<T>): void;
39
39
  isFilterable(): boolean;
40
40
  doSort(_sortItems: SortItem[]): boolean;
41
+ sort(_compareFn?: (a: any, b: any) => number): void;
41
42
  isEditable(_rowIndex: number, columnIndex: number): boolean;
42
43
  setValue(rowIndex: number, columnIndex: number, value: any): boolean;
43
44
  isSelectable(_rowIndex: number, _columnIndex: number): boolean;
@@ -22,6 +22,7 @@ export declare class AreaModelCellGroups implements AreaModelIf {
22
22
  private groupExts;
23
23
  private cellGroupExtCellRenderer;
24
24
  constructor(areaIdent: AreaIdent, groups: CellGroupIf[], columnDefs: ColumnDefIf[], defaultRowHeight: number, headerGroupOptions?: HeaderGroupOptionsIf);
25
+ sort<T>(_compareFn?: (a: T, b: T) => number): void;
25
26
  init(): void;
26
27
  getAllLeafs(): CellGroupExt[];
27
28
  getMaxRowCount(): number;
@@ -12,6 +12,7 @@ export declare class AreaModelHidden implements AreaModelIf {
12
12
  areaIdent: AreaIdent;
13
13
  rowSelectionModel: CheckboxModelIf<any> | undefined;
14
14
  constructor(areaIdent?: AreaIdent);
15
+ sort<T>(_compareFn?: (a: T, b: T) => number): void;
15
16
  getRowCount(): number;
16
17
  getValueAt(_rowIndex: number, _columnIndex: number): any;
17
18
  getTextValueAt(_rowIndex: number, _columnIndex: number): string;
@@ -16,11 +16,13 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
16
16
  protected columnDefs: ColumnDefIf[];
17
17
  selectedRowClass: string;
18
18
  focusedRowClass: string;
19
- focusedRowIndex: number;
20
19
  protected readonly properties: string[];
21
20
  protected filteredRows: T[];
22
21
  protected sorterService: SorterService;
23
22
  constructor(areaIdent: AreaIdent, rows: T[], defaultRowHeight: number, columnDefs?: ColumnDefIf[], selectedRowClass?: string, focusedRowClass?: string);
23
+ private _focusedRowIndex;
24
+ get focusedRowIndex(): number;
25
+ set focusedRowIndex(value: number);
24
26
  setRows(rows: T[]): void;
25
27
  filterRowsByPredict(predict: (row: T) => boolean): void;
26
28
  /**
@@ -36,10 +38,29 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
36
38
  */
37
39
  getFilteredRows(): T[];
38
40
  getAllRows(): T[];
41
+ /**
42
+ * Returns the first row from the filtered rows that matches the given criteria based on the provided predicate function.
43
+ *
44
+ * @param {Partial<T>} criteria - A partial object containing the search criteria
45
+ * @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
46
+ * and returns true if the row matches the criteria
47
+ * @returns {T | undefined} The first matching row, or undefined if no match is found
48
+ */
49
+ findRowFromFilteredRowsByAllCriteria(criteria: Partial<T>, predicate: (criteria: Partial<T>, row: T) => boolean): T | undefined;
50
+ /**
51
+ * Searches through all rows to find a row that matches the given criteria based on the predicate function.
52
+ *
53
+ * @param {Partial<T>} criteria - A partial object containing the search criteria
54
+ * @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
55
+ * and returns true if the row matches the criteria
56
+ * @returns {T | undefined} The first matching row from all rows, or undefined if no match is found
57
+ */
58
+ findRowFromAllRowsByAllCriteria(criteria: Partial<T>, predicate: (criteria: Partial<T>, row: T) => boolean): T | undefined;
39
59
  getRowHeight(_rowIndex: number): number;
40
60
  getRowByIndex(rowIndex: number): any;
41
61
  externalFilterChanged(predictFn: FilterFunction<any>): void;
42
62
  doSort(sortItems: SortItem[]): boolean;
63
+ sort(compareFn: (a: T, b: T) => number): void;
43
64
  getValueByT(t: T, property: string): any;
44
65
  changeColumnOrder(sourceColumnIndex: number, targetColumnIndex: number): void;
45
66
  getCustomClassesAt(rowIndex: number, _columnIndex: number): string[];
@@ -13,6 +13,7 @@ export declare class AreaModel implements AreaModelIf {
13
13
  rowSelectionModel: CheckboxModelIf<any> | undefined;
14
14
  changeColumnOrder(_sourceColumnIndex: number, _targetColumnIndex: number): void;
15
15
  doSort(_sortItems: SortItem[]): boolean;
16
+ sort(_compareFn?: (a: any, b: any) => number): void;
16
17
  externalFilterChanged<T>(_predictFn: FilterFunction<T>): void;
17
18
  getCellRenderer(_rowIndex: number, _columnIndex: number): CellRendererIf | undefined;
18
19
  getColspanAt(_rowIndex: number, _columnIndex: number): number;
@@ -160,4 +160,5 @@ export interface AreaModelIf {
160
160
  * @param sortItems
161
161
  */
162
162
  doSort(sortItems: SortItem[]): boolean;
163
+ sort(compareFn?: (a: any, b: any) => number): void;
163
164
  }
@@ -230,6 +230,7 @@ export declare class TableModel implements TableModelIf {
230
230
  * @return {boolean} - Returns true if the sorting is successful, otherwise false.
231
231
  */
232
232
  doSort(sortItems: SortItem[]): boolean;
233
+ sort(compareFn: (a: any, b: any) => number): void;
233
234
  /**
234
235
  * Returns an array of ColumnDefIf objects or undefined.
235
236
  *
@@ -221,6 +221,7 @@ export interface TableModelIf {
221
221
  * @return {boolean} - Returns true if the sorting was successful, false otherwise.
222
222
  */
223
223
  doSort(sortItems: SortItem[]): boolean;
224
+ sort(compareFn: (a: any, b: any) => number): void;
224
225
  /**
225
226
  * Retrieves the selection model associated with the component.
226
227
  *
@@ -172,17 +172,410 @@ export declare class TableApi {
172
172
  * or undefined if no selection model is available.
173
173
  */
174
174
  getSelectionModel(): SelectionModelIf | undefined;
175
+ /**
176
+ * Automatically resizes all columns to fit their content.
177
+ *
178
+ * @param {boolean} recalcWrappers - Determines whether to recalculate wrapper dimensions after resizing columns.
179
+ * Default value is true.
180
+ *
181
+ * @return {void} - This method doesn't return anything.
182
+ */
175
183
  autoResizeColumns(recalcWrappers?: boolean): void;
184
+ /**
185
+ * Recalculates the dimensions of all wrapper elements in the table.
186
+ *
187
+ * This method is typically called after changes to the table structure or content
188
+ * that might affect the layout, such as resizing columns or changing row heights.
189
+ * It ensures that all wrapper elements are properly sized to match their content.
190
+ *
191
+ * @return {void} - This method doesn't return anything.
192
+ */
176
193
  recalcWrappers(): void;
194
+ /**
195
+ * Sets the width of a specific column in the table.
196
+ *
197
+ * @param {number} columnIndex - The index of the column to resize.
198
+ * @param {number} width - The new width to set for the column, in pixels.
199
+ *
200
+ * @return {void} - This method doesn't return anything.
201
+ */
177
202
  setColumnWidth(columnIndex: number, width: number): void;
203
+ /**
204
+ * Retrieves the table model that contains all data and structure information for the table.
205
+ *
206
+ * @return {TableModelIf} The table model interface that provides access to the table's data structure,
207
+ * including header, body, and footer area models.
208
+ */
178
209
  getTableModel(): TableModelIf;
210
+ /**
211
+ * Retrieves the area model for the body section of the table.
212
+ *
213
+ * @return {AreaModelIf} The area model interface that provides access to the table's body data,
214
+ * including rows, cells, and their values.
215
+ */
179
216
  getBodyModel(): AreaModelIf;
217
+ /**
218
+ * Sets the rows data for the table body, replacing any existing rows.
219
+ *
220
+ * @template T - The type of elements in the rows array
221
+ * @param {T[]} rows - An array of data objects to set as the table's rows
222
+ *
223
+ * @description
224
+ * This method replaces all existing rows in the table body with the provided array of data objects.
225
+ * It only works with tables that use AreaModelObjectArray as their body model.
226
+ *
227
+ * @return {void} - This method doesn't return anything.
228
+ *
229
+ * @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
230
+ */
180
231
  setRows<T>(rows: T[]): void;
232
+ /**
233
+ * Adds new rows to the end of the table body.
234
+ *
235
+ * @template T - The type of elements in the rows array
236
+ * @param {T[]} rows - An array of data objects to append to the table's existing rows
237
+ *
238
+ * @description
239
+ * This method appends the provided array of data objects to the end of the existing rows in the table body.
240
+ * It only works with tables that use AreaModelObjectArray as their body model.
241
+ *
242
+ * @return {void} - This method doesn't return anything.
243
+ *
244
+ * @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
245
+ */
181
246
  addRows<T>(rows: T[]): void;
247
+ /**
248
+ * Inserts new rows at a specific position in the table body.
249
+ *
250
+ * @template T - The type of elements in the rows array
251
+ * @param {T[]} rows - An array of data objects to insert into the table
252
+ * @param {number} rowIndex - The index position where the new rows should be inserted
253
+ *
254
+ * @description
255
+ * This method inserts the provided array of data objects at the specified index position in the table body.
256
+ * Existing rows at or after the specified index will be shifted down.
257
+ * It only works with tables that use AreaModelObjectArray as their body model.
258
+ *
259
+ * @return {void} - This method doesn't return anything.
260
+ *
261
+ * @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
262
+ */
182
263
  addRowsAt<T>(rows: T[], rowIndex: number): void;
264
+ /**
265
+ * Removes specified rows from the table body.
266
+ *
267
+ * @template T - The type of elements in the rows array
268
+ * @param {T[]} rows - An array of data objects to remove from the table
269
+ * @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
270
+ * - Default predicate uses strict equality (===)
271
+ * - The function should return true if the rows are considered a match
272
+ *
273
+ * @description
274
+ * This method removes rows from the table body that match any of the provided rows based on the predicate function.
275
+ * It only works with tables that use AreaModelObjectArray as their body model.
276
+ *
277
+ * @return {void} - This method doesn't return anything.
278
+ *
279
+ * @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
280
+ */
183
281
  removeRows<T>(rows: T[], predicate?: (a: T, b: T) => boolean): void;
282
+ /**
283
+ * Searches for and returns rows from the table body that match the given criteria.
284
+ *
285
+ * @template T - The type of elements in the rows array
286
+ *
287
+ * @description
288
+ * This method searches through the table body model for rows that match the provided criteria.
289
+ * It only works with tables that use AreaModelObjectArray as their body model.
290
+ * The method uses a predicate function to determine matches between rows.
291
+ *
292
+ * @param {T[]} rows - An array of rows to search for in the table body
293
+ * @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
294
+ * - Default predicate uses strict equality (===)
295
+ * - The function should return true if the rows are considered a match
296
+ * - Parameters:
297
+ * - a: The row from the table body being checked
298
+ * - b: The row from the input array being searched for
299
+ *
300
+ * @returns {T[]} An array containing all matching rows found in the table body
301
+ * - Returns an empty array if:
302
+ * - The body model is not an instance of AreaModelObjectArray
303
+ * - No matches are found
304
+ *
305
+ * @example
306
+ * // Find rows with simple equality comparison
307
+ * const matchingRows = table.findRows([row1, row2]);
308
+ *
309
+ * @example
310
+ * // Find rows with custom comparison logic
311
+ * const matchingRows = table.findRows([row1, row2], (a, b) => a.id === b.id);
312
+ *
313
+ * @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
314
+ */
184
315
  findRows<T>(rows: T[], predicate?: (a: T, b: T) => boolean): T[];
316
+ /**
317
+ * Searches through the filtered rows of the table to find a row that matches specific criteria.
318
+ * This method only works with tables that use AreaModelObjectArray as their body model.
319
+ *
320
+ * @template T - The type of the row objects in the table
321
+ *
322
+ * @param {Partial<T>} criteria - A partial object containing the search criteria.
323
+ * Only needs to include the properties you want to match against.
324
+ *
325
+ * @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
326
+ * Returns true if the row matches the criteria, false otherwise.
327
+ *
328
+ * @returns {T | undefined} The first matching row from the filtered rows, or undefined if no match is found
329
+ * or if the body model is not an instance of AreaModelObjectArray.
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * interface Person {
334
+ * id: number;
335
+ * name: string;
336
+ * age: number;
337
+ * }
338
+ *
339
+ * // Find a person by exact match
340
+ * const criteria = { name: "John", age: 30 };
341
+ * const person = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
342
+ * criteria,
343
+ * (criteria, row) => row.name === criteria.name && row.age === criteria.age
344
+ * );
345
+ *
346
+ * // Find a person by partial name match
347
+ * const searchCriteria = { name: "Jo" };
348
+ * const person2 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
349
+ * searchCriteria,
350
+ * (criteria, row) => row.name.toLowerCase().includes(criteria.name!.toLowerCase())
351
+ * );
352
+ *
353
+ * // Find a person within age range
354
+ * const ageCriteria = { minAge: 25, maxAge: 35 };
355
+ * const person3 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
356
+ * ageCriteria,
357
+ * (criteria, row) => row.age >= criteria.minAge! && row.age <= criteria.maxAge!
358
+ * );
359
+ * ```
360
+ *
361
+ * @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
362
+ *
363
+ * @remarks
364
+ * - This method only searches through filtered rows (rows that are currently visible in the table)
365
+ * - If you need to search through all rows (including filtered out ones), use findRowFromAllRowsByAllCriteria instead
366
+ * - The predicate function gives you full control over how to match rows against your criteria
367
+ * - Returns undefined if either no match is found or if the table's body model is not compatible
368
+ */
369
+ findRowFromFilteredRowsByAllCriteria<T>(criteria: Partial<T>, predicate: (criteria: Partial<T>, row: T) => boolean): T | undefined;
370
+ /**
371
+ * Searches through all rows in the table's body model to find a row that matches specified criteria.
372
+ * This method works only with AreaModelObjectArray<T> body models.
373
+ *
374
+ * @template T - The type of objects/rows in the table
375
+ *
376
+ * @param {Partial<T>} criteria - A partial object containing the search criteria.
377
+ * Only needs to include the properties you want to match against.
378
+ *
379
+ * @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
380
+ * Returns true if the row matches the criteria, false otherwise.
381
+ *
382
+ * @returns {T | undefined} The first matching row, or undefined if no match is found or if the body model is not AreaModelObjectArray.
383
+ *
384
+ * @example
385
+ * // Find a user row by id and name
386
+ * const criteria = { id: 1, name: "John" };
387
+ * const user = tableApi.findRowFromAllRowsByAllCriteria(criteria,
388
+ * (criteria, row) => row.id === criteria.id && row.name === criteria.name
389
+ * );
390
+ *
391
+ * @example
392
+ * // Find a product row with partial match on name
393
+ * const criteria = { name: "Phone" };
394
+ * const product = tableApi.findRowFromAllRowsByAllCriteria(criteria,
395
+ * (criteria, row) => row.name.includes(criteria.name)
396
+ * );
397
+ *
398
+ * @example
399
+ * // Find an order with complex matching logic
400
+ * const criteria = { total: 100, status: "pending" };
401
+ * const order = tableApi.findRowFromAllRowsByAllCriteria(criteria,
402
+ * (criteria, row) => {
403
+ * return row.total > criteria.total &&
404
+ * row.status === criteria.status &&
405
+ * row.items.length > 0;
406
+ * }
407
+ * );
408
+ *
409
+ * @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
410
+ */
411
+ findRowFromAllRowsByAllCriteria<T>(criteria: Partial<T>, predicate: (criteria: Partial<T>, row: T) => boolean): T | undefined;
412
+ /**
413
+ * Updates existing rows in the table body with new data.
414
+ *
415
+ * @template T - The type of elements in the rows array
416
+ * @param {T[]} rows - An array of data objects containing the updated values
417
+ * @param {(a: T, b: T) => boolean} predicate - A comparison function that determines which rows to update
418
+ * - Default predicate uses strict equality (===)
419
+ * - The function should return true if the row should be updated
420
+ *
421
+ * @description
422
+ * This method updates existing rows in the table body with new values from the provided rows array.
423
+ * For each row in the table, if the predicate returns true when compared with any row in the provided array,
424
+ * all properties from the provided row will be copied to the existing row.
425
+ * It only works with tables that use AreaModelObjectArray as their body model.
426
+ *
427
+ * @return {void} - This method doesn't return anything.
428
+ *
429
+ * @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
430
+ */
185
431
  updateRows<T>(rows: T[], predicate?: (a: T, b: T) => boolean): void;
432
+ /**
433
+ * Re-applies the current sorting configuration to the table data.
434
+ *
435
+ * @description
436
+ * This method triggers a re-sort of the table data using the current sorting configuration.
437
+ * It's useful when the underlying data has changed and needs to be re-sorted without changing
438
+ * the sort columns or direction.
439
+ *
440
+ * @return {void} - This method doesn't return anything.
441
+ */
186
442
  reSort(): void;
443
+ /**
444
+ * Sorts the table data using a custom comparison function.
445
+ *
446
+ * This method allows sorting of table rows by providing a custom comparison function. The comparison function
447
+ * should follow the standard JavaScript array sort comparator pattern, returning:
448
+ * - A negative number if the first element should be sorted before the second
449
+ * - A positive number if the first element should be sorted after the second
450
+ * - Zero if the elements are equal
451
+ *
452
+ * @param compareFn - A function that defines the sort order. The function should accept two arguments
453
+ * and return a number indicating their relative order:
454
+ * - Negative number: first argument should come before second
455
+ * - Positive number: second argument should come before first
456
+ * - Zero: elements are equal
457
+ *
458
+ * @example
459
+ * // Sort table rows by a specific property in ascending order
460
+ * table.api.sort((a, b) => {
461
+ * if (a.name < b.name) return -1;
462
+ * if (a.name > b.name) return 1;
463
+ * return 0;
464
+ * });
465
+ *
466
+ * @example
467
+ * // Sort numbers in descending order
468
+ * table.api.sort((a, b) => b.value - a.value);
469
+ *
470
+ * @example
471
+ * // Sort with multiple criteria
472
+ * table.api.sort((a, b) => {
473
+ * // First sort by status
474
+ * const statusCompare = a.status.localeCompare(b.status);
475
+ * if (statusCompare !== 0) return statusCompare;
476
+ *
477
+ * // Then sort by name if status is equal
478
+ * return a.name.localeCompare(b.name);
479
+ * });
480
+ *
481
+ * @example
482
+ * // Case-insensitive string sorting
483
+ * table.api.sort((a, b) =>
484
+ * a.name.toLowerCase().localeCompare(b.name.toLowerCase())
485
+ * );
486
+ */
487
+ sort(compareFn: (a: any, b: any) => number): void;
488
+ /**
489
+ * Ensures that a specific row is visible in the viewport by scrolling if necessary.
490
+ * This method checks if the target row is within the currently visible range and
491
+ * adjusts the scroll position if it's not visible.
492
+ *
493
+ * The method performs the following:
494
+ * 1. Checks if the row is above the current viewport (before first visible row)
495
+ * 2. Checks if the row is below the current viewport (after last visible row)
496
+ * 3. Scrolls to make the row visible if needed
497
+ *
498
+ * @param {number} rowIndex - The index of the row to make visible
499
+ * @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
500
+ *
501
+ * @example
502
+ * // Ensure row 5 is visible in the viewport
503
+ * tableApi.ensureRowIsVisible(5);
504
+ *
505
+ * @example
506
+ * // Example usage in a component
507
+ * class MyTableComponent {
508
+ * private tableApi: TableApi;
509
+ *
510
+ * scrollToSpecificRow(rowIndex: number) {
511
+ * // This will scroll the row into view if it's not visible
512
+ * const didScroll = this.tableApi.ensureRowIsVisible(rowIndex);
513
+ *
514
+ * if (didScroll) {
515
+ * console.log(`Table scrolled to show row ${rowIndex}`);
516
+ * } else {
517
+ * console.log(`Row ${rowIndex} was already visible`);
518
+ * }
519
+ * }
520
+ * }
521
+ *
522
+ * @example
523
+ * // Example with row selection
524
+ * class TableHandler {
525
+ * selectAndShowRow(rowIndex: number) {
526
+ * // First ensure the row is visible
527
+ * this.tableApi.ensureRowIsVisible(rowIndex);
528
+ *
529
+ * // Then perform selection
530
+ * this.selectionModel.selectRow(rowIndex);
531
+ * }
532
+ * }
533
+ *
534
+ * @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
535
+ *
536
+ * @see {@link scrollToIndex} - The underlying method used for scrolling
537
+ * @see {@link getDisplayedRowCount} - Related method for getting visible row count
538
+ */
539
+ ensureRowIsVisible(rowIndex: number): boolean;
540
+ /**
541
+ * Retrieves the number of rows currently displayed in the table.
542
+ *
543
+ * @description
544
+ * This method returns the count of rows that are currently visible in the table after
545
+ * applying any filtering, pagination, or other visibility constraints.
546
+ *
547
+ * @return {number} The number of rows currently displayed in the table.
548
+ */
187
549
  getDisplayedRowCount(): number;
550
+ /**
551
+ * Returns the index of the first visible row in the table's viewport.
552
+ *
553
+ * This method retrieves the first visible row index from the table's scope, which is useful
554
+ * for virtual scrolling and viewport-related calculations. The index represents the topmost
555
+ * visible row in the current scroll position of the table.
556
+ *
557
+ * This value is maintained internally by the table and updated during scrolling operations.
558
+ * It's particularly important for:
559
+ * - Virtual scrolling optimization
560
+ * - Calculating visible range of rows
561
+ * - Viewport-related operations
562
+ * - Scroll position restoration
563
+ *
564
+ * @returns {number} The index of the first visible row in the table's viewport.
565
+ * Returns -1 if no rows are visible or if the table is not yet rendered.
566
+ *
567
+ * @example
568
+ * ```typescript
569
+ * // Get the first visible row index
570
+ * const tableApi = new TableApi(tableScope);
571
+ * const firstVisibleIndex = tableApi.getFirstVisibleRowIndex();
572
+ *
573
+ * // Use the index for scroll position calculations
574
+ * if (firstVisibleIndex >= 0) {
575
+ * // Perform operations with the first visible row
576
+ * console.log(`First visible row index: ${firstVisibleIndex}`);
577
+ * }
578
+ * ```
579
+ */
580
+ getFirstVisibleRowIndex(): number;
188
581
  }
@@ -297,5 +297,59 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
297
297
  autoResizeColumns(recalcWrappers?: boolean): void;
298
298
  recalcWrappers(): void;
299
299
  reSort(): void;
300
+ sort(compareFn: (a: any, b: any) => number): void;
300
301
  getDisplayedRowCount(): number;
302
+ /**
303
+ * Ensures that a specific row is visible in the viewport by scrolling if necessary.
304
+ * This method checks if the target row is within the currently visible range and
305
+ * adjusts the scroll position if it's not visible.
306
+ *
307
+ * The method performs the following:
308
+ * 1. Checks if the row is above the current viewport (before first visible row)
309
+ * 2. Checks if the row is below the current viewport (after last visible row)
310
+ * 3. Scrolls to make the row visible if needed
311
+ *
312
+ * @param {number} rowIndex - The index of the row to make visible
313
+ * @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
314
+ *
315
+ * @example
316
+ * // Ensure row 5 is visible in the viewport
317
+ * tableScope.ensureRowIsVisible(5);
318
+ *
319
+ * @example
320
+ * // Example usage in a component
321
+ * class MyTableComponent {
322
+ * private tableScope: TableScope;
323
+ *
324
+ * scrollToSpecificRow(rowIndex: number) {
325
+ * // This will scroll the row into view if it's not visible
326
+ * const didScroll = this.tableScope.ensureRowIsVisible(rowIndex);
327
+ *
328
+ * if (didScroll) {
329
+ * console.log(`Table scrolled to show row ${rowIndex}`);
330
+ * } else {
331
+ * console.log(`Row ${rowIndex} was already visible`);
332
+ * }
333
+ * }
334
+ * }
335
+ *
336
+ * @example
337
+ * // Example with row selection
338
+ * class TableHandler {
339
+ * selectAndShowRow(rowIndex: number) {
340
+ * // First ensure the row is visible
341
+ * this.tableScope.ensureRowIsVisible(rowIndex);
342
+ *
343
+ * // Then perform selection
344
+ * this.selectionModel.selectRow(rowIndex);
345
+ * }
346
+ * }
347
+ *
348
+ * @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
349
+ *
350
+ * @see {@link scrollToIndex} - The underlying method used for scrolling
351
+ * @see {@link getDisplayedRowCount} - Related method for getting visible row count
352
+ */
353
+ ensureRowIsVisible(rowIndex: number): boolean;
354
+ getFirstVisibleRowIndex(): number;
301
355
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/table",
3
- "version": "1.1.72",
3
+ "version": "1.1.75",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./index.js",