@xh/hoist 90.0.0 → 90.1.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.
Files changed (172) hide show
  1. package/CHANGELOG.md +136 -54
  2. package/admin/columns/Tracking.ts +9 -3
  3. package/admin/tabs/activity/tracking/ActivityTrackingModel.ts +155 -47
  4. package/admin/tabs/activity/tracking/ActivityTrackingPanel.ts +25 -4
  5. package/admin/tabs/activity/tracking/chart/AggChartModel.ts +2 -3
  6. package/appcontainer/ImpersonationBarModel.ts +8 -5
  7. package/build/types/admin/tabs/activity/tracking/ActivityTrackingModel.d.ts +25 -5
  8. package/build/types/cmp/cubegrid/CubeGrid.d.ts +26 -0
  9. package/build/types/cmp/cubegrid/CubeGridModel.d.ts +103 -0
  10. package/build/types/cmp/cubegrid/CubeGridPivotModel.d.ts +181 -0
  11. package/build/types/cmp/cubegrid/Types.d.ts +85 -0
  12. package/build/types/cmp/cubegrid/index.d.ts +4 -0
  13. package/build/types/cmp/dataview/DataViewModel.d.ts +6 -10
  14. package/build/types/cmp/grid/GridModel.d.ts +8 -33
  15. package/build/types/cmp/grid/Types.d.ts +51 -1
  16. package/build/types/cmp/grid/columns/Column.d.ts +2 -1
  17. package/build/types/cmp/grid/columns/ColumnGroup.d.ts +6 -0
  18. package/build/types/cmp/grid/helpers/GridCountLabel.d.ts +6 -3
  19. package/build/types/cmp/grid/impl/ColumnWidthCalculator.d.ts +6 -0
  20. package/build/types/cmp/grid/impl/GridLikeModel.d.ts +3 -0
  21. package/build/types/cmp/grid/impl/MenuSupport.d.ts +13 -0
  22. package/build/types/cmp/pdfviewer/PdfViewer.d.ts +14 -0
  23. package/build/types/cmp/pdfviewer/PdfViewerModel.d.ts +150 -0
  24. package/build/types/cmp/pdfviewer/Types.d.ts +55 -0
  25. package/build/types/cmp/pdfviewer/impl/PdfFindInputModel.d.ts +14 -0
  26. package/build/types/cmp/pdfviewer/impl/PdfViewerToolbarModel.d.ts +34 -0
  27. package/build/types/cmp/pdfviewer/impl/ZoomOptions.d.ts +10 -0
  28. package/build/types/cmp/pdfviewer/index.d.ts +3 -0
  29. package/build/types/cmp/statcard/StatCard.d.ts +90 -0
  30. package/build/types/cmp/statcard/index.d.ts +1 -0
  31. package/build/types/cmp/store/StoreFilterField.d.ts +8 -9
  32. package/build/types/cmp/store/impl/StoreFilterFieldImplModel.d.ts +4 -4
  33. package/build/types/cmp/zoneGrid/ZoneGridModel.d.ts +6 -10
  34. package/build/types/core/types/Types.d.ts +6 -0
  35. package/build/types/data/Field.d.ts +8 -1
  36. package/build/types/data/Store.d.ts +12 -0
  37. package/build/types/data/cube/Cube.d.ts +2 -0
  38. package/build/types/data/cube/CubeField.d.ts +3 -2
  39. package/build/types/data/cube/Query.d.ts +66 -4
  40. package/build/types/data/cube/View.d.ts +82 -4
  41. package/build/types/data/cube/ViewRowData.d.ts +13 -0
  42. package/build/types/data/cube/aggregate/MedianAggregator.d.ts +19 -0
  43. package/build/types/data/cube/aggregate/SumIfSameAggregator.d.ts +30 -0
  44. package/build/types/data/cube/impl/RowCache.d.ts +5 -0
  45. package/build/types/data/cube/impl/RowDataGenerator.d.ts +26 -0
  46. package/build/types/data/cube/impl/ViewDiagnostics.d.ts +27 -0
  47. package/build/types/data/cube/pivot/PivotCellRow.d.ts +27 -0
  48. package/build/types/data/cube/pivot/PivotPath.d.ts +45 -0
  49. package/build/types/data/cube/pivot/impl/PivotCells.d.ts +111 -0
  50. package/build/types/data/cube/pivot/impl/PivotReference.d.ts +39 -0
  51. package/build/types/data/cube/pivot/impl/PivotStructure.d.ts +105 -0
  52. package/build/types/data/cube/row/BaseRow.d.ts +12 -0
  53. package/build/types/data/cube/row/LeafRow.d.ts +4 -4
  54. package/build/types/data/cube/row/ParentRow.d.ts +20 -4
  55. package/build/types/data/cube/row/RowUpdate.d.ts +2 -0
  56. package/build/types/data/index.d.ts +3 -0
  57. package/build/types/desktop/cmp/button/grid/ColAutosizeButton.d.ts +6 -3
  58. package/build/types/desktop/cmp/button/grid/ColChooserButton.d.ts +7 -3
  59. package/build/types/desktop/cmp/button/grid/ExpandToLevelButton.d.ts +6 -3
  60. package/build/types/desktop/cmp/button/grid/ExportButton.d.ts +6 -3
  61. package/build/types/desktop/cmp/grid/find/GridFindField.d.ts +8 -9
  62. package/build/types/desktop/cmp/grid/find/impl/GridFindFieldImplModel.d.ts +3 -4
  63. package/build/types/desktop/cmp/pdfviewer/impl/PdfViewerToolbar.d.ts +12 -0
  64. package/build/types/desktop/cmp/statcard/impl/StatCardInfoImpl.d.ts +12 -0
  65. package/build/types/dynamics/desktop.d.ts +2 -0
  66. package/build/types/dynamics/mobile.d.ts +1 -0
  67. package/build/types/icon/Icon.d.ts +12 -0
  68. package/build/types/kit/pdfjs/index.d.ts +23 -0
  69. package/build/types/kit/pdfjs/styles.d.ts +2 -0
  70. package/build/types/kit/swiper/index.d.ts +7 -7
  71. package/build/types/mobile/cmp/button/grid/ColAutosizeButton.d.ts +6 -3
  72. package/build/types/mobile/cmp/button/grid/ColChooserButton.d.ts +6 -3
  73. package/build/types/mobile/cmp/button/grid/ExpandCollapseButton.d.ts +4 -4
  74. package/build/types/mobile/cmp/button/grid/ExpandToLevelButton.d.ts +4 -4
  75. package/build/types/mobile/cmp/pdfviewer/impl/PdfViewerToolbar.d.ts +12 -0
  76. package/cmp/README.md +3 -0
  77. package/cmp/ag-grid/AgGrid.ts +25 -3
  78. package/cmp/cubegrid/CubeGrid.ts +60 -0
  79. package/cmp/cubegrid/CubeGridModel.ts +365 -0
  80. package/cmp/cubegrid/CubeGridPivotModel.ts +943 -0
  81. package/cmp/cubegrid/README.md +343 -0
  82. package/cmp/cubegrid/Types.ts +105 -0
  83. package/cmp/cubegrid/index.ts +10 -0
  84. package/cmp/dataview/DataViewModel.ts +13 -8
  85. package/cmp/grid/Grid.scss +21 -5
  86. package/cmp/grid/GridModel.ts +41 -47
  87. package/cmp/grid/Types.ts +58 -1
  88. package/cmp/grid/columns/Column.ts +3 -1
  89. package/cmp/grid/columns/ColumnGroup.ts +10 -0
  90. package/cmp/grid/helpers/GridCountLabel.ts +12 -5
  91. package/cmp/grid/impl/ColumnGroupHeader.ts +18 -4
  92. package/cmp/grid/impl/ColumnWidthCalculator.ts +24 -0
  93. package/cmp/grid/impl/GridLikeModel.ts +17 -0
  94. package/cmp/grid/impl/MenuSupport.ts +36 -20
  95. package/cmp/pdfviewer/PdfViewer.scss +48 -0
  96. package/cmp/pdfviewer/PdfViewer.ts +102 -0
  97. package/cmp/pdfviewer/PdfViewerModel.ts +641 -0
  98. package/cmp/pdfviewer/README.md +224 -0
  99. package/cmp/pdfviewer/Types.ts +72 -0
  100. package/cmp/pdfviewer/impl/PdfFindInputModel.ts +44 -0
  101. package/cmp/pdfviewer/impl/PdfViewerToolbarModel.ts +45 -0
  102. package/cmp/pdfviewer/impl/ZoomOptions.ts +36 -0
  103. package/cmp/pdfviewer/index.ts +9 -0
  104. package/cmp/statcard/StatCard.scss +181 -0
  105. package/cmp/statcard/StatCard.ts +320 -0
  106. package/cmp/statcard/index.ts +1 -0
  107. package/cmp/store/StoreFilterField.ts +8 -9
  108. package/cmp/store/impl/StoreFilterFieldImplModel.ts +14 -14
  109. package/cmp/zoneGrid/ZoneGridModel.ts +13 -8
  110. package/core/types/Types.ts +7 -0
  111. package/data/Field.ts +10 -0
  112. package/data/Store.ts +25 -2
  113. package/data/cube/Cube.ts +5 -0
  114. package/data/cube/CubeField.ts +5 -0
  115. package/data/cube/Query.ts +170 -17
  116. package/data/cube/README.md +77 -2
  117. package/data/cube/View.ts +211 -32
  118. package/data/cube/ViewRowData.ts +22 -0
  119. package/data/cube/aggregate/MedianAggregator.ts +88 -0
  120. package/data/cube/aggregate/SumIfSameAggregator.ts +128 -0
  121. package/data/cube/impl/RowCache.ts +32 -11
  122. package/data/cube/impl/RowDataGenerator.ts +96 -4
  123. package/data/cube/impl/ViewDiagnostics.ts +47 -0
  124. package/data/cube/pivot/PivotCellRow.ts +73 -0
  125. package/data/cube/pivot/PivotPath.ts +67 -0
  126. package/data/cube/pivot/impl/PivotCells.ts +538 -0
  127. package/data/cube/pivot/impl/PivotReference.ts +125 -0
  128. package/data/cube/pivot/impl/PivotStructure.ts +500 -0
  129. package/data/cube/row/BaseRow.ts +26 -0
  130. package/data/cube/row/LeafRow.ts +9 -8
  131. package/data/cube/row/ParentRow.ts +58 -25
  132. package/data/cube/row/RowUpdate.ts +8 -0
  133. package/data/index.ts +3 -0
  134. package/desktop/appcontainer/AppContainer.ts +5 -1
  135. package/desktop/cmp/button/grid/ColAutosizeButton.ts +21 -5
  136. package/desktop/cmp/button/grid/ColChooserButton.ts +11 -5
  137. package/desktop/cmp/button/grid/ExpandToLevelButton.ts +20 -5
  138. package/desktop/cmp/button/grid/ExportButton.ts +19 -7
  139. package/desktop/cmp/dash/canvas/DashCanvas.ts +26 -2
  140. package/desktop/cmp/grid/find/GridFindField.ts +8 -9
  141. package/desktop/cmp/grid/find/impl/GridFindFieldImplModel.ts +15 -16
  142. package/desktop/cmp/grid/impl/colchooser/ColChooserBucketModel.ts +1 -1
  143. package/desktop/cmp/pdfviewer/impl/PdfViewerToolbar.ts +190 -0
  144. package/desktop/cmp/statcard/impl/StatCardInfoImpl.ts +27 -0
  145. package/docs/README.md +6 -2
  146. package/docs/doc-registry.json +21 -5
  147. package/docs/upgrade-notes/v90-upgrade-notes.md +130 -0
  148. package/docs/version-compatibility.md +2 -1
  149. package/dynamics/desktop.ts +4 -0
  150. package/dynamics/mobile.ts +2 -0
  151. package/format/FormatNumber.ts +6 -2
  152. package/icon/Icon.ts +18 -0
  153. package/icon/index.ts +32 -0
  154. package/kit/README.md +2 -0
  155. package/kit/pdfjs/PdfJs.scss +25 -0
  156. package/kit/pdfjs/index.ts +103 -0
  157. package/kit/pdfjs/pdf_viewer.css +6481 -0
  158. package/kit/pdfjs/styles.ts +12 -0
  159. package/mcp/README.md +13 -0
  160. package/mcp/data/import-paths.ts +4 -8
  161. package/mcp/data/index-cache.ts +2 -1
  162. package/mcp/data/ts-registry.ts +8 -29
  163. package/mcp/util/paths.ts +26 -0
  164. package/mobile/appcontainer/AppContainer.ts +3 -1
  165. package/mobile/cmp/button/grid/ColAutosizeButton.ts +20 -5
  166. package/mobile/cmp/button/grid/ColChooserButton.ts +12 -5
  167. package/mobile/cmp/button/grid/ExpandCollapseButton.ts +10 -6
  168. package/mobile/cmp/button/grid/ExpandToLevelButton.ts +10 -6
  169. package/mobile/cmp/pdfviewer/impl/PdfViewerToolbar.ts +137 -0
  170. package/package.json +14 -8
  171. package/public/msal-redirect-bridge.min.js +1 -1
  172. package/styles/vars.scss +59 -0
@@ -112,6 +112,16 @@ export class RowCache {
112
112
  this.usedParents = null;
113
113
  }
114
114
 
115
+ /**
116
+ * Drop cached exposed leaves, whose data objects were minted against a leaf class since
117
+ * rebuilt. Parents are retained and rewired onto the fresh leaves on regeneration.
118
+ */
119
+ invalidateExposedLeaves() {
120
+ this.rows.forEach((row, id) => {
121
+ if (row.isLeaf) this.rows.delete(id);
122
+ });
123
+ }
124
+
115
125
  //------------------
116
126
  // Implementation
117
127
  //------------------
@@ -129,7 +139,12 @@ export class RowCache {
129
139
  newExposed = query.includeLeaves || query.provideLeaves,
130
140
  oldFieldNames = new Set(map(oldQuery.fields, 'name')),
131
141
  fieldsGained = query.fields.some(it => !oldFieldNames.has(it.name)),
132
- bucketsRemoved = oldQuery.bucketSpecFn && !query.bucketSpecFn;
142
+ bucketsRemoved = oldQuery.bucketSpecFn && !query.bucketSpecFn,
143
+ // Any other change leaving parents holding state the new query does not ask for. Cell
144
+ // rows aggregate `measures` alone, a set the `fields` check above cannot see.
145
+ parentsInvalid =
146
+ query.bucketSpecFn !== oldQuery.bucketSpecFn ||
147
+ !isEqual(query.pivot?.measures, oldQuery.pivot?.measures);
133
148
 
134
149
  // 1) Leaf-mode flips, field gains on exposed leaves, and bucket removal invalidate
135
150
  // wholesale - existing rows' data was minted without the gained fields. (Dropped fields
@@ -139,29 +154,34 @@ export class RowCache {
139
154
  return;
140
155
  }
141
156
 
142
- // 2) Field gains with hidden leaves, or a changed bucketSpecFn: leaves remain valid,
143
- // but parents hold never-computed aggregates or a stale BucketSpec.
144
- if (fieldsGained || oldQuery.bucketSpecFn !== query.bucketSpecFn) {
157
+ // 2) Field gains with hidden leaves, or an invalidating change: leaves remain valid, but
158
+ // parents hold never-computed aggregates or a stale BucketSpec.
159
+ if (fieldsGained || parentsInvalid) {
145
160
  this.removeParentRows();
146
161
  return;
147
162
  }
148
163
 
149
164
  // 3) Otherwise retain everything...
150
165
 
151
- // but on a changed grouping, be sure to throw out any unused rows
152
- // at end, when we have already rescued any reusable "upper tree" nodes.
153
- if (!isEqual(oldQuery.dimensions, query.dimensions)) {
166
+ // but where the change moves the ids parents generate under, throw out any unused rows at
167
+ // end, once reusable "upper tree" nodes are rescued. Cell row ids are keyed on pivot path,
168
+ // whose keys carry dimension values alone.
169
+ if (
170
+ !isEqual(query.dimensions, oldQuery.dimensions) ||
171
+ query.isPivoted !== oldQuery.isPivoted ||
172
+ !isEqual(query.pivot?.dimensions, oldQuery.pivot?.dimensions)
173
+ ) {
154
174
  this.usedParents = new Set();
155
175
  }
156
176
  }
157
177
 
158
- // Remove all parent rows, nulling retained leaves' parent pointers so dead chains are not
159
- // pinned in memory.
178
+ // Remove all parent (aggregate/bucket/cell) rows, nulling retained leaves' parent pointers so
179
+ // dead chains are not pinned in memory.
160
180
  private removeParentRows() {
161
181
  const {rows} = this;
162
182
  rows.forEach((row, id) => {
163
183
  if (row.isLeaf) {
164
- row.parent = null;
184
+ row.parent = row.pivotParent = null;
165
185
  } else {
166
186
  rows.delete(id);
167
187
  }
@@ -182,8 +202,9 @@ export class RowCache {
182
202
  });
183
203
  if (!removed) return;
184
204
  rows.forEach(row => {
185
- const {parent} = row;
205
+ const {parent, pivotParent} = row;
186
206
  if (parent && rows.get(parent.id) !== parent) row.parent = null;
207
+ if (pivotParent && rows.get(pivotParent.id) !== pivotParent) row.pivotParent = null;
187
208
  });
188
209
  }
189
210
 
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type {PlainObject} from '@xh/hoist/core';
9
- import {isEqual} from 'lodash';
9
+ import {isEmpty, isEqual} from 'lodash';
10
10
  import type {View} from '../View';
11
11
  import type {ViewRowData} from '../ViewRowData';
12
12
 
@@ -27,6 +27,9 @@ import type {ViewRowData} from '../ViewRowData';
27
27
  * generated class per query keeps all leaf datas on a single shape with monomorphic,
28
28
  * inlinable reads.
29
29
  *
30
+ * Pivoted views add two more shapes, driven by `PivotCells` since they track the pivot structure
31
+ * rather than the query alone - see the Pivot section below.
32
+ *
30
33
  * @internal
31
34
  */
32
35
  export class RowDataGenerator {
@@ -67,6 +70,7 @@ export class RowDataGenerator {
67
70
  private init() {
68
71
  this.fieldNames = this.view.fieldNames;
69
72
  this.exposesLeaves = this.view.exposesLeaves;
73
+ this.cellFieldNames = this.cellFieldSignature();
70
74
  this.parentDataTemplate = this.buildParentDataTemplate();
71
75
  this.leafDataClass = this.buildLeafDataClass();
72
76
  }
@@ -76,6 +80,7 @@ export class RowDataGenerator {
76
80
  id: null,
77
81
  cubeRowType: null,
78
82
  cubeLabel: null,
83
+ cubeLabelValue: null,
79
84
  cubeDimension: null,
80
85
  cubeBuckets: null,
81
86
  children: null,
@@ -92,16 +97,99 @@ export class RowDataGenerator {
92
97
  private buildLeafDataClass(): LeafDataClass {
93
98
  if (!this.exposesLeaves) return null;
94
99
 
95
- class LeafRowData extends BaseLeafRowData {}
100
+ const cls = isEmpty(this.cellFieldNames)
101
+ ? class LeafRowData extends BaseLeafRowData {}
102
+ : this.buildPivotLeafDataClass();
103
+
104
+ // A prototype getter per queried field, reading through the own `_src` reference.
96
105
  this.view.fields.forEach(({name}) => {
97
- Object.defineProperty(LeafRowData.prototype, name, {
106
+ Object.defineProperty(cls.prototype, name, {
98
107
  get(this: PlainObject) {
99
108
  return this._src[name];
100
109
  },
101
110
  enumerable: true
102
111
  });
103
112
  });
104
- return LeafRowData;
113
+ return cls;
114
+ }
115
+
116
+ //------------------
117
+ // Pivot
118
+ //------------------
119
+ private cellFieldNames: string[] = null;
120
+ private cellAggNames: string[] = null;
121
+ private cellDataTemplate: PlainObject = null;
122
+
123
+ /**
124
+ * Create a cell row's data object from the shared template - the digest slot plus the measures
125
+ * cells aggregate, far narrower than a group row's shape.
126
+ */
127
+ newCellRowData(): PlainObject {
128
+ return {...this.cellDataTemplate};
129
+ }
130
+
131
+ /** Rebuild the cell template if the measures cells aggregate have moved. */
132
+ onCellAggFieldsChange() {
133
+ const names = this.view._pivot.cellAggFields.map(it => it.name);
134
+ if (this.cellAggNames && isEqual(this.cellAggNames, names)) return;
135
+
136
+ this.cellAggNames = names;
137
+
138
+ const data: PlainObject = {cubeRowDigest: null};
139
+ names.forEach(name => (data[name] = null));
140
+
141
+ // Clone into V8 fast-properties mode, as the parent template does.
142
+ this.cellDataTemplate = {...data};
143
+ }
144
+
145
+ /**
146
+ * Rebuild the exposed-leaf class if the cell field set has moved, returning true if it did.
147
+ * Called before any leaf is minted in a generation; the caller drops cached leaves on a true.
148
+ */
149
+ onCellFieldsChange(): boolean {
150
+ if (!this.exposesLeaves || isEqual(this.cellFieldNames, this.cellFieldSignature())) {
151
+ return false;
152
+ }
153
+
154
+ this.init();
155
+ return true;
156
+ }
157
+
158
+ private cellFieldSignature(): string[] {
159
+ return this.view._pivot?.cellFields.map(it => it.name) ?? [];
160
+ }
161
+
162
+ /**
163
+ * A leaf carries its own value for its full-depth path and every ancestor of it - the one path
164
+ * it belongs to at each depth - and null for the rest, read through prototype getters over one
165
+ * `_pivotPathIdx` slot so every leaf keeps a single hidden class. Root-path cell fields are
166
+ * skipped - their name is the measure's, whose getter already answers.
167
+ */
168
+ private buildPivotLeafDataClass(): LeafDataClass {
169
+ class PivotLeafRowData extends BaseLeafRowData {
170
+ // Index into `PivotCells.allPaths` of this leaf's full-depth path; -1 until placed.
171
+ _pivotPathIdx: number = -1;
172
+ }
173
+
174
+ const {_pivot} = this.view;
175
+ _pivot.cellFields.forEach(({name, path, measure}) => {
176
+ if (path.isRoot) return;
177
+
178
+ const pathIdx = _pivot.pathIdx.get(path),
179
+ valueName = measure.name;
180
+ Object.defineProperty(PivotLeafRowData.prototype, name, {
181
+ get(this: PlainObject) {
182
+ const {pathParentIdx} = _pivot;
183
+ for (let i = this._pivotPathIdx; i >= 0; i = pathParentIdx[i]) {
184
+ if (i === pathIdx) return this._src[valueName];
185
+ }
186
+ return null;
187
+ },
188
+ enumerable: true
189
+ });
190
+ });
191
+
192
+ return PivotLeafRowData;
105
193
  }
106
194
  }
107
195
 
@@ -131,6 +219,10 @@ class BaseLeafRowData implements ViewRowData {
131
219
  get cubeDimension(): string {
132
220
  return null;
133
221
  }
222
+ // A getter, not an own slot, so every leaf keeps the same shape.
223
+ get cubeLabelValue(): any {
224
+ return this.id;
225
+ }
134
226
  get children(): ViewRowData[] {
135
227
  return null;
136
228
  }
@@ -20,6 +20,8 @@ export class ViewDiagnostics extends BaseDiagnostics<View> {
20
20
  @observableRef accessor load: ViewOpStats = this.emptyStats();
21
21
  @observableRef accessor update: ViewOpStats = this.emptyStats();
22
22
  @observableRef accessor query: ViewOpStats = this.emptyStats();
23
+ /** Path discovery and cell build for the last generation of a pivoted view, else null. */
24
+ @observableRef accessor pivot: PivotOp = null;
23
25
 
24
26
  @action
25
27
  noteLoad(type: ViewOp['type'], start: number) {
@@ -36,11 +38,27 @@ export class ViewDiagnostics extends BaseDiagnostics<View> {
36
38
  this.query = this.note('query', this.query, type, start);
37
39
  }
38
40
 
41
+ /** Note the path discovery and cell build for one generation of a pivoted view. */
42
+ @action
43
+ notePivot(op: Omit<PivotOp, 'timestamp'>) {
44
+ this.pivot = {...op, timestamp: Date.now()};
45
+
46
+ const phases = Object.entries(op.phases)
47
+ .map(([name, ms]) => `${name} ${ms.toFixed(1)}`)
48
+ .join(' ');
49
+ this.logOp(
50
+ 'pivot',
51
+ {type: 'build', total: op.cells, elapsed: op.elapsed},
52
+ `paths ${op.paths} | ${phases}`
53
+ );
54
+ }
55
+
39
56
  @action
40
57
  reset() {
41
58
  this.load = this.emptyStats();
42
59
  this.update = this.emptyStats();
43
60
  this.query = this.emptyStats();
61
+ this.pivot = null;
44
62
  }
45
63
 
46
64
  private note(
@@ -96,3 +114,32 @@ export interface ViewOp {
96
114
  elapsed: number;
97
115
  timestamp: number;
98
116
  }
117
+
118
+ export interface PivotOp {
119
+ /** Nodes of the pivot path tree, including the synthetic root path. */
120
+ paths: number;
121
+
122
+ /** Cell rows materialized across the whole row hierarchy. */
123
+ cells: number;
124
+
125
+ /** Sum of `phases` - all pivot work, excluding base row generation. */
126
+ elapsed: number;
127
+
128
+ phases: PivotPhases;
129
+
130
+ timestamp: number;
131
+ }
132
+
133
+ /** Elapsed ms per phase of one pivot generation. Zero for phases a degenerate build skipped. */
134
+ export interface PivotPhases {
135
+ /** Path discovery over the filtered records, ahead of base row generation. */
136
+ discover: number;
137
+ /** Group enumeration and the per-record leaf alignment pass. */
138
+ align: number;
139
+ /** `buildPivotStructure` - planning the cell set and its links over integer arrays. */
140
+ plan: number;
141
+ /** Cell row instantiation or reuse, wiring, and clearing of vacated cells. */
142
+ build: number;
143
+ /** Projection of cell values onto owner rows. */
144
+ project: number;
145
+ }
@@ -0,0 +1,73 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2026 Extremely Heavy Industries Inc.
6
+ */
7
+
8
+ import type {PlainObject} from '@xh/hoist/core';
9
+ import type {CubeField} from '../CubeField';
10
+ import type {PivotPath} from './PivotPath';
11
+ import type {View} from '../View';
12
+ import type {BaseRow} from '../row/BaseRow';
13
+ import {ParentRow} from '../row/ParentRow';
14
+
15
+ /**
16
+ * Row for one `(group node, pivot path)` cell of a pivoted {@link View} - see `PivotCells`.
17
+ *
18
+ * A real row in the aggregation network, so aggregators and incremental updates work unmodified,
19
+ * but never part of the visible tree or a Store - its values are copied onto its owner row. Not an
20
+ * {@link AggregateRow}, so `omitFn` / `lockFn` never see it. Internal.
21
+ */
22
+ export class PivotCellRow extends ParentRow {
23
+ // Rebound on every reuse from `_rowCache` - the id pins what they name, not which object. Any
24
+ // state added here must be in the id, derived from `children`, or reassigned by PivotCells.
25
+ /** Group row this cell's value is projected onto. */
26
+ ownerRow: BaseRow;
27
+ path: PivotPath;
28
+
29
+ /** Cell field names last projected onto `ownerRow`, nulled by a generation that drops them. */
30
+ projectedCellNames: string[] = null;
31
+
32
+ protected get dimOrBucketName(): string {
33
+ return this.path.dimension?.name;
34
+ }
35
+
36
+ protected get dimOrBucketVal(): any {
37
+ return this.path.value;
38
+ }
39
+
40
+ // Cells aggregate the measures alone.
41
+ protected override get aggFields(): CubeField[] {
42
+ return this.view._pivot.cellAggFields;
43
+ }
44
+ protected override get aggFieldNames(): Set<string> {
45
+ return this.view._pivot.cellAggFieldNames;
46
+ }
47
+ protected override get canAggregateFnFields(): CubeField[] {
48
+ return this.view._pivot.cellCanAggregateFnFields;
49
+ }
50
+ protected override get complexAggFields(): CubeField[] {
51
+ return this.view._pivot.cellComplexAggFields;
52
+ }
53
+
54
+ // Parent links are assigned by PivotCells - children do not uniformly treat a cell as their
55
+ // group-axis parent.
56
+ protected override adoptChildren(children: BaseRow[]) {
57
+ this.children = children;
58
+ }
59
+
60
+ constructor(view: View, id: string, children: BaseRow[], ownerRow: BaseRow, path: PivotPath) {
61
+ super(view, id);
62
+
63
+ this.data = view._pivot.newCellRowData();
64
+ this.ownerRow = ownerRow;
65
+ this.path = path;
66
+
67
+ this.adoptChildren(children);
68
+ this.initData(EMPTY_DIMS, null);
69
+ }
70
+ }
71
+
72
+ /** Cells apply no dimension of their own; shared so each cell row does not allocate one. */
73
+ const EMPTY_DIMS: PlainObject = Object.freeze({});
@@ -0,0 +1,67 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2026 Extremely Heavy Industries Inc.
6
+ */
7
+
8
+ import type {CubeField} from '../CubeField';
9
+
10
+ /**
11
+ * One ordered tuple of pivot dimension values within a pivoted {@link View} result - e.g.
12
+ * `US >> Equity`. Maps to one rendered column or column group.
13
+ *
14
+ * Immutable and identity-stable while the pivot structure is unchanged, so consumers can skip
15
+ * rebuilding columns. Treat the tree as read-only.
16
+ *
17
+ * @see ViewResult.paths
18
+ */
19
+ export class PivotPath {
20
+ /** Pivot dimension at this depth. Null for the root path. */
21
+ readonly dimension: CubeField;
22
+
23
+ /** Raw dimension value, null for an empty (null / blank) segment. */
24
+ readonly value: any;
25
+
26
+ /** Escaped, delimiter-joined path key. '' for the root path. */
27
+ readonly key: string;
28
+
29
+ /** 0 for the root path, 1 for a top-level pivot value, and so on. */
30
+ readonly depth: number;
31
+
32
+ /** True where this segment stands for a null or blank dimension value. */
33
+ readonly isEmpty: boolean;
34
+
35
+ readonly children: PivotPath[] = [];
36
+
37
+ /** @internal - constructed by PivotCells. */
38
+ constructor(config: {
39
+ dimension: CubeField;
40
+ value: any;
41
+ key: string;
42
+ depth: number;
43
+ isEmpty: boolean;
44
+ }) {
45
+ Object.assign(this, config);
46
+ }
47
+
48
+ get isRoot(): boolean {
49
+ return this.depth === 0;
50
+ }
51
+ }
52
+
53
+ /**
54
+ * A single materialized measure within a pivoted {@link View} result - the pairing of a pivot path with
55
+ * a measure, and the synthetic field name its value is written to on row data.
56
+ *
57
+ * `CubeGridModel` declares one Store field per entry and binds value columns to `name`.
58
+ */
59
+ export interface PivotCellField {
60
+ /** Field name on published row data. The measure's own name at the root path. */
61
+ name: string;
62
+
63
+ path: PivotPath;
64
+
65
+ /** Source measure - supplies type and defaultValue when declaring Store fields. */
66
+ measure: CubeField;
67
+ }