@guiexpert/table 1.1.90 → 1.1.91

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.
Files changed (205) hide show
  1. package/README.md +3 -1
  2. package/css/main.css +50 -4
  3. package/css/table-classes.css +30 -0
  4. package/css/table-color-classes.css +3 -1
  5. package/css/table-color-vars.css +4 -2
  6. package/css/table-tree.css +13 -1
  7. package/index.cjs +80 -89
  8. package/index.d.ts +192 -184
  9. package/index.js +3229 -1580
  10. package/lib/common/debounce.d.ts +1 -0
  11. package/lib/common/decorator/avoid-double-execution.decorator.d.ts +2 -0
  12. package/lib/common/escape-html.d.ts +22 -0
  13. package/lib/common/generator/column-def-generator-service.d.ts +2 -1
  14. package/lib/common/generator/domain/property-type.d.ts +19 -0
  15. package/lib/common/generator/domain/value-info.d.ts +2 -1
  16. package/lib/common/generator/json-service.d.ts +1 -0
  17. package/lib/common/generator/property-type.service.d.ts +3 -2
  18. package/lib/common/generator/scheme-generator-service.d.ts +3 -1
  19. package/lib/common/generator/string-util.d.ts +7 -0
  20. package/lib/common/throttle.d.ts +1 -0
  21. package/lib/table/action/action-id.type.d.ts +5 -1
  22. package/lib/table/action/on-action-triggered.if.d.ts +2 -1
  23. package/lib/table/action/osx-shortcut-actionId-mapping.d.ts +3 -1
  24. package/lib/table/action/shortcut-actionid-mapping.type.d.ts +3 -1
  25. package/lib/table/action/shortcut-util.d.ts +12 -0
  26. package/lib/table/action/shortcut.service.d.ts +5 -3
  27. package/lib/table/action/windows-shortcut-actionId-mapping.d.ts +3 -1
  28. package/lib/table/aria/aria-grid-info.d.ts +76 -0
  29. package/lib/table/aria/aria-ids.d.ts +56 -0
  30. package/lib/table/aria/aria-texts.d.ts +34 -0
  31. package/lib/table/aria/aria-texts.if.d.ts +88 -0
  32. package/lib/table/aria/live-announcer.d.ts +53 -0
  33. package/lib/table/aria/tree-aria-info.d.ts +58 -0
  34. package/lib/table/checkbox/all-rows-checkbox-model.d.ts +31 -0
  35. package/lib/table/checkbox/checkbox-model.d.ts +3 -2
  36. package/lib/table/checkbox/checkbox-model.if.d.ts +2 -1
  37. package/lib/table/checkbox/tree-checkbox-model.d.ts +19 -4
  38. package/lib/table/color/color-rgb.d.ts +2 -1
  39. package/lib/table/color/color-rgb.if.d.ts +2 -0
  40. package/lib/table/color/ge-css-color-util.d.ts +25 -2
  41. package/lib/table/color/three-color-gradient-arg.d.ts +3 -2
  42. package/lib/table/color/three-color-gradient-arg.if.d.ts +3 -1
  43. package/lib/table/color/two-color-gradient-arg.d.ts +3 -2
  44. package/lib/table/color/two-color-gradient-arg.if.d.ts +3 -1
  45. package/lib/table/crud/column-widths.d.ts +2 -1
  46. package/lib/table/crud/column-widths.if.d.ts +1 -0
  47. package/lib/table/crud/crud-action.d.ts +1 -0
  48. package/lib/table/crud/crud-object-edit.d.ts +25 -3
  49. package/lib/table/crud/crud-object-view.d.ts +6 -0
  50. package/lib/table/crud/crud-options.d.ts +35 -4
  51. package/lib/table/crud/crud-options.if.d.ts +3 -2
  52. package/lib/table/crud/crud-table-model-factory.d.ts +64 -8
  53. package/lib/table/crud/url-info.d.ts +2 -1
  54. package/lib/table/crud/url-info.if.d.ts +1 -0
  55. package/lib/table/crud/urls.if.d.ts +2 -1
  56. package/lib/table/css-vars.d.ts +1 -0
  57. package/lib/table/data/chunk/chunk.data-event.d.ts +3 -2
  58. package/lib/table/data/chunk/chunk.data-event.if.d.ts +2 -1
  59. package/lib/table/data/chunk/request-chunk.d.ts +2 -1
  60. package/lib/table/data/chunk/request-chunk.if.d.ts +1 -0
  61. package/lib/table/data/common/aligns.d.ts +18 -0
  62. package/lib/table/data/common/area-map-factory.d.ts +3 -2
  63. package/lib/table/data/common/area-map.d.ts +3 -1
  64. package/lib/table/data/common/area-map.type.d.ts +1 -0
  65. package/lib/table/data/common/args-adjust-columns-to-row-parent-params.d.ts +6 -4
  66. package/lib/table/data/common/args-render-cell-div.d.ts +5 -3
  67. package/lib/table/data/common/boolean-function.d.ts +10 -0
  68. package/lib/table/data/common/cell-range.d.ts +16 -7
  69. package/lib/table/data/common/checkbox-column-def.d.ts +6 -4
  70. package/lib/table/data/common/checked-type.d.ts +2 -0
  71. package/lib/table/data/common/event/ge-cell-indices.d.ts +2 -0
  72. package/lib/table/data/common/event/ge-key-event.d.ts +2 -0
  73. package/lib/table/data/common/event/ge-model-change-event.d.ts +16 -2
  74. package/lib/table/data/common/event/ge-mouse-event.d.ts +52 -4
  75. package/lib/table/data/common/event/ge-scroll-event.d.ts +27 -1
  76. package/lib/table/data/common/event/input/table-cell-update-event.d.ts +14 -10
  77. package/lib/table/data/common/event/input/table-cell-update-event.if.d.ts +3 -1
  78. package/lib/table/data/common/filter-function.d.ts +2 -0
  79. package/lib/table/data/common/get-t.d.ts +2 -0
  80. package/lib/table/data/common/index-and-px.d.ts +2 -0
  81. package/lib/table/data/common/size-unit.type.d.ts +2 -0
  82. package/lib/table/data/common/size.d.ts +13 -2
  83. package/lib/table/data/common/size.if.d.ts +3 -1
  84. package/lib/table/data/common/sizes.d.ts +133 -1
  85. package/lib/table/data/common/sort-item.d.ts +16 -3
  86. package/lib/table/data/common/sort-state.type.d.ts +2 -0
  87. package/lib/table/data/common/tree-arrow.type.d.ts +2 -0
  88. package/lib/table/data/common/tree-row-if.d.ts +22 -1
  89. package/lib/table/data/common/tree-row.d.ts +3 -1
  90. package/lib/table/data/common/value-label.d.ts +2 -1
  91. package/lib/table/data/common/value-label.if.d.ts +1 -0
  92. package/lib/table/data/div-scope.type.d.ts +2 -0
  93. package/lib/table/data/event/mouse-target-data.d.ts +5 -3
  94. package/lib/table/data/geo-data.d.ts +2 -0
  95. package/lib/table/data/options/auto-restore-options.d.ts +32 -1
  96. package/lib/table/data/options/auto-restore-options.if.d.ts +8 -0
  97. package/lib/table/data/options/default-row-heights.d.ts +20 -2
  98. package/lib/table/data/options/default-row-heights.if.d.ts +4 -1
  99. package/lib/table/data/options/header-group-options.d.ts +3 -2
  100. package/lib/table/data/options/header-group-options.if.d.ts +3 -4
  101. package/lib/table/data/options/icon.d.ts +2 -1
  102. package/lib/table/data/options/icon.if.d.ts +2 -0
  103. package/lib/table/data/options/sorted-options.d.ts +3 -2
  104. package/lib/table/data/options/sorted-options.if.d.ts +3 -1
  105. package/lib/table/data/options/table-options.d.ts +37 -13
  106. package/lib/table/data/options/table-options.if.d.ts +117 -44
  107. package/lib/table/data/options/tree-options.d.ts +3 -2
  108. package/lib/table/data/options/tree-options.if.d.ts +3 -1
  109. package/lib/table/data/side-ident.type.d.ts +2 -0
  110. package/lib/table/data/table-model-and-options.d.ts +5 -3
  111. package/lib/table/data/table-model-and-options.if.d.ts +4 -2
  112. package/lib/table/data/tablemodel/area-ident.type.d.ts +4 -0
  113. package/lib/table/data/tablemodel/areamodel/abstract-area-model.d.ts +10 -9
  114. package/lib/table/data/tablemodel/areamodel/area-model-array-of-arrays.d.ts +6 -4
  115. package/lib/table/data/tablemodel/areamodel/area-model-cell-groups.d.ts +13 -12
  116. package/lib/table/data/tablemodel/areamodel/area-model-hidden.d.ts +9 -7
  117. package/lib/table/data/tablemodel/areamodel/area-model-object-array-with-columndefs.d.ts +16 -14
  118. package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +35 -31
  119. package/lib/table/data/tablemodel/areamodel/area-model-tree.d.ts +153 -11
  120. package/lib/table/data/tablemodel/areamodel/area-model.d.ts +66 -104
  121. package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +56 -50
  122. package/lib/table/data/tablemodel/areamodel/async-area-model-object-array.d.ts +5 -5
  123. package/lib/table/data/tablemodel/areamodel/col-and-rowspan-model.d.ts +14 -3
  124. package/lib/table/data/tablemodel/areamodel/cover-grid-body-model.d.ts +10 -8
  125. package/lib/table/data/tablemodel/areamodel/has-default-row-height-if.d.ts +1 -0
  126. package/lib/table/data/tablemodel/areamodel/object-array-holder.if.d.ts +1 -0
  127. package/lib/table/data/tablemodel/cellgroup/cell-group-ext.d.ts +3 -2
  128. package/lib/table/data/tablemodel/cellgroup/cell-group.d.ts +2 -1
  129. package/lib/table/data/tablemodel/cellgroup/cell-group.if.d.ts +28 -0
  130. package/lib/table/data/tablemodel/cellgroup/cellgroup-factory.d.ts +4 -3
  131. package/lib/table/data/tablemodel/column/column-def.d.ts +67 -10
  132. package/lib/table/data/tablemodel/column/column-def.if.d.ts +63 -96
  133. package/lib/table/data/tablemodel/column/column-visibility.d.ts +6 -0
  134. package/lib/table/data/tablemodel/cover-grid-table-model.d.ts +11 -10
  135. package/lib/table/data/tablemodel/padding.d.ts +2 -0
  136. package/lib/table/data/tablemodel/table-model.d.ts +75 -14
  137. package/lib/table/data/tablemodel/table-model.if.d.ts +52 -8
  138. package/lib/table/ele-scope.d.ts +36 -5
  139. package/lib/table/event-adapter.d.ts +17 -10
  140. package/lib/table/event-checkbox-changed-handler.d.ts +2 -1
  141. package/lib/table/event-listener.if.d.ts +42 -9
  142. package/lib/table/factory/cover-grid-factory.d.ts +4 -3
  143. package/lib/table/factory/table-factory.d.ts +103 -64
  144. package/lib/table/factory/tree-factory.d.ts +45 -3
  145. package/lib/table/focus/event-focus-changed-listener.if.d.ts +5 -3
  146. package/lib/table/focus/focus-model.d.ts +7 -5
  147. package/lib/table/focus/focus-model.if.d.ts +22 -1
  148. package/lib/table/focus/focus.type.d.ts +2 -0
  149. package/lib/table/input-handler.d.ts +5 -1
  150. package/lib/table/instanceof-workaround.d.ts +16 -0
  151. package/lib/table/license-manager.d.ts +2 -0
  152. package/lib/table/mouse-handler.d.ts +18 -9
  153. package/lib/table/render-scope.d.ts +115 -25
  154. package/lib/table/renderer/action/action-event-listener.if.d.ts +2 -1
  155. package/lib/table/renderer/action/action-event.d.ts +4 -3
  156. package/lib/table/renderer/action/action-event.if.d.ts +2 -1
  157. package/lib/table/renderer/action/actions-cell-renderer.d.ts +8 -7
  158. package/lib/table/renderer/cell-group-ext-cell-renderer.d.ts +8 -7
  159. package/lib/table/renderer/cell-render.if.d.ts +41 -4
  160. package/lib/table/renderer/checkbox-boolean-property-cell-renderer.d.ts +7 -5
  161. package/lib/table/renderer/checkbox-cell-renderer.d.ts +8 -5
  162. package/lib/table/renderer/date-to-int-date-cell-renderer.d.ts +6 -5
  163. package/lib/table/renderer/date-to-iso-cell-renderer.d.ts +6 -5
  164. package/lib/table/renderer/date-to-locale-date-cell-renderer.d.ts +6 -5
  165. package/lib/table/renderer/date-to-tec-cell-renderer.d.ts +6 -5
  166. package/lib/table/renderer/edit/edit-cell-renderer.type.d.ts +2 -1
  167. package/lib/table/renderer/edit/edit-input-pipe-for-number.d.ts +2 -1
  168. package/lib/table/renderer/edit/edit-input-pipe.if.d.ts +2 -0
  169. package/lib/table/renderer/edit/input-cell-renderer.d.ts +6 -5
  170. package/lib/table/renderer/edit/select-cell-renderer.d.ts +7 -6
  171. package/lib/table/renderer/male-female-to-icon-cell-renderer.d.ts +19 -6
  172. package/lib/table/renderer/number-cell-progress-bar-cell-renderer.d.ts +11 -6
  173. package/lib/table/renderer/number-cell-renderer.d.ts +6 -5
  174. package/lib/table/renderer/positive-and-negative-number-renderer.d.ts +6 -5
  175. package/lib/table/renderer/progress-bar-cell-renderer.d.ts +12 -6
  176. package/lib/table/renderer/renderer-cleanup-fn.type.d.ts +1 -0
  177. package/lib/table/renderer/renderer.d.ts +3 -2
  178. package/lib/table/renderer/simple-array-cell-renderer.d.ts +6 -5
  179. package/lib/table/renderer/star-rating-cell-renderer.d.ts +12 -6
  180. package/lib/table/renderer/true-false-cell-renderer.d.ts +17 -5
  181. package/lib/table/resize-handler.d.ts +3 -1
  182. package/lib/table/selection/event-selection-changed-listener.if.d.ts +2 -1
  183. package/lib/table/selection/multi-rows-selection-model.d.ts +7 -4
  184. package/lib/table/selection/selection-model.d.ts +112 -10
  185. package/lib/table/selection/selection-model.if.d.ts +48 -3
  186. package/lib/table/selection/selection-service.d.ts +35 -7
  187. package/lib/table/selection/selection.type.d.ts +3 -0
  188. package/lib/table/service/abstract-store-state.service.d.ts +1 -1
  189. package/lib/table/service/convenience-dom.service.d.ts +36 -13
  190. package/lib/table/service/copy-service.d.ts +18 -4
  191. package/lib/table/service/copy-service.if.d.ts +4 -3
  192. package/lib/table/service/data/collapsed-expanded.data.d.ts +1 -0
  193. package/lib/table/service/data/html-style.type.d.ts +1 -0
  194. package/lib/table/service/dom-service.if.d.ts +30 -0
  195. package/lib/table/service/excel-service.d.ts +24 -1
  196. package/lib/table/service/excel-service.if.d.ts +7 -0
  197. package/lib/table/service/ge-filter.service.d.ts +1 -0
  198. package/lib/table/service/simple-dom-service.d.ts +3 -1
  199. package/lib/table/service/store-state-collapsed-expand.service.d.ts +4 -3
  200. package/lib/table/service/store-state-scroll-pos.service.d.ts +3 -2
  201. package/lib/table/service/store-state-sorting.service.d.ts +4 -3
  202. package/lib/table/service/tree-row.service.d.ts +5 -1
  203. package/lib/table/table-api.d.ts +296 -550
  204. package/lib/table/table-scope.d.ts +213 -86
  205. package/package.json +23 -8
@@ -1,96 +1,59 @@
1
- import { AreaModelIf } from './area-model.if';
2
- import { AreaIdent } from '../area-ident.type';
3
- import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if';
4
- import { SortItem } from '../../common/sort-item';
5
- import { FilterFunction } from '../../common/filter-function';
6
- import { CellRendererIf } from '../../../renderer/cell-render.if';
7
- import { CheckedType } from '../../common/checked-type';
1
+ import { AreaModelIf } from './area-model.if.js';
2
+ import { AreaIdent } from '../area-ident.type.js';
3
+ import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if.js';
4
+ import { SortItem } from '../../common/sort-item.js';
5
+ import { FilterFunction } from '../../common/filter-function.js';
6
+ import { CellRendererIf } from '../../../renderer/cell-render.if.js';
7
+ import { CheckedType } from '../../common/checked-type.js';
8
8
 
9
9
  /**
10
- * @class AreaModel
11
- * @implements {AreaModelIf}
12
- * @description
13
- * The AreaModel class is a base implementation of the AreaModelIf interface.
14
- * It represents a model for a specific area of a table (header, body, or footer)
15
- * and provides methods for accessing and manipulating data within that area.
10
+ * Base class for area models of your own – every method of {@link AreaModelIf} has a sensible default,
11
+ * override only what you need (at least {@link getRowCount}, {@link getValueAt} and {@link getRowHeight}).
16
12
  *
17
- * In the GuiExpert Table library, a table is divided into three main areas:
18
- * - Header: Contains column titles and optional filter/sort controls
19
- * - Body: Contains the main data of the table
20
- * - Footer: Contains summary information or additional controls
21
- *
22
- * Each of these areas can be further divided into three sections:
23
- * - West: Fixed columns on the left side
24
- * - Center: Scrollable columns in the middle
25
- * - East: Fixed columns on the right side
26
- *
27
- * <pre>
28
- * +----------------+-------------------+--------------+
29
- * | header/west | header/center | header/east |
30
- * +----------------+-------------------+--------------+
31
- * | body/west | body/center | body/east |
32
- * +----------------+-------------------+--------------+
33
- * | footer/west | footer/center | footer/east |
34
- * +----------------+-------------------+--------------+
35
- * </pre>
36
- *
37
- * This base AreaModel class provides default implementations for all methods
38
- * required by the AreaModelIf interface. Most methods return default values
39
- * or do nothing, making this class suitable as a starting point for creating
40
- * more specialized area models.
13
+ * A table consists of three area models – header, body and footer ({@link AreaIdent}) – and asks them only for
14
+ * the cells that are visible. That makes models possible that compute values on demand (millions of rows,
15
+ * server data) or summarise other models (footer totals).
41
16
  *
42
17
  * @example
43
- * // Creating a basic area model for the header
44
- * const headerModel = new AreaModel();
45
- * headerModel.areaIdent = "header";
46
- *
47
- * @example
48
- * // Extending AreaModel to create a custom implementation
49
- * class CustomAreaModel extends AreaModel {
50
- * private data: any[][];
51
- *
52
- * constructor(data: any[][]) {
18
+ * // a body with two million rows – no array behind it
19
+ * class TwoMillionRows extends AreaModel {
20
+ * constructor() {
53
21
  * super();
54
- * this.data = data;
22
+ * this.areaIdent = "body";
55
23
  * }
56
- *
57
- * getRowCount(): number {
58
- * return this.data.length;
59
- * }
60
- *
61
- * getValueAt(rowIndex: number, columnIndex: number): any {
62
- * if (rowIndex < 0 || rowIndex >= this.data.length) return undefined;
63
- * const row = this.data[rowIndex];
64
- * if (columnIndex < 0 || columnIndex >= row.length) return undefined;
65
- * return row[columnIndex];
24
+ * override getRowCount(): number { return 2_000_000; }
25
+ * override getRowHeight(_rowIndex: number): number { return 34; }
26
+ * override getConstantRowHeight(): number { return 34; } // all rows equally high → O(1) scrolling
27
+ * override getValueAt(row: number, col: number): any {
28
+ * return col === 0 ? row + 1 : `cell ${row}/${col}`;
66
29
  * }
67
- *
68
- * // Override other methods as needed...
69
30
  * }
31
+ * const tableModel = TableFactory.createTableModel({
32
+ * bodyAreaModel: new TwoMillionRows(),
33
+ * columnDefs: [new ColumnDef("id", "ID", px100, allRight), new ColumnDef("text", "Text", px200)]
34
+ * });
70
35
  *
71
36
  * @example
72
- * // Using AreaModel with a TableModel
73
- * import { TableFactory, TableModelIf } from "@guiexpert/table";
74
- *
75
- * // Create a table model with custom area models
76
- * const tableModel: TableModelIf = TableFactory.createTableModel();
77
- *
78
- * // Set custom area models
79
- * const headerModel = new CustomAreaModel([["ID", "Name", "Age"]]);
80
- * headerModel.areaIdent = "header";
81
- * tableModel.setAreaModel("header", headerModel);
37
+ * // a footer that sums the rows the body currently shows (after filter and sorting)
38
+ * class TotalsFooter extends AreaModel {
39
+ * constructor(private readonly getBody: () => AreaModelObjectArray<Order>) {
40
+ * super();
41
+ * this.areaIdent = "footer";
42
+ * }
43
+ * override getRowCount(): number { return 1; }
44
+ * override getRowHeight(_rowIndex: number): number { return 34; }
45
+ * override getValueAt(_row: number, col: number): any {
46
+ * const rows = this.getBody().getFilteredRows();
47
+ * return col === 0 ? `${rows.length} orders` : col === 5 ? rows.reduce((s, o) => s + o.total, 0) : "";
48
+ * }
49
+ * }
82
50
  *
83
- * const bodyModel = new CustomAreaModel([
84
- * [1, "John", 30],
85
- * [2, "Jane", 25],
86
- * [3, "Bob", 40]
87
- * ]);
88
- * bodyModel.areaIdent = "body";
89
- * tableModel.setAreaModel("body", bodyModel);
51
+ * @see {@link AreaModelObjectArray} (objects), {@link AreaModelArrayOfArrays} (rows of values), {@link AreaModelTree} (trees)
52
+ * @see Training: [The TableModel: three times three areas](https://gui.expert/training/table-model-areas/),
53
+ * [Own AreaModel: two million rows](https://gui.expert/training/custom-area-model/),
54
+ * [Footer totals](https://gui.expert/training/footer-totals/)
90
55
  *
91
- * @see {@link AreaModelIf} - The interface that this class implements
92
- * @see {@link AbstractAreaModel} - An abstract implementation with common functionality
93
- * @see {@link AreaModelObjectArray} - An implementation for object array data
56
+ * @category Area models
94
57
  */
95
58
  export declare class AreaModel implements AreaModelIf {
96
59
  /**
@@ -141,31 +104,29 @@ export declare class AreaModel implements AreaModelIf {
141
104
  changeColumnOrder(_sourceColumnIndex: number, _targetColumnIndex: number): void;
142
105
  /**
143
106
  * Sorts the rows in this area based on the provided sort items.
144
- * This method is called when the user clicks on a sortable column header.
107
+ * Called when the user double-clicks a sortable column header (and by {@link TableApi.sortByColumn}).
145
108
  * The base implementation returns false (no sorting performed) and should be
146
- * overridden by subclasses that support sorting.
109
+ * overridden by subclasses that hold their rows themselves.
147
110
  *
148
111
  * @param {SortItem[]} _sortItems - An array of sort items, each containing a column index and sort direction
149
112
  * @returns {boolean} True if sorting was performed, false otherwise
150
113
  *
151
114
  * @example
152
- * // Override in a subclass to implement sorting
153
- * doSort(sortItems: SortItem[]): boolean {
154
- * if (!sortItems.length) return false;
115
+ * class SortableRows extends AreaModel {
116
+ * constructor(private readonly rows: any[][]) {
117
+ * super();
118
+ * this.areaIdent = "body";
119
+ * }
120
+ * override getRowCount(): number { return this.rows.length; }
121
+ * override getValueAt(row: number, col: number): any { return this.rows[row][col]; }
155
122
  *
156
- * // Apply sorting to the rows
157
- * this.rows.sort((a, b) => {
123
+ * override doSort(sortItems: SortItem[]): boolean {
124
+ * if (!sortItems.length) return false;
158
125
  * const { columnIndex, sortState } = sortItems[0];
159
- * const valueA = this.getValueAt(this.rows.indexOf(a), columnIndex);
160
- * const valueB = this.getValueAt(this.rows.indexOf(b), columnIndex);
161
- *
162
- * const direction = sortState === 'asc' ? 1 : -1;
163
- * if (valueA < valueB) return -1 * direction;
164
- * if (valueA > valueB) return 1 * direction;
165
- * return 0;
166
- * });
167
- *
168
- * return true;
126
+ * const direction = sortState === "asc" ? 1 : -1;
127
+ * this.rows.sort((a, b) => (a[columnIndex] < b[columnIndex] ? -1 : a[columnIndex] > b[columnIndex] ? 1 : 0) * direction);
128
+ * return true;
129
+ * }
169
130
  * }
170
131
  */
171
132
  doSort(_sortItems: SortItem[]): boolean;
@@ -641,19 +602,20 @@ export declare class AreaModel implements AreaModelIf {
641
602
  isRowChecked(_rowIndex: number): CheckedType | undefined;
642
603
  /**
643
604
  * Determines whether the cell at the specified row and column indices is selectable.
644
- * If true, the user can select the cell.
645
- * The base implementation returns false (not selectable) and should be overridden by
646
- * subclasses that support cell selection.
605
+ * The table draws the selection (of the {@link SelectionModel}) only on selectable body cells.
606
+ *
607
+ * Default: `true` – all cells are selectable, like in all built-in area models
608
+ * (up to 1.1.90 the default of `AreaModel` was `false`: a selection on an own model was not drawn).
609
+ * Override it to exclude cells, e.g. a column of row numbers.
647
610
  *
648
611
  * @param {number} _rowIndex - The index of the row
649
612
  * @param {number} _columnIndex - The index of the column
650
613
  * @returns {boolean} True if the cell is selectable, false otherwise
651
614
  *
652
615
  * @example
653
- * // Override in a subclass to implement cell selectability
654
- * isSelectable(rowIndex: number, columnIndex: number): boolean {
655
- * // All cells in the body are selectable
656
- * return this.areaIdent === 'body';
616
+ * // Override in a subclass: the first column (row numbers) never shows a selection
617
+ * override isSelectable(_rowIndex: number, columnIndex: number): boolean {
618
+ * return columnIndex > 0;
657
619
  * }
658
620
  */
659
621
  isSelectable(_rowIndex: number, _columnIndex: number): boolean;
@@ -1,9 +1,9 @@
1
- import { CellRendererIf } from '../../../renderer/cell-render.if';
2
- import { CheckedType } from '../../common/checked-type';
3
- import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if';
4
- import { FilterFunction } from '../../common/filter-function';
5
- import { SortItem } from '../../common/sort-item';
6
- import { AreaIdent } from '../area-ident.type';
1
+ import { CellRendererIf } from '../../../renderer/cell-render.if.js';
2
+ import { CheckedType } from '../../common/checked-type.js';
3
+ import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if.js';
4
+ import { FilterFunction } from '../../common/filter-function.js';
5
+ import { SortItem } from '../../common/sort-item.js';
6
+ import { AreaIdent } from '../area-ident.type.js';
7
7
 
8
8
  /**
9
9
  * @interface AreaModelIf
@@ -57,7 +57,7 @@ import { AreaIdent } from '../area-ident.type';
57
57
  * [2, "Jane", 25],
58
58
  * [3, "Bob", 40]
59
59
  * ];
60
- * const footerData = [["", "Average", 31.67]];
60
+ * const footerData = [["", "Average", "31.67"]];
61
61
  *
62
62
  * // Create the table model with all three areas
63
63
  * const tableModel: TableModelIf = TableFactory.createTableModel({
@@ -88,9 +88,9 @@ import { AreaIdent } from '../area-ident.type';
88
88
  *
89
89
  * // Define column definitions
90
90
  * const columnDefs: ColumnDefIf[] = [
91
- * { property: "id", headerLabel: "ID", width: 80 },
92
- * { property: "name", headerLabel: "Name", width: 150 },
93
- * { property: "age", headerLabel: "Age", width: 80 }
91
+ * new ColumnDef('id', 'ID', new Size(80, 'px')),
92
+ * new ColumnDef('name', 'Name', new Size(150, 'px')),
93
+ * new ColumnDef('age', 'Age', new Size(80, 'px'))
94
94
  * ];
95
95
  *
96
96
  * // Create the table model
@@ -109,35 +109,36 @@ import { AreaIdent } from '../area-ident.type';
109
109
  * // Example of implementing a custom AreaModelIf
110
110
  * import { AreaModelIf, AreaIdent, CellRendererIf } from "@guiexpert/table";
111
111
  *
112
- * class CustomAreaModel implements AreaModelIf {
112
+ * class CustomAreaModel extends AreaModel {
113
113
  * constructor(
114
- * public areaIdent: AreaIdent,
115
- * private data: any[][],
116
- * private defaultRowHeight: number = 30
117
- * ) {}
114
+ * areaIdent: AreaIdent,
115
+ * private readonly data: any[][],
116
+ * private readonly rowHeight: number = 30
117
+ * ) {
118
+ * super();
119
+ * this.areaIdent = areaIdent;
120
+ * }
118
121
  *
119
- * getRowCount(): number {
122
+ * override getRowCount(): number {
120
123
  * return this.data.length;
121
124
  * }
122
125
  *
123
- * getValueAt(rowIndex: number, columnIndex: number): any {
124
- * if (rowIndex < 0 || rowIndex >= this.data.length) return undefined;
125
- * const row = this.data[rowIndex];
126
- * if (columnIndex < 0 || columnIndex >= row.length) return undefined;
127
- * return row[columnIndex];
126
+ * override getValueAt(rowIndex: number, columnIndex: number): any {
127
+ * return this.data[rowIndex]?.[columnIndex];
128
128
  * }
129
129
  *
130
- * getRowHeight(rowIndex: number): number {
131
- * return this.defaultRowHeight;
130
+ * override getRowHeight(_rowIndex: number): number {
131
+ * return this.rowHeight;
132
132
  * }
133
- *
134
- * // Implement other required methods...
133
+ * // AreaModel has defaults for all other methods
135
134
  * }
136
135
  *
137
136
  * @see {@link TableModelIf} - The parent interface that contains area models
138
137
  * @see {@link AreaModel} - A base implementation of this interface
139
138
  * @see {@link AbstractAreaModel} - An abstract implementation with common functionality
140
139
  * @see {@link AreaModelObjectArray} - An implementation for object array data
140
+ *
141
+ * @category Area models
141
142
  */
142
143
  export interface AreaModelIf {
143
144
  /**
@@ -148,7 +149,8 @@ export interface AreaModelIf {
148
149
  *
149
150
  * @example
150
151
  * // Creating an area model for the header
151
- * const headerModel = new AreaModel("header");
152
+ * const headerModel = new AreaModel();
153
+ * headerModel.areaIdent = "header";
152
154
  *
153
155
  * @example
154
156
  * // Checking which area a model represents
@@ -167,7 +169,8 @@ export interface AreaModelIf {
167
169
  * // Creating a checkbox model for row selection
168
170
  * import { CheckboxModel } from "@guiexpert/table";
169
171
  *
170
- * const bodyModel = new AreaModel("body");
172
+ * const bodyModel = new AreaModel();
173
+ * bodyModel.areaIdent = "body";
171
174
  * bodyModel.rowSelectionModel = new CheckboxModel();
172
175
  *
173
176
  * // Later, check if a row is selected
@@ -673,7 +676,8 @@ export interface AreaModelIf {
673
676
  isEditable(rowIndex: number, columnIndex: number): boolean;
674
677
  /**
675
678
  * Determines whether the cell at the specified row and column indices is selectable.
676
- * If true, the user can select the cell.
679
+ * If true, the user can select the cell: the table draws the selection only on selectable body cells.
680
+ * All built-in models and {@link AreaModel} return `true` (except the hidden and cover-grid models).
677
681
  *
678
682
  * @param {number} rowIndex - The index of the row
679
683
  * @param {number} columnIndex - The index of the column
@@ -733,9 +737,9 @@ export interface AreaModelIf {
733
737
  * @example
734
738
  * // Check if a row is checked
735
739
  * const checkedState = bodyAreaModel.isRowChecked(1);
736
- * if (checkedState === true) {
740
+ * if (checkedState === "full") {
737
741
  * console.log('This row is checked');
738
- * } else if (checkedState === 'indeterminate') {
742
+ * } else if (checkedState === "semi") {
739
743
  * console.log('This row is partially checked');
740
744
  * }
741
745
  *
@@ -836,27 +840,29 @@ export interface AreaModelIf {
836
840
  * ]);
837
841
  *
838
842
  * @example
839
- * // Implementation example
840
- * doSort(sortItems: SortItem[]): boolean {
841
- * if (!sortItems.length) return false;
842
- *
843
- * // Apply sorting to the rows
844
- * for (const sortItem of sortItems) {
845
- * const { columnIndex, sortState } = sortItem;
846
- * const property = this.columnDefs[columnIndex].property;
847
- * const direction = sortState === 'asc' ? 1 : -1;
848
- *
849
- * this.rows.sort((a, b) => {
850
- * const valueA = a[property];
851
- * const valueB = b[property];
852
- *
853
- * if (valueA < valueB) return -1 * direction;
854
- * if (valueA > valueB) return 1 * direction;
855
- * return 0;
856
- * });
857
- * }
843
+ * // Implementation example: a body model that sorts its own rows
844
+ * class MyBodyModel extends AreaModelObjectArray<any> {
845
+ * override doSort(sortItems: SortItem[]): boolean {
846
+ * if (!sortItems.length) return false;
858
847
  *
859
- * return true;
848
+ * // Apply sorting to the rows
849
+ * for (const sortItem of sortItems) {
850
+ * const { columnIndex, sortState } = sortItem;
851
+ * const property = this.columnDefs[columnIndex].property;
852
+ * const direction = sortState === 'asc' ? 1 : -1;
853
+ *
854
+ * this.rows.sort((a, b) => {
855
+ * const valueA = a[property];
856
+ * const valueB = b[property];
857
+ *
858
+ * if (valueA < valueB) return -1 * direction;
859
+ * if (valueA > valueB) return 1 * direction;
860
+ * return 0;
861
+ * });
862
+ * }
863
+ *
864
+ * return true;
865
+ * }
860
866
  * }
861
867
  */
862
868
  doSort(sortItems: SortItem[]): boolean;
@@ -1,8 +1,8 @@
1
- import { AbstractAreaModel } from './abstract-area-model';
2
- import { ColumnDefIf } from '../column/column-def.if';
3
- import { FilterFunction } from '../../common/filter-function';
4
- import { SorterService } from '../../../service/sorter.service';
5
- import { SortItem } from '../../common/sort-item';
1
+ import { AbstractAreaModel } from './abstract-area-model.js';
2
+ import { ColumnDefIf } from '../column/column-def.if.js';
3
+ import { FilterFunction } from '../../common/filter-function.js';
4
+ import { SorterService } from '../../../service/sorter.service.js';
5
+ import { SortItem } from '../../common/sort-item.js';
6
6
 
7
7
  export declare class AsyncBodyAreaModelObjectArray<T> extends AbstractAreaModel<T> {
8
8
  protected readonly maxRowCount: number;
@@ -1,16 +1,27 @@
1
- import { CellRange } from '../../common/cell-range';
2
- import { AreaModelIf } from './area-model.if';
3
- import { TableModelIf } from '../table-model.if';
1
+ import { CellRange } from '../../common/cell-range.js';
2
+ import { AreaModelIf } from './area-model.if.js';
3
+ import { TableModelIf } from '../table-model.if.js';
4
4
 
5
5
  /**
6
6
  * Represents a model for handling colspan and rowspan in a table.
7
+ *
8
+ * @category Area models
7
9
  */
8
10
  export declare class ColAndRowspanModel {
9
11
  protected tableModel: TableModelIf;
10
12
  protected areaModel: AreaModelIf;
11
13
  protected colAndRowspanRanges: CellRange[] | undefined;
12
14
  constructor(tableModel: TableModelIf, areaModel: AreaModelIf);
15
+ /** Row count of the area model at the last {@link init} (−1: not initialized yet). */
16
+ protected rowCountAtInit: number;
13
17
  init(): void;
18
+ /**
19
+ * Builds the ranges again if the row count of the area model changed since the last {@link init} – e.g. after
20
+ * `setRows()` or a filter (the old ranges could point to rows that no longer exist). Cheap otherwise.
21
+ *
22
+ * @returns {boolean} true if the ranges were rebuilt
23
+ */
24
+ initIfRowCountChanged(): boolean;
14
25
  getRanges(): CellRange[];
15
26
  isInRange(rowIndex: number, columnIndex: number): boolean;
16
27
  }
@@ -1,12 +1,13 @@
1
- import { AreaModelIf } from './area-model.if';
2
- import { CellRendererIf } from '../../../renderer/cell-render.if';
3
- import { CheckedType } from '../../common/checked-type';
4
- import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if';
5
- import { FilterFunction } from '../../common/filter-function';
6
- import { SortItem } from '../../common/sort-item';
7
- import { AreaIdent } from '../area-ident.type';
8
- import { SorterService } from '../../../service/sorter.service';
1
+ import { AreaModelIf } from './area-model.if.js';
2
+ import { CellRendererIf } from '../../../renderer/cell-render.if.js';
3
+ import { CheckedType } from '../../common/checked-type.js';
4
+ import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if.js';
5
+ import { FilterFunction } from '../../common/filter-function.js';
6
+ import { SortItem } from '../../common/sort-item.js';
7
+ import { AreaIdent } from '../area-ident.type.js';
8
+ import { SorterService } from '../../../service/sorter.service.js';
9
9
 
10
+ /** @category Area models */
10
11
  export declare class CoverGridBodyModel<T> implements AreaModelIf {
11
12
  items: T[];
12
13
  cellRenderer: CellRendererIf;
@@ -17,6 +18,7 @@ export declare class CoverGridBodyModel<T> implements AreaModelIf {
17
18
  rowSelectionModel: CheckboxModelIf<any> | undefined;
18
19
  areaIdent: AreaIdent;
19
20
  filteredItems: T[];
21
+ /** @internal */
20
22
  protected sorterService: SorterService;
21
23
  constructor(items: T[], cellRenderer: CellRendererIf, coverWidth?: number, coverHeight?: number, width?: number, firstRowPaddingTop?: number);
22
24
  setParentWidth(widthInPixel: number): void;
@@ -1,3 +1,4 @@
1
+ /** @category Area models */
1
2
  export interface HasDefaultRowHeightIf {
2
3
  defaultRowHeight: number;
3
4
  }
@@ -1,3 +1,4 @@
1
+ /** @category Area models */
1
2
  export interface ObjectArrayHolderIf<T> {
2
3
  getAllRows(): T[];
3
4
  getFilteredRows(): T[];
@@ -1,6 +1,7 @@
1
- import { CellGroupIf } from './cell-group.if';
2
- import { CellGroup } from './cell-group';
1
+ import { CellGroupIf } from './cell-group.if.js';
2
+ import { CellGroup } from './cell-group.js';
3
3
 
4
+ /** @category Header groups */
4
5
  export declare class CellGroupExt extends CellGroup {
5
6
  rowIndex: number;
6
7
  childIndex: number;
@@ -1,5 +1,6 @@
1
- import { CellGroupIf } from './cell-group.if';
1
+ import { CellGroupIf } from './cell-group.if.js';
2
2
 
3
+ /** @category Header groups */
3
4
  export declare class CellGroup implements CellGroupIf {
4
5
  data: any;
5
6
  property?: string | undefined;
@@ -1,9 +1,37 @@
1
+ /**
2
+ * One node of a grouped header ({@link AreaModelCellGroups}): a group with `children`, or a leaf with a `property`
3
+ * (a leaf becomes a column).
4
+ *
5
+ * @example
6
+ * const groups: CellGroupIf[] = [
7
+ * { data: "Order", children: [{ data: "ID", property: "id" }, { data: "Date", property: "date" }] },
8
+ * { data: "Customer", toggle: true, children: [
9
+ * { data: "Customer", property: "customer", visibility: "always" }, // stays visible when collapsed
10
+ * { data: "City", property: "city" }] }
11
+ * ];
12
+ * const columnDefs = CellgroupFactory.buildColumnDefs(CellgroupFactory.buildGroupExts(groups));
13
+ * const header = new AreaModelCellGroups("header", groups, columnDefs, 34);
14
+ *
15
+ * @see Training: [Header models: multi-row and grouped](https://gui.expert/training/header-groups/)
16
+ *
17
+ * @category Header groups
18
+ */
1
19
  export interface CellGroupIf {
20
+ /** The label of the group or column. */
2
21
  data: any;
22
+ /** Set on leaves only: the property shown in this column. */
3
23
  property?: string;
24
+ /** Show a ❯ toggle so that the user can collapse / expand the group. */
4
25
  toggle?: boolean;
26
+ /** Current state: collapsed. */
5
27
  closed?: boolean;
28
+ /**
29
+ * When is this child visible? `"always"` – also when the group is collapsed; `"inverted"` – only when collapsed
30
+ * (e.g. a summary column); `"normal"` / undefined – only when expanded.
31
+ */
6
32
  visibility?: "always" | "inverted" | "normal" | undefined;
33
+ /** Sub-groups or columns. */
7
34
  children?: CellGroupIf[] | undefined;
35
+ /** Internal: the implementation type of the node. */
8
36
  impl?: string;
9
37
  }
@@ -1,7 +1,8 @@
1
- import { CellGroupIf } from './cell-group.if';
2
- import { ColumnDefIf } from '../column/column-def.if';
3
- import { CellGroupExt } from './cell-group-ext';
1
+ import { CellGroupIf } from './cell-group.if.js';
2
+ import { ColumnDefIf } from '../column/column-def.if.js';
3
+ import { CellGroupExt } from './cell-group-ext.js';
4
4
 
5
+ /** @category Header groups */
5
6
  export declare class CellgroupFactory {
6
7
  static buildColumnDefs(cellGroups: CellGroupIf[], ret?: ColumnDefIf[]): ColumnDefIf[];
7
8
  static buildGroupExts(cellGroups: CellGroupIf[], ret?: CellGroupExt[], deep?: number, parent?: CellGroupExt): CellGroupExt[];