@inglorious/ui 9.10.1 → 9.11.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/ui",
3
- "version": "9.10.1",
3
+ "version": "9.11.0",
4
4
  "description": "A design system for Inglorious Web with render-function components and customizable themes",
5
5
  "author": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -433,6 +433,8 @@ function initDataGrid(entity) {
433
433
  entity.isMultiSelect ??= true
434
434
  entity.isVirtualized ??= false
435
435
 
436
+ entity.totalRows ??= null
437
+
436
438
  entity.pagination ??= null
437
439
  if (entity.pagination) {
438
440
  entity.pagination.page ??= 0
@@ -60,11 +60,15 @@ export function getEditedRows(entity) {
60
60
  }
61
61
 
62
62
  /**
63
- * Gets the processed rows (filtered, searched, sorted, paginated).
63
+ * Gets the processed rows (filtered, searched, sorted, paginated). A grid with
64
+ * `totalRows` holds the server's page already processed, so it gets the rows
65
+ * as they are.
64
66
  * @param {TableEntity} entity
65
67
  * @returns {any[]}
66
68
  */
67
69
  export function getRows(entity) {
70
+ if (entity.totalRows != null) return entity.rows
71
+
68
72
  let rows = entity.rows
69
73
  rows = applyFilters(entity, rows)
70
74
  rows = applySearch(entity, rows)
@@ -75,11 +79,14 @@ export function getRows(entity) {
75
79
  }
76
80
 
77
81
  /**
78
- * Gets the total number of rows after filtering and searching.
82
+ * Gets the total number of rows after filtering and searching, or the
83
+ * server's `totalRows` when the grid has it.
79
84
  * @param {TableEntity} entity
80
85
  * @returns {number}
81
86
  */
82
87
  export function getTotalRows(entity) {
88
+ if (entity.totalRows != null) return entity.totalRows
89
+
83
90
  let rows = entity.rows
84
91
  rows = applyFilters(entity, rows)
85
92
  rows = applySearch(entity, rows)
@@ -75,6 +75,13 @@ export interface DataGridProps<T extends Row = Row> {
75
75
  selectionAnchor?: string | number | null
76
76
  pagination?: { page: number; pageSize: number; pageSizes: number[] } | null
77
77
  rowId?: string
78
+ /**
79
+ * How many rows the server has for the current filters and search. When it
80
+ * is set, `rows` is the page the server already filtered, sorted and sliced,
81
+ * so the grid shows them as they are and pages by this total. Set it to `0`
82
+ * before the first load to start the grid server-side.
83
+ */
84
+ totalRows?: number | null
78
85
  isMultiSelect: boolean
79
86
  /**
80
87
  * The user's unsaved edits, by row key and column id, shown over the rows