@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
@@ -7,7 +7,7 @@
7
7
  import {dataFieldsEditor} from '@xh/hoist/admin/tabs/activity/tracking/datafields/DataFieldsEditor';
8
8
  import {errorMessage} from '@xh/hoist/cmp/error';
9
9
  import {form} from '@xh/hoist/cmp/form';
10
- import {grid} from '@xh/hoist/cmp/grid';
10
+ import {cubeGrid} from '@xh/hoist/cmp/cubegrid';
11
11
  import {div, filler, hframe} from '@xh/hoist/cmp/layout';
12
12
  import {creates, hoistCmp} from '@xh/hoist/core';
13
13
  import {button, colChooserButton, exportButton} from '@xh/hoist/desktop/cmp/button';
@@ -111,13 +111,34 @@ const aggregateView = hoistCmp.factory<ActivityTrackingModel>(({model}) => {
111
111
  compact: true,
112
112
  items: [
113
113
  groupingChooser({flex: 10, maxWidth: 300}),
114
+ select({
115
+ bind: 'pivotBy',
116
+ options: model.pivotByOptions,
117
+ // Count shown in the menu only - the control reads better without it.
118
+ valueRenderer: opt => opt.displayName,
119
+ placeholder: 'Pivot by...',
120
+ enableClear: true,
121
+ enableFilter: false,
122
+ width: 150
123
+ }),
124
+ select({
125
+ bind: 'pivotMeasures',
126
+ options: model.pivotMeasureOptions,
127
+ enableMulti: true,
128
+ enableClear: false,
129
+ enableFilter: false,
130
+ hideDropdownIndicator: true,
131
+ placeholder: 'Measures...',
132
+ width: 260,
133
+ omit: !model.pivotBy
134
+ }),
114
135
  filler(),
115
- colChooserButton(),
116
- exportButton()
136
+ colChooserButton({gridModel: model.cubeGridModel}),
137
+ exportButton({gridModel: model.cubeGridModel})
117
138
  ]
118
139
  }),
119
140
  items: [
120
- grid({flex: 1}),
141
+ cubeGrid({flex: 1, model: model.cubeGridModel}),
121
142
  div({
122
143
  className: 'xh-admin-activity-panel__max-rows-alert',
123
144
  items: [
@@ -120,8 +120,7 @@ export class AggChartModel extends HoistModel {
120
120
  }
121
121
 
122
122
  private get data() {
123
- const roots = this.activityTrackingModel.gridModel.store.allRootRecords;
124
- return roots.length ? roots[0].children : [];
123
+ return this.activityTrackingModel.cubeGridModel.store.allRootRecords;
125
124
  }
126
125
 
127
126
  private createChartModel(): ChartModel {
@@ -147,7 +146,7 @@ export class AggChartModel extends HoistModel {
147
146
 
148
147
  private selectRow(e) {
149
148
  const id = `root>>${this.primaryDim}=[${e.point.name}]`;
150
- this.activityTrackingModel.gridModel.selectAsync(id);
149
+ this.activityTrackingModel.cubeGridModel.selectAsync(id);
151
150
  }
152
151
 
153
152
  private loadChart() {
@@ -20,15 +20,17 @@ export class ImpersonationBarModel extends HoistModel {
20
20
  override xhName = 'impersonationBarModel';
21
21
 
22
22
  @observable accessor showRequested: boolean = false;
23
- @observableRef accessor targets: string[] = [];
23
+ @observableRef accessor targets: string[] = null;
24
24
  @bindable accessor pendingTarget: string = null;
25
25
 
26
26
  // For managed focus of desktop select.
27
27
  inputRef = createRef<HoistInputModel>();
28
28
 
29
29
  init() {
30
- this.addAutorun(() => {
31
- if (this.isOpen) {
30
+ this.addReaction({
31
+ track: () => this.isOpen,
32
+ run: isOpen => {
33
+ if (!isOpen) return;
32
34
  this.ensureTargetsLoaded();
33
35
 
34
36
  // We don't have an impersonation message on mobile, so instead we
@@ -36,7 +38,8 @@ export class ImpersonationBarModel extends HoistModel {
36
38
  if (XH.isMobileApp && XH.identityService.isImpersonating) {
37
39
  this.pendingTarget = XH.getUsername();
38
40
  }
39
- }
41
+ },
42
+ fireImmediately: true
40
43
  });
41
44
  }
42
45
 
@@ -89,7 +92,7 @@ export class ImpersonationBarModel extends HoistModel {
89
92
  // Implementation
90
93
  //--------------------
91
94
  private ensureTargetsLoaded() {
92
- if (this.targets.length) return;
95
+ if (this.targets) return;
93
96
 
94
97
  this.runner()
95
98
  .span('impersonationTargets')
@@ -4,9 +4,9 @@ import { DateRangePickerModel } from '@xh/hoist/cmp/daterange';
4
4
  import { FilterChooserModel } from '@xh/hoist/cmp/filter';
5
5
  import { FormModel } from '@xh/hoist/cmp/form';
6
6
  import type { ColumnSpec } from '@xh/hoist/cmp/grid';
7
- import { GridModel } from '@xh/hoist/cmp/grid';
7
+ import { CubeGridModel } from '@xh/hoist/cmp/cubegrid';
8
8
  import { GroupingChooserModel } from '@xh/hoist/cmp/grouping';
9
- import type { LoadSpec, PlainObject } from '@xh/hoist/core';
9
+ import type { LoadSpec, PlainObject, SelectOption } from '@xh/hoist/core';
10
10
  import { HoistModel } from '@xh/hoist/core';
11
11
  import { Cube } from '@xh/hoist/data';
12
12
  import type { ActivityDetailProvider } from './detail/ActivityDetailModel';
@@ -20,8 +20,12 @@ export declare class ActivityTrackingModel extends HoistModel implements Activit
20
20
  accessor groupingChooserModel: GroupingChooserModel;
21
21
  accessor cube: Cube;
22
22
  accessor filterChooserModel: FilterChooserModel;
23
- accessor gridModel: GridModel;
23
+ accessor cubeGridModel: CubeGridModel;
24
24
  dataFieldsEditorModel: DataFieldsEditorModel;
25
+ /** Dimension to pivot into columns, or null for the standard grouped grid. */
26
+ accessor pivotBy: string;
27
+ /** Measures shown per pivot value, at most `PIVOT_MAX_MEASURES`. */
28
+ accessor pivotMeasures: string[];
25
29
  /**
26
30
  * Optional spec for fields to be extracted from additional `data` returned by track entries
27
31
  * and promoted to top-level columns in the grids. Supports dot-delimited paths as names.
@@ -31,6 +35,15 @@ export declare class ActivityTrackingModel extends HoistModel implements Activit
31
35
  accessor showFilterChooser: boolean;
32
36
  get enabled(): boolean;
33
37
  get dimensions(): string[];
38
+ /**
39
+ * Dimensions available to pivot on, carrying their distinct value count in the loaded data.
40
+ * Those already grouping the rows are left out. Those with a single value, which would only
41
+ * repeat the row summary, or too many to read are disabled.
42
+ */
43
+ get pivotByOptions(): SelectOption[];
44
+ /** Distinct value count per pivotable dimension, over the records currently loaded. */
45
+ private get pivotCardinality();
46
+ get pivotMeasureOptions(): SelectOption[];
34
47
  get hasFilter(): boolean;
35
48
  get maxRowOptions(): {
36
49
  value: number;
@@ -47,19 +60,26 @@ export declare class ActivityTrackingModel extends HoistModel implements Activit
47
60
  constructor();
48
61
  doLoadAsync(loadSpec: LoadSpec): Promise<void>;
49
62
  setDataFields(dataFields: ActivityTrackingDataFieldSpec[]): void;
63
+ /** Keeps the most recent picks, so a third choice replaces the oldest. */
64
+ setPivotMeasures(measures: string[]): void;
50
65
  toggleFilterChooser(): void;
51
66
  getDisplayName(fieldName: string): string;
52
67
  private createQueryFormModel;
53
68
  private createDateRangePickerModel;
54
- private loadGridAsync;
55
69
  private cubeLabelComparator;
56
70
  private getComparableValForDim;
57
71
  private get query();
72
+ /**
73
+ * Requery the view to match the grouping and pivot controls. The grid follows on its own, and
74
+ * shows the path cap's error in its place if the pivot outgrows it.
75
+ */
76
+ private syncQuery;
77
+ private get queryConfig();
58
78
  private createAndSetCoreModels;
59
79
  private createCube;
60
80
  private createFilterChooserModel;
61
81
  private createGroupingChooserModel;
62
- private createGridModel;
82
+ private createCubeGridModel;
63
83
  private processRawTrackLog;
64
84
  private getDfRenderer;
65
85
  }
@@ -0,0 +1,26 @@
1
+ import type { HoistProps, LayoutProps, TestSupportProps } from '@xh/hoist/core';
2
+ import type { GridOptions } from '@xh/hoist/kit/ag-grid';
3
+ import { CubeGridModel } from './CubeGridModel';
4
+ export interface CubeGridProps<M extends CubeGridModel = CubeGridModel> extends HoistProps<M>, LayoutProps, TestSupportProps {
5
+ /**
6
+ * Options for ag-Grid's API.
7
+ *
8
+ * This constitutes an 'escape hatch' for applications that need to get to the underlying
9
+ * ag-Grid API. It should be used with care. Settings made here might be overwritten and/or
10
+ * interfere with the implementation of this component and its use of the ag-Grid API.
11
+ *
12
+ * Note that changes to these options after the component's initial render will be ignored.
13
+ */
14
+ agOptions?: GridOptions;
15
+ }
16
+ /**
17
+ * A CubeGrid is a specialized version of the Grid component, bound to a Cube View.
18
+ *
19
+ * It displays group rows down a tree column with the app's columns and, when the view's query
20
+ * pivots, pivot paths across nested column groups with optional docked summaries. See
21
+ * {@link CubeGridModel} for its configuration.
22
+ *
23
+ * While the view declines its data - see {@link ViewResult.exception} - an {@link ErrorMessage}
24
+ * renders in place of the grid.
25
+ */
26
+ export declare const CubeGrid: import("react").FC<CubeGridProps<CubeGridModel>>, cubeGrid: import("@xh/hoist/core").ElementFactory<CubeGridProps<CubeGridModel>>;
@@ -0,0 +1,103 @@
1
+ import type { ColumnGroupSpec, ColumnSpec, GridConfig, GridEnsureVisibleOptions, GridFilterBindTarget, GridFilterModelConfig, GridLikeModel, GridSelectFirstOptions, GridSelectOptions } from '@xh/hoist/cmp/grid';
2
+ import { GridModel } from '@xh/hoist/cmp/grid';
3
+ import type { Some, VSide } from '@xh/hoist/core';
4
+ import { HoistModel } from '@xh/hoist/core';
5
+ import type { Cube, QueryConfig, Store, StoreRecordOrId, View } from '@xh/hoist/data';
6
+ import type { CubeGridPivotConfig } from './CubeGridPivotModel';
7
+ import { CubeGridPivotModel } from './CubeGridPivotModel';
8
+ /**
9
+ * Configuration for a {@link CubeGridModel}.
10
+ *
11
+ * Supply the data as either an existing `view` or a `cube` with a `query`. Query configuration -
12
+ * `dimensions`, `pivot`, `includeRoot` and the rest - lives on the {@link Query}, and apps
13
+ * reconfigure by calling `view.updateQuery()`. Everything else here is presentational.
14
+ *
15
+ * @see CubeGridModel
16
+ */
17
+ export interface CubeGridConfig {
18
+ /**
19
+ * View supplying this grid's data. Owned by the *application* - this model neither manages nor
20
+ * destroys it, and cannot swap it after construction. Two CubeGridModels may bind to one view;
21
+ * each mints its own Store. Omit to create a view from `cube` and `query` instead.
22
+ */
23
+ view?: View;
24
+ /** Cube to query, when no `view` is supplied. The model creates and owns a connected View. */
25
+ cube?: Cube;
26
+ /** Query for the view this model creates from `cube`. Ignored when `view` is supplied. */
27
+ query?: QueryConfig;
28
+ /**
29
+ * Columns for the fixed region, as on {@link GridConfig.columns}. Bind them to the view's
30
+ * fields - a measure's bare name is its row summary, whether or not the query pivots. When
31
+ * none is a tree column, a label column for the row dimensions is placed first. Pivot columns,
32
+ * if any, follow this region.
33
+ */
34
+ columns?: Array<ColumnSpec | ColumnGroupSpec>;
35
+ /**
36
+ * Config for the underlying GridModel. `store`, `treeMode` and `columns` are managed by this
37
+ * model and cannot be set here; everything else is a default this config overrides. A
38
+ * `showSummary` row needs `includeRoot` on the query, which is what produces it. `persistWith`
39
+ * attaches once the pivot columns exist, so saved state can name them.
40
+ *
41
+ * A `filterModel` binds to `'view'` by default, filtering the source records and
42
+ * re-aggregating. Bind it to `'store'` to filter the group rows by their aggregates instead.
43
+ */
44
+ gridConfig?: Omit<GridConfig, 'store' | 'treeMode' | 'columns' | 'filterModel'> & {
45
+ filterModel?: boolean | (Omit<GridFilterModelConfig, 'bind'> & {
46
+ bind?: GridFilterBindTarget | 'view' | 'store';
47
+ });
48
+ };
49
+ /** Config for the pivot region, held by {@link CubeGridModel.pivotModel}. */
50
+ pivotConfig?: CubeGridPivotConfig;
51
+ }
52
+ /**
53
+ * Grid presentation of a Cube {@link View} - a tree grid of group rows with the app's own columns,
54
+ * and when the query sets {@link QueryConfig.pivot}, a column group per pivot path appended to
55
+ * their right, with optional docked summaries.
56
+ *
57
+ * Owns everything downstream of the view: the Store, the {@link GridModel} and the column
58
+ * hierarchy, rebuilt when `result.paths` changes identity. Owns the view too when created from
59
+ * `cube` and `query`.
60
+ *
61
+ * @see CubeGridConfig
62
+ * @mcpHint tree grid on a Cube view - app columns, plus pivot paths as column groups when pivoted
63
+ */
64
+ export declare class CubeGridModel extends HoistModel implements GridLikeModel {
65
+ /** View supplying this grid's data. Not swappable. */
66
+ readonly view: View;
67
+ accessor columns: Array<ColumnSpec | ColumnGroupSpec>;
68
+ /** Store projecting the view's rows. Owned here - GridModel never manages a store instance. */
69
+ readonly store: Store;
70
+ readonly gridModel: GridModel;
71
+ readonly pivotModel: CubeGridPivotModel;
72
+ constructor({ view, cube, query, columns, gridConfig, pivotConfig }: CubeGridConfig);
73
+ get innerGridModel(): GridModel;
74
+ get empty(): boolean;
75
+ /** The grid's summary row, as {@link GridModel.showSummary}. Needs `includeRoot` on the query. */
76
+ get showSummary(): boolean | VSide;
77
+ setShowSummary(v: boolean | VSide): void;
78
+ get selModel(): import("@xh/hoist/data").StoreSelectionModel;
79
+ get hasSelection(): boolean;
80
+ get selectedRecords(): import("@xh/hoist/data").StoreRecord[];
81
+ get selectedRecord(): import("@xh/hoist/data").StoreRecord;
82
+ get selectedId(): import("@xh/hoist/data").StoreRecordId;
83
+ selectAsync(records: Some<StoreRecordOrId>, opts?: GridSelectOptions): Promise<void>;
84
+ preSelectFirstAsync(): Promise<void>;
85
+ selectFirstAsync(opts?: GridSelectFirstOptions): Promise<void>;
86
+ ensureSelectionVisibleAsync(opts?: GridEnsureVisibleOptions): Promise<void>;
87
+ private get query();
88
+ private columnsReaction;
89
+ private createGridModel;
90
+ private get rowLevelLabels();
91
+ private parseHeaderContextMenu;
92
+ private parseFilterModel;
93
+ private restoreDefaultsAsync;
94
+ private rebuildColumns;
95
+ private regionsReaction;
96
+ private enforceRegions;
97
+ private initPersistWhenReady;
98
+ private buildColumns;
99
+ private buildFixedColumns;
100
+ private buildLabelColumn;
101
+ private _pendingPersistWith;
102
+ destroy(): void;
103
+ }
@@ -0,0 +1,181 @@
1
+ import type { ColumnGroupSpec, ColumnSpec } from '@xh/hoist/cmp/grid';
2
+ import { HoistModel } from '@xh/hoist/core';
3
+ import type { CubeField } from '@xh/hoist/data';
4
+ import type { GetMainMenuItemsParams } from '@xh/hoist/kit/ag-grid';
5
+ import type { CubeGridModel } from './CubeGridModel';
6
+ import type { PivotLinkedSizingOptions, PivotDimensionSpec, PivotMeasureSpec } from './Types';
7
+ /**
8
+ * Configuration for the pivot region of a {@link CubeGridModel}, as `gridConfig` is for its
9
+ * GridModel. Applies when the query sets {@link QueryConfig.pivot}.
10
+ *
11
+ * @see CubeGridPivotModel
12
+ */
13
+ export interface CubeGridPivotConfig {
14
+ /**
15
+ * The dimensions this grid can pivot on, in the order to offer them, with settings for each
16
+ * over `dimensionDefaults`. A dimension's settings follow it to whatever level the query
17
+ * pivots it at. Entries the query does not pivot on are ignored, and a pivot on a dimension
18
+ * not listed takes the defaults. See {@link CubeGridPivotModel.availableDimensions}.
19
+ */
20
+ dimensions?: PivotDimensionSpec[];
21
+ /**
22
+ * Defaults for every pivot dimension, under its own settings in `dimensions` - sort,
23
+ * collapsing, summaries shown while expanded, labels and classes.
24
+ */
25
+ dimensionDefaults?: Omit<PivotDimensionSpec, 'field'>;
26
+ /**
27
+ * The measures this grid can pivot, in display order, with settings for each over
28
+ * `measureDefaults` - chiefly the column config applied to every pivot column built for it
29
+ * under every path. Measures the query pivots without an entry follow in query order. See
30
+ * {@link CubeGridPivotModel.availableMeasures}.
31
+ *
32
+ * Pivot columns are not hideable and stay out of the column chooser - the region is the
33
+ * query's, so drop a measure from `pivot.measures` to remove its columns.
34
+ */
35
+ measures?: PivotMeasureSpec[];
36
+ /** Defaults for every pivot measure, under its own settings in `measures`. */
37
+ measureDefaults?: Omit<PivotMeasureSpec, 'field'>;
38
+ /**
39
+ * True to put each measure outermost, with the pivot paths beneath it, to compare one measure
40
+ * across paths. Default false, nesting the measures under each path. Applies only with
41
+ * multiple measures - a single measure is always laid out outermost. Outermost, each measure
42
+ * is a root group that collapses to its own row summary, with no group over the whole region,
43
+ * so the header is one level shallower. Leaf paths head their columns directly, and
44
+ * summaries are single columns, so `showCollapsedLabel` has no effect.
45
+ */
46
+ measuresOutermost?: boolean;
47
+ /**
48
+ * True (default) to head the pivot region with a root group, titled by the measure and first
49
+ * pivot dimension, that collapses to the row summary. False to drop it, saving a header row -
50
+ * the top-level path groups head the region directly, with the row summary beside them only
51
+ * if the first dimension's `showSummary` asks for it. Ignored with multiple measures
52
+ * outermost, as their root groups are what name the measures.
53
+ */
54
+ showRootGroup?: boolean;
55
+ /**
56
+ * True (default) to link every pivot column of a measure to one width, or options to tune it.
57
+ * The width is the measure's widest data, plus an even share of any room a displayed pivot
58
+ * label needs beyond the data of the columns it spans, up to `headerFitMaxWidth`. It follows
59
+ * as groups expand and collapse, and a manual resize moves all of the measure's columns. False
60
+ * to size each column on its own, as in any grid.
61
+ */
62
+ linkedSizing?: boolean | PivotLinkedSizingOptions;
63
+ /**
64
+ * Pivot header level to expand to on initial load, as {@link GridConfig.expandLevel} is for
65
+ * rows. 0 collapses the region to the row summary, 1 shows the top-level pivot groups
66
+ * collapsed to theirs, and so on. Default -1, all levels expanded. Initial state only -
67
+ * thereafter {@link GridModel.columnGroupState} tracks each group, keyed on its path, and
68
+ * persists it with `gridConfig.persistWith`. See {@link CubeGridPivotModel.expandToLevel}.
69
+ */
70
+ expandLevel?: number;
71
+ }
72
+ /**
73
+ * The pivot region of a {@link CubeGridModel} - its options, bindable for toolbar controls, and
74
+ * the column groups built from them: their paths, summaries, shared widths and expansion. Created
75
+ * by the CubeGridModel from its `pivotConfig`, which merges the region into its grid's columns.
76
+ *
77
+ * @see CubeGridPivotConfig
78
+ */
79
+ export declare class CubeGridPivotModel extends HoistModel {
80
+ /** Pivot header level last expanded to, or -1 for all. Set via {@link expandToLevel}. */
81
+ accessor expandLevel: number;
82
+ accessor dimensions: PivotDimensionSpec[];
83
+ accessor dimensionDefaults: Omit<PivotDimensionSpec, 'field'>;
84
+ accessor measures: PivotMeasureSpec[];
85
+ accessor measureDefaults: Omit<PivotMeasureSpec, 'field'>;
86
+ accessor measuresOutermost: boolean;
87
+ accessor showRootGroup: boolean;
88
+ accessor linkedSizing: boolean | PivotLinkedSizingOptions;
89
+ private readonly cubeGridModel;
90
+ /** @internal - created by {@link CubeGridModel}. */
91
+ constructor({ dimensions, dimensionDefaults, measures, measureDefaults, measuresOutermost, showRootGroup, linkedSizing, expandLevel }: CubeGridPivotConfig, cubeGridModel: CubeGridModel);
92
+ /**
93
+ * Expand the pivot column groups to the given level, or all for -1, as
94
+ * {@link GridModel.expandToLevel} does for rows. The region is level 0 and each path group
95
+ * the level of its depth. Later rebuilds mint new groups at this level too.
96
+ */
97
+ expandToLevel(level: number): void;
98
+ expandAll(): void;
99
+ collapseAll(): void;
100
+ /** @internal - number of pivot dimensions, or 0 when the region is empty. */
101
+ get maxDepth(): number;
102
+ /**
103
+ * @internal - labels for each level in {@link expandToLevel}, naming the pivot dimension it
104
+ * shows. Level 0 shows none and has no label - {@link collapseAll} reaches it.
105
+ */
106
+ get resolvedLevelLabels(): string[];
107
+ /** @internal - true if the level is current, as {@link GridModel.isCurrentExpandLevel}. */
108
+ isCurrentExpandLevel(idx: number): boolean;
109
+ /** @internal - true if a header menu's column or group lies within the pivot region. */
110
+ isInRegion({ column, columnGroup }: GetMainMenuItemsParams): boolean;
111
+ /**
112
+ * Dimensions to offer for pivoting - those listed in `dimensions`, or all of the cube's
113
+ * dimensions if none are.
114
+ */
115
+ get availableDimensions(): CubeField[];
116
+ /**
117
+ * Measures to offer for pivoting - those listed in `measures`, or all of the cube's measures
118
+ * if none are.
119
+ */
120
+ get availableMeasures(): CubeField[];
121
+ /** @internal - options the built region depends on, tracked by the parent's rebuild. */
122
+ get regionDeps(): unknown[];
123
+ /** @internal - leaf colIds of the built region. */
124
+ get colIds(): Set<string>;
125
+ /** @internal - the width shared by the column's measure, if one has been applied. */
126
+ widthFor(colId: string): number;
127
+ /** @internal - starts syncing widths, once the parent's GridModel exists. */
128
+ initWidths(): void;
129
+ /** @internal - builds the pivot region: its root groups, or their children when hidden. */
130
+ buildRegion(): Array<ColumnSpec | ColumnGroupSpec>;
131
+ private get view();
132
+ private get cube();
133
+ private availableFields;
134
+ private get query();
135
+ private get gridModel();
136
+ private isLevelExpanded;
137
+ private groupIdFor;
138
+ private measureHeader;
139
+ private measureColumn;
140
+ private dimensionSpec;
141
+ private get isMeasuresOutermost();
142
+ private get isRootGroupShown();
143
+ private get pivotMeasures();
144
+ private summarySide;
145
+ private pathLabel;
146
+ private pathClass;
147
+ private indexCellFields;
148
+ private buildPathColumn;
149
+ private buildGroupChildren;
150
+ private buildSummaryColumns;
151
+ private buildValueColumns;
152
+ private buildValueColumn;
153
+ private buildColGroup;
154
+ private noteMeasure;
155
+ private widthsReaction;
156
+ private sizingReaction;
157
+ private syncPivotWidths;
158
+ private calcLabelPadding;
159
+ private forEachDisplayedGroup;
160
+ private measureLabel;
161
+ private sortPaths;
162
+ private cellFieldName;
163
+ private _cellFieldNames;
164
+ private _rootPath;
165
+ private _dimensionSpecs;
166
+ private _columnsByMeasure;
167
+ private _defaultColumn;
168
+ private _colIds;
169
+ private _groupLevels;
170
+ private _rootGroups;
171
+ private _measureByColId;
172
+ private _widths;
173
+ private _dataWidths;
174
+ private _manualWidths;
175
+ private _labelWidths;
176
+ }
177
+ /**
178
+ * Group id of the column group spanning the pivot region. Its summary group is `pivot:summary`. With
179
+ * `measuresOutermost` there is no such group - each measure's root is `{field}::pivot`.
180
+ */
181
+ export declare const PIVOT_GROUP_ID = "pivot";
@@ -0,0 +1,85 @@
1
+ import type { ColumnSpec } from '@xh/hoist/cmp/grid';
2
+ import type { HSide } from '@xh/hoist/core';
3
+ import type { PivotPath } from '@xh/hoist/data';
4
+ /**
5
+ * Display sort for the values of one pivot dimension.
6
+ *
7
+ * `'asc'` / `'desc'` sort by raw dimension value. An array is an explicit ordering of raw dimension
8
+ * values, with anything unlisted following in the view's own ascending order. A comparator orders
9
+ * the paths, as `Array.sort` does - it runs on each rebuild, so set new `dimensions` to re-sort
10
+ * when what it reads changes. `null` leaves the dimension in that view order.
11
+ */
12
+ export type PivotSort = 'asc' | 'desc' | any[] | ((a: PivotPath, b: PivotPath) => number);
13
+ /**
14
+ * Display settings for one pivot dimension - see {@link CubeGridPivotConfig.dimensions}.
15
+ *
16
+ * A dimension's summary aggregates its values: the first dimension's is the row summary, which
17
+ * the region collapses to, and each later dimension's is the summary its parent groups collapse to.
18
+ */
19
+ export interface PivotDimensionSpec {
20
+ /** Name of the pivot dimension. */
21
+ field: string;
22
+ /** Display order of the dimension's values. Default null, keeping view order. */
23
+ sortBy?: PivotSort;
24
+ /**
25
+ * True (default) to let groups collapse to this dimension's summary. False to fix them open,
26
+ * with the summary shown only where `showSummary` asks for it.
27
+ */
28
+ collapsible?: boolean;
29
+ /**
30
+ * Show this dimension's summary while its groups are expanded too, as
31
+ * {@link GridConfig.showSummary} is the summary row. True for the default 'left', where the
32
+ * summary keeps its collapsed position and the group opens to its right, or an {@link HSide}
33
+ * to place it within the group. Default false - a collapsed group always shows it.
34
+ */
35
+ showSummary?: boolean | HSide;
36
+ /** Header of this dimension's summary, and its name in export headers. Default 'Total'. */
37
+ summaryLabel?: string;
38
+ /**
39
+ * True (default) to show `summaryLabel` over the summary while its group is collapsed. False
40
+ * to drop it, so the summary's column headers stretch up to the group's. No effect with
41
+ * measures outermost, or a single measure, where a summary is one column headed by its label.
42
+ */
43
+ showCollapsedLabel?: boolean;
44
+ /**
45
+ * Class for this dimension's summary columns, cells and headers, over the built-in
46
+ * `xh-cube-grid__summary-cell` and `xh-cube-grid__summary-header` classes every summary
47
+ * carries - to style the row summary apart from the others, say.
48
+ */
49
+ summaryClass?: string;
50
+ /**
51
+ * Header text for one of the dimension's values - a date as 'Nov 2026', say. Also used in
52
+ * export headers and to fit widths. Not called for an empty value, which takes `emptyLabel`.
53
+ * Default the value as a string.
54
+ */
55
+ valueRenderer?: (value: any, path: PivotPath) => string;
56
+ /**
57
+ * Class for each of the dimension's values, on its header and on every header and cell
58
+ * beneath it - nested values and their summaries included. A function picks it per value,
59
+ * with `value` null for an empty one, to set one apart, such as the current month.
60
+ */
61
+ valueClass?: string | ((value: any, path: PivotPath) => string);
62
+ /** Header text for a null / blank value of the dimension. Default '(empty)'. */
63
+ emptyLabel?: string;
64
+ }
65
+ /** Settings for one pivot measure - see {@link CubeGridPivotConfig.measures}. */
66
+ export interface PivotMeasureSpec {
67
+ /** Name of the measure, a `pivot.measures` entry. */
68
+ field: string;
69
+ /**
70
+ * Column config applied to every pivot column built for the measure, under every path -
71
+ * renderer, width, align, and so on. Its `headerName` heads the measure's columns. Keys the
72
+ * grid sets itself - identity, placement, visibility, export name, editing and `agOptions` -
73
+ * are ignored, so a spec shared with the fixed `columns` applies cleanly.
74
+ */
75
+ column?: Partial<ColumnSpec>;
76
+ }
77
+ /** Options for {@link CubeGridPivotConfig.linkedSizing}. */
78
+ export interface PivotLinkedSizingOptions {
79
+ /**
80
+ * Most a pivot label can claim to fit, in pixels across the columns it spans - a group's, or
81
+ * with `measuresOutermost` a column's own header. Default 140. Data can widen the columns past
82
+ * it. 0 to size for data alone.
83
+ */
84
+ headerFitMaxWidth?: number;
85
+ }
@@ -0,0 +1,4 @@
1
+ export * from './CubeGrid';
2
+ export * from './CubeGridModel';
3
+ export * from './CubeGridPivotModel';
4
+ export type * from './Types';
@@ -1,5 +1,5 @@
1
1
  import type { RowClickedEvent, RowDoubleClickedEvent, RowHeightParams } from '@xh/hoist/kit/ag-grid';
2
- import type { ColumnRenderer, GridConfig, GroupRowRenderer, RowClassFn, RowClassRuleFn, GridSorterLike, GridContextMenuSpec, GridGroupSortFn } from '@xh/hoist/cmp/grid';
2
+ import type { ColumnRenderer, GridConfig, GridEnsureVisibleOptions, GridLikeModel, GridSelectFirstOptions, GridSelectOptions, GroupRowRenderer, RowClassFn, RowClassRuleFn, GridSorterLike, GridContextMenuSpec, GridGroupSortFn } from '@xh/hoist/cmp/grid';
3
3
  import { GridModel } from '@xh/hoist/cmp/grid';
4
4
  import type { LoadSpec, PlainObject, Some } from '@xh/hoist/core';
5
5
  import { HoistModel } from '@xh/hoist/core';
@@ -101,12 +101,13 @@ export type ItemHeightFn = (params: {
101
101
  * @see DataView
102
102
  * @see DataViewConfig
103
103
  */
104
- export declare class DataViewModel extends HoistModel {
104
+ export declare class DataViewModel extends HoistModel implements GridLikeModel {
105
105
  gridModel: GridModel;
106
106
  accessor itemHeight: number | ItemHeightFn;
107
107
  accessor groupRowHeight: number;
108
108
  constructor(config: DataViewConfig);
109
109
  get store(): Store;
110
+ get innerGridModel(): GridModel;
110
111
  get empty(): boolean;
111
112
  get selModel(): StoreSelectionModel;
112
113
  get hasSelection(): boolean;
@@ -115,15 +116,10 @@ export declare class DataViewModel extends HoistModel {
115
116
  get selectedId(): import("@xh/hoist/data").StoreRecordId;
116
117
  get groupBy(): string[];
117
118
  get sortBy(): import("@xh/hoist/cmp/grid").GridSorter[];
118
- selectAsync(records: Some<StoreRecordOrId>, opts?: {
119
- ensureVisible?: boolean;
120
- clearSelection?: boolean;
121
- }): Promise<void>;
119
+ selectAsync(records: Some<StoreRecordOrId>, opts?: GridSelectOptions): Promise<void>;
122
120
  preSelectFirstAsync(): Promise<void>;
123
- selectFirstAsync(opts?: {
124
- ensureVisible?: boolean;
125
- }): Promise<void>;
126
- ensureSelectionVisibleAsync(): Promise<void>;
121
+ selectFirstAsync(opts?: GridSelectFirstOptions): Promise<void>;
122
+ ensureSelectionVisibleAsync(opts?: GridEnsureVisibleOptions): Promise<void>;
127
123
  doLoadAsync(loadSpec: LoadSpec): Promise<any>;
128
124
  loadData(rawData: any[], rawSummaryData?: PlainObject): void;
129
125
  updateData(rawData: PlainObject[] | StoreTransaction): import("@xh/hoist/data").StoreChangeLog;