@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.
- package/CHANGELOG.md +136 -54
- package/admin/columns/Tracking.ts +9 -3
- package/admin/tabs/activity/tracking/ActivityTrackingModel.ts +155 -47
- package/admin/tabs/activity/tracking/ActivityTrackingPanel.ts +25 -4
- package/admin/tabs/activity/tracking/chart/AggChartModel.ts +2 -3
- package/appcontainer/ImpersonationBarModel.ts +8 -5
- package/build/types/admin/tabs/activity/tracking/ActivityTrackingModel.d.ts +25 -5
- package/build/types/cmp/cubegrid/CubeGrid.d.ts +26 -0
- package/build/types/cmp/cubegrid/CubeGridModel.d.ts +103 -0
- package/build/types/cmp/cubegrid/CubeGridPivotModel.d.ts +181 -0
- package/build/types/cmp/cubegrid/Types.d.ts +85 -0
- package/build/types/cmp/cubegrid/index.d.ts +4 -0
- package/build/types/cmp/dataview/DataViewModel.d.ts +6 -10
- package/build/types/cmp/grid/GridModel.d.ts +8 -33
- package/build/types/cmp/grid/Types.d.ts +51 -1
- package/build/types/cmp/grid/columns/Column.d.ts +2 -1
- package/build/types/cmp/grid/columns/ColumnGroup.d.ts +6 -0
- package/build/types/cmp/grid/helpers/GridCountLabel.d.ts +6 -3
- package/build/types/cmp/grid/impl/ColumnWidthCalculator.d.ts +6 -0
- package/build/types/cmp/grid/impl/GridLikeModel.d.ts +3 -0
- package/build/types/cmp/grid/impl/MenuSupport.d.ts +13 -0
- package/build/types/cmp/pdfviewer/PdfViewer.d.ts +14 -0
- package/build/types/cmp/pdfviewer/PdfViewerModel.d.ts +150 -0
- package/build/types/cmp/pdfviewer/Types.d.ts +55 -0
- package/build/types/cmp/pdfviewer/impl/PdfFindInputModel.d.ts +14 -0
- package/build/types/cmp/pdfviewer/impl/PdfViewerToolbarModel.d.ts +34 -0
- package/build/types/cmp/pdfviewer/impl/ZoomOptions.d.ts +10 -0
- package/build/types/cmp/pdfviewer/index.d.ts +3 -0
- package/build/types/cmp/statcard/StatCard.d.ts +90 -0
- package/build/types/cmp/statcard/index.d.ts +1 -0
- package/build/types/cmp/store/StoreFilterField.d.ts +8 -9
- package/build/types/cmp/store/impl/StoreFilterFieldImplModel.d.ts +4 -4
- package/build/types/cmp/zoneGrid/ZoneGridModel.d.ts +6 -10
- package/build/types/core/types/Types.d.ts +6 -0
- package/build/types/data/Field.d.ts +8 -1
- package/build/types/data/Store.d.ts +12 -0
- package/build/types/data/cube/Cube.d.ts +2 -0
- package/build/types/data/cube/CubeField.d.ts +3 -2
- package/build/types/data/cube/Query.d.ts +66 -4
- package/build/types/data/cube/View.d.ts +82 -4
- package/build/types/data/cube/ViewRowData.d.ts +13 -0
- package/build/types/data/cube/aggregate/MedianAggregator.d.ts +19 -0
- package/build/types/data/cube/aggregate/SumIfSameAggregator.d.ts +30 -0
- package/build/types/data/cube/impl/RowCache.d.ts +5 -0
- package/build/types/data/cube/impl/RowDataGenerator.d.ts +26 -0
- package/build/types/data/cube/impl/ViewDiagnostics.d.ts +27 -0
- package/build/types/data/cube/pivot/PivotCellRow.d.ts +27 -0
- package/build/types/data/cube/pivot/PivotPath.d.ts +45 -0
- package/build/types/data/cube/pivot/impl/PivotCells.d.ts +111 -0
- package/build/types/data/cube/pivot/impl/PivotReference.d.ts +39 -0
- package/build/types/data/cube/pivot/impl/PivotStructure.d.ts +105 -0
- package/build/types/data/cube/row/BaseRow.d.ts +12 -0
- package/build/types/data/cube/row/LeafRow.d.ts +4 -4
- package/build/types/data/cube/row/ParentRow.d.ts +20 -4
- package/build/types/data/cube/row/RowUpdate.d.ts +2 -0
- package/build/types/data/index.d.ts +3 -0
- package/build/types/desktop/cmp/button/grid/ColAutosizeButton.d.ts +6 -3
- package/build/types/desktop/cmp/button/grid/ColChooserButton.d.ts +7 -3
- package/build/types/desktop/cmp/button/grid/ExpandToLevelButton.d.ts +6 -3
- package/build/types/desktop/cmp/button/grid/ExportButton.d.ts +6 -3
- package/build/types/desktop/cmp/grid/find/GridFindField.d.ts +8 -9
- package/build/types/desktop/cmp/grid/find/impl/GridFindFieldImplModel.d.ts +3 -4
- package/build/types/desktop/cmp/pdfviewer/impl/PdfViewerToolbar.d.ts +12 -0
- package/build/types/desktop/cmp/statcard/impl/StatCardInfoImpl.d.ts +12 -0
- package/build/types/dynamics/desktop.d.ts +2 -0
- package/build/types/dynamics/mobile.d.ts +1 -0
- package/build/types/icon/Icon.d.ts +12 -0
- package/build/types/kit/pdfjs/index.d.ts +23 -0
- package/build/types/kit/pdfjs/styles.d.ts +2 -0
- package/build/types/kit/swiper/index.d.ts +7 -7
- package/build/types/mobile/cmp/button/grid/ColAutosizeButton.d.ts +6 -3
- package/build/types/mobile/cmp/button/grid/ColChooserButton.d.ts +6 -3
- package/build/types/mobile/cmp/button/grid/ExpandCollapseButton.d.ts +4 -4
- package/build/types/mobile/cmp/button/grid/ExpandToLevelButton.d.ts +4 -4
- package/build/types/mobile/cmp/pdfviewer/impl/PdfViewerToolbar.d.ts +12 -0
- package/cmp/README.md +3 -0
- package/cmp/ag-grid/AgGrid.ts +25 -3
- package/cmp/cubegrid/CubeGrid.ts +60 -0
- package/cmp/cubegrid/CubeGridModel.ts +365 -0
- package/cmp/cubegrid/CubeGridPivotModel.ts +943 -0
- package/cmp/cubegrid/README.md +343 -0
- package/cmp/cubegrid/Types.ts +105 -0
- package/cmp/cubegrid/index.ts +10 -0
- package/cmp/dataview/DataViewModel.ts +13 -8
- package/cmp/grid/Grid.scss +21 -5
- package/cmp/grid/GridModel.ts +41 -47
- package/cmp/grid/Types.ts +58 -1
- package/cmp/grid/columns/Column.ts +3 -1
- package/cmp/grid/columns/ColumnGroup.ts +10 -0
- package/cmp/grid/helpers/GridCountLabel.ts +12 -5
- package/cmp/grid/impl/ColumnGroupHeader.ts +18 -4
- package/cmp/grid/impl/ColumnWidthCalculator.ts +24 -0
- package/cmp/grid/impl/GridLikeModel.ts +17 -0
- package/cmp/grid/impl/MenuSupport.ts +36 -20
- package/cmp/pdfviewer/PdfViewer.scss +48 -0
- package/cmp/pdfviewer/PdfViewer.ts +102 -0
- package/cmp/pdfviewer/PdfViewerModel.ts +641 -0
- package/cmp/pdfviewer/README.md +224 -0
- package/cmp/pdfviewer/Types.ts +72 -0
- package/cmp/pdfviewer/impl/PdfFindInputModel.ts +44 -0
- package/cmp/pdfviewer/impl/PdfViewerToolbarModel.ts +45 -0
- package/cmp/pdfviewer/impl/ZoomOptions.ts +36 -0
- package/cmp/pdfviewer/index.ts +9 -0
- package/cmp/statcard/StatCard.scss +181 -0
- package/cmp/statcard/StatCard.ts +320 -0
- package/cmp/statcard/index.ts +1 -0
- package/cmp/store/StoreFilterField.ts +8 -9
- package/cmp/store/impl/StoreFilterFieldImplModel.ts +14 -14
- package/cmp/zoneGrid/ZoneGridModel.ts +13 -8
- package/core/types/Types.ts +7 -0
- package/data/Field.ts +10 -0
- package/data/Store.ts +25 -2
- package/data/cube/Cube.ts +5 -0
- package/data/cube/CubeField.ts +5 -0
- package/data/cube/Query.ts +170 -17
- package/data/cube/README.md +77 -2
- package/data/cube/View.ts +211 -32
- package/data/cube/ViewRowData.ts +22 -0
- package/data/cube/aggregate/MedianAggregator.ts +88 -0
- package/data/cube/aggregate/SumIfSameAggregator.ts +128 -0
- package/data/cube/impl/RowCache.ts +32 -11
- package/data/cube/impl/RowDataGenerator.ts +96 -4
- package/data/cube/impl/ViewDiagnostics.ts +47 -0
- package/data/cube/pivot/PivotCellRow.ts +73 -0
- package/data/cube/pivot/PivotPath.ts +67 -0
- package/data/cube/pivot/impl/PivotCells.ts +538 -0
- package/data/cube/pivot/impl/PivotReference.ts +125 -0
- package/data/cube/pivot/impl/PivotStructure.ts +500 -0
- package/data/cube/row/BaseRow.ts +26 -0
- package/data/cube/row/LeafRow.ts +9 -8
- package/data/cube/row/ParentRow.ts +58 -25
- package/data/cube/row/RowUpdate.ts +8 -0
- package/data/index.ts +3 -0
- package/desktop/appcontainer/AppContainer.ts +5 -1
- package/desktop/cmp/button/grid/ColAutosizeButton.ts +21 -5
- package/desktop/cmp/button/grid/ColChooserButton.ts +11 -5
- package/desktop/cmp/button/grid/ExpandToLevelButton.ts +20 -5
- package/desktop/cmp/button/grid/ExportButton.ts +19 -7
- package/desktop/cmp/dash/canvas/DashCanvas.ts +26 -2
- package/desktop/cmp/grid/find/GridFindField.ts +8 -9
- package/desktop/cmp/grid/find/impl/GridFindFieldImplModel.ts +15 -16
- package/desktop/cmp/grid/impl/colchooser/ColChooserBucketModel.ts +1 -1
- package/desktop/cmp/pdfviewer/impl/PdfViewerToolbar.ts +190 -0
- package/desktop/cmp/statcard/impl/StatCardInfoImpl.ts +27 -0
- package/docs/README.md +6 -2
- package/docs/doc-registry.json +21 -5
- package/docs/upgrade-notes/v90-upgrade-notes.md +130 -0
- package/docs/version-compatibility.md +2 -1
- package/dynamics/desktop.ts +4 -0
- package/dynamics/mobile.ts +2 -0
- package/format/FormatNumber.ts +6 -2
- package/icon/Icon.ts +18 -0
- package/icon/index.ts +32 -0
- package/kit/README.md +2 -0
- package/kit/pdfjs/PdfJs.scss +25 -0
- package/kit/pdfjs/index.ts +103 -0
- package/kit/pdfjs/pdf_viewer.css +6481 -0
- package/kit/pdfjs/styles.ts +12 -0
- package/mcp/README.md +13 -0
- package/mcp/data/import-paths.ts +4 -8
- package/mcp/data/index-cache.ts +2 -1
- package/mcp/data/ts-registry.ts +8 -29
- package/mcp/util/paths.ts +26 -0
- package/mobile/appcontainer/AppContainer.ts +3 -1
- package/mobile/cmp/button/grid/ColAutosizeButton.ts +20 -5
- package/mobile/cmp/button/grid/ColChooserButton.ts +12 -5
- package/mobile/cmp/button/grid/ExpandCollapseButton.ts +10 -6
- package/mobile/cmp/button/grid/ExpandToLevelButton.ts +10 -6
- package/mobile/cmp/pdfviewer/impl/PdfViewerToolbar.ts +137 -0
- package/package.json +14 -8
- package/public/msal-redirect-bridge.min.js +1 -1
- 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
|
|
143
|
-
//
|
|
144
|
-
if (fieldsGained ||
|
|
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
|
|
152
|
-
//
|
|
153
|
-
|
|
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
|
|
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
|
-
|
|
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(
|
|
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
|
|
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
|
+
}
|