@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
@@ -0,0 +1,320 @@
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
+ import classNames from 'classnames';
8
+ import {isEmpty, max, sumBy} from 'lodash';
9
+ import {Children, useId, useLayoutEffect, useRef, useState} from 'react';
10
+ import type {KeyboardEvent, MouseEvent, ReactElement, ReactNode} from 'react';
11
+
12
+ import {div, span} from '@xh/hoist/cmp/layout';
13
+ import {hoistCmp} from '@xh/hoist/core';
14
+ import type {
15
+ ComponentSize,
16
+ DomAttrsProps,
17
+ HoistProps,
18
+ Intent,
19
+ LayoutProps,
20
+ TestSupportProps
21
+ } from '@xh/hoist/core';
22
+ import {statCardInfoImpl} from '@xh/hoist/dynamics/desktop';
23
+ import {Icon} from '@xh/hoist/icon';
24
+ import {mergeDeep, TEST_ID} from '@xh/hoist/utils/js';
25
+ import {composeRefs, splitLayoutProps, useOnResize} from '@xh/hoist/utils/react';
26
+
27
+ import './StatCard.scss';
28
+
29
+ export interface StatCardProps extends HoistProps, LayoutProps, TestSupportProps, DomAttrsProps {
30
+ /** Caption shown above the value. */
31
+ title: ReactNode;
32
+
33
+ /**
34
+ * Primary content, pre-formatted by the caller. The card never formats - currency, percent,
35
+ * precision and color decisions belong to the caller. A unit added with `fmtNumber`'s `label`
36
+ * option renders smaller than the figure.
37
+ *
38
+ * The value and sub-value are never truncated in normal layout - a card does not get narrower
39
+ * than them, and a {@link StatCardStrip} wraps cards to a new row instead. Compact large
40
+ * values with `fmtMillions` or `fmtQuantity` (e.g. `48.5m`). Only a card held narrower than
41
+ * its value - by an explicit `width` or `maxWidth` - shows an ellipsis.
42
+ */
43
+ value: ReactNode;
44
+
45
+ /**
46
+ * Smaller figure rendered inline after the value, e.g. a change vs. a prior period, a target
47
+ * or an average. Pass a `fmtNumber` result to color it by sign - and invert its `colorSpec`
48
+ * for a metric where down is good:
49
+ *
50
+ * ```ts
51
+ * subValue: fmtPercent(delta, {withSignGlyph: true, colorSpec: {pos: 'xh-neg-val', neg: 'xh-pos-val'}})
52
+ * ```
53
+ */
54
+ subValue?: ReactNode;
55
+
56
+ /** Sub-line beneath the value, e.g. what a change is measured against. */
57
+ detail?: ReactNode;
58
+
59
+ /**
60
+ * Supporting detail shown as a tooltip on an info icon after the title. Omit to render no icon.
61
+ * Desktop only - on mobile the icon shows, but its tooltip does not.
62
+ */
63
+ infoTooltip?: ReactElement | string;
64
+
65
+ /** Icon that shows `infoTooltip`. Default `Icon.info()`. */
66
+ infoIcon?: ReactElement;
67
+
68
+ /**
69
+ * Flags the card with a semantic color on its border, as with {@link Card}. Does not color
70
+ * the value - to do so, format the value with a `colorSpec` or wrap it in a styled element.
71
+ */
72
+ intent?: Intent;
73
+
74
+ /**
75
+ * CSS color for an accent bar, e.g. `var(--xh-blue)`, to mark a category or series identity.
76
+ * Use `intent` to flag a status.
77
+ *
78
+ * The bar runs along the top edge by default. Set the `--stat-card-accent-top`, `-right`,
79
+ * `-bottom` and `-left` CSS variables to choose its edge and thickness - e.g. a left bar with
80
+ * `--stat-card-accent-top: 0; --stat-card-accent-left: 4px`.
81
+ */
82
+ accent?: string;
83
+
84
+ /**
85
+ * Size of the card - `large` for a headline figure, with a bigger value, captions and padding.
86
+ * Default `standard`. Set the `--xh-stat-card-large-*` CSS variables to tune the large size.
87
+ *
88
+ * A large card stands best on its own or in a strip of large cards. In a wrapped strip, every
89
+ * column takes the width of the widest card.
90
+ */
91
+ size?: Extract<ComponentSize, 'standard' | 'large'>;
92
+
93
+ /**
94
+ * Handler for a click or Enter/Space keypress on the card, e.g. to drill into the figure.
95
+ * Makes the card focusable and styles it as clickable.
96
+ */
97
+ onClick?: (e: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>) => void;
98
+ }
99
+
100
+ /**
101
+ * A tile that calls out a key figure: a caption over a prominent value, with an optional inline
102
+ * sub-value, info tooltip and sub-line.
103
+ *
104
+ * The card is presentation-only. Callers pass an already-formatted `value` - the card never
105
+ * formats or colors a value based on its content.
106
+ *
107
+ * A card on its own sizes to its content. For a row of cards, use {@link StatCardStrip} rather
108
+ * than an `hbox` - a strip shares out the width, wraps cards before a value is cut short, and
109
+ * truncates other lines with an ellipsis, showing their full text in a tooltip.
110
+ */
111
+ export const [StatCard, statCard] = hoistCmp.withFactory<StatCardProps>({
112
+ displayName: 'StatCard',
113
+ model: false,
114
+ className: 'xh-stat-card',
115
+
116
+ render(props, ref) {
117
+ const [
118
+ layoutProps,
119
+ {
120
+ className,
121
+ title,
122
+ value,
123
+ subValue,
124
+ detail,
125
+ infoTooltip,
126
+ infoIcon = Icon.info(),
127
+ intent,
128
+ accent,
129
+ size,
130
+ onClick,
131
+ testId,
132
+ domAttrs
133
+ }
134
+ ] = splitLayoutProps(props),
135
+ titleId = useId(),
136
+ clickProps = onClick
137
+ ? {
138
+ role: 'button',
139
+ tabIndex: 0,
140
+ onClick,
141
+ onKeyDown: (e: KeyboardEvent<HTMLDivElement>) => {
142
+ if (e.target !== e.currentTarget) return;
143
+ if (e.key === 'Enter' || e.key === ' ') {
144
+ e.preventDefault();
145
+ onClick(e);
146
+ }
147
+ }
148
+ }
149
+ : {role: 'group', 'aria-labelledby': titleId},
150
+ divProps = mergeDeep(
151
+ {
152
+ className: classNames(
153
+ className,
154
+ intent && `xh-stat-card--intent-${intent}`,
155
+ size === 'large' && 'xh-stat-card--large',
156
+ accent && 'xh-stat-card--accented',
157
+ onClick && 'xh-stat-card--clickable'
158
+ )
159
+ },
160
+ {style: {...layoutProps, '--xh-stat-card-accent-color': accent}},
161
+ {[TEST_ID]: testId, ...domAttrs}
162
+ );
163
+
164
+ return div({
165
+ ref,
166
+ ...clickProps,
167
+ ...divProps,
168
+ items: [
169
+ div({
170
+ className: 'xh-stat-card__header',
171
+ items: [
172
+ span({
173
+ id: titleId,
174
+ className: 'xh-stat-card__title',
175
+ onMouseEnter: titleIfTruncated,
176
+ item: title
177
+ }),
178
+ infoTooltip ? info(infoIcon, infoTooltip) : null
179
+ ]
180
+ }),
181
+ div({
182
+ className: 'xh-stat-card__value',
183
+ items: [
184
+ span({
185
+ className: 'xh-stat-card__value-primary',
186
+ onMouseEnter: titleIfTruncated,
187
+ item: value
188
+ }),
189
+ span({
190
+ omit: subValue == null,
191
+ className: 'xh-stat-card__sub-value',
192
+ onMouseEnter: titleIfTruncated,
193
+ item: subValue
194
+ })
195
+ ]
196
+ }),
197
+ span({
198
+ omit: detail == null,
199
+ className: 'xh-stat-card__detail',
200
+ onMouseEnter: titleIfTruncated,
201
+ item: detail
202
+ })
203
+ ]
204
+ });
205
+ }
206
+ });
207
+
208
+ export interface StatCardStripProps
209
+ extends HoistProps, LayoutProps, TestSupportProps, DomAttrsProps {}
210
+
211
+ /**
212
+ * A row of {@link StatCard}s, passed as `items`, each given an equal share of the strip's width.
213
+ * Pass `flex` or `width` to a card to weight or fix its share.
214
+ *
215
+ * When the cards no longer fit on one row, the strip becomes an even grid with as many columns as
216
+ * fit its widest card, so cards on later rows line up under those above. A card is never narrower
217
+ * than its value and sub-value, or than the `--xh-stat-card-min-content-width` CSS variable. A
218
+ * card's `flex` does not apply in the grid.
219
+ *
220
+ * Renders nothing if given no cards - use `omit` on a card to leave it out.
221
+ */
222
+ export const [StatCardStrip, statCardStrip] = hoistCmp.withFactory<StatCardStripProps>({
223
+ displayName: 'StatCardStrip',
224
+ model: false,
225
+ className: 'xh-stat-card-strip',
226
+
227
+ render(props, ref) {
228
+ const [layoutProps, {className, children, testId, domAttrs}] = splitLayoutProps(props),
229
+ [columns, setColumns] = useState<number>(null),
230
+ stripRef = useRef<HTMLDivElement>(null),
231
+ resizeRef = useOnResize(() => setColumns(gridColumns(stripRef.current)));
232
+
233
+ // Card values change with the cards passed in, so measure on each change as well as on resize.
234
+ useLayoutEffect(() => setColumns(gridColumns(stripRef.current)), [children]);
235
+
236
+ if (isEmpty(Children.toArray(children))) return null;
237
+
238
+ return div({
239
+ ref: composeRefs(ref, stripRef, resizeRef),
240
+ role: 'group',
241
+ ...mergeDeep(
242
+ {className: classNames(className, columns && 'xh-stat-card-strip--grid')},
243
+ {style: {...layoutProps, '--xh-stat-card-strip-columns': columns}},
244
+ {[TEST_ID]: testId, ...domAttrs}
245
+ ),
246
+ items: children
247
+ });
248
+ }
249
+ });
250
+
251
+ //------------------
252
+ // Implementation
253
+ //------------------
254
+ /** The info icon, with its tooltip on desktop. */
255
+ function info(icon: ReactElement, content: ReactElement | string) {
256
+ return statCardInfoImpl
257
+ ? statCardInfoImpl({icon, content})
258
+ : span({className: 'xh-stat-card__info', item: icon});
259
+ }
260
+
261
+ /**
262
+ * Columns for an even grid of a strip's cards, each as wide as the widest card's minimum. Null
263
+ * while every card fits on one row at an equal share.
264
+ */
265
+ function gridColumns(strip: HTMLElement): number {
266
+ const cards = strip ? (Array.from(strip.children) as HTMLElement[]) : [];
267
+ if (isEmpty(cards)) return null;
268
+
269
+ const {columnGap, paddingLeft, paddingRight} = window.getComputedStyle(strip),
270
+ gap = px(columnGap),
271
+ width = strip.clientWidth - px(paddingLeft) - px(paddingRight),
272
+ cardWidth = max(cards.map(minCardWidth)),
273
+ fit = Math.floor((width + gap) / (cardWidth + gap));
274
+
275
+ return fit >= cards.length ? null : Math.max(fit, 1);
276
+ }
277
+
278
+ /**
279
+ * The narrowest a card can get: the wider of its value line and its header floor, plus padding and
280
+ * border. Reads layout without changing it, so measuring adds no layout pass of its own. Returns 0
281
+ * for an element that is not a StatCard.
282
+ */
283
+ function minCardWidth(card: HTMLElement): number {
284
+ const header = card.querySelector<HTMLElement>(':scope > .xh-stat-card__header'),
285
+ valueLine = card.querySelector<HTMLElement>(':scope > .xh-stat-card__value');
286
+ if (!header || !valueLine) return 0;
287
+
288
+ // scrollWidth gives each part's full width even while truncated, rounded to a whole pixel.
289
+ const parts = Array.from(valueLine.children) as HTMLElement[],
290
+ valueWidth =
291
+ sumBy(parts, it => it.scrollWidth + 1) +
292
+ (parts.length - 1) * px(window.getComputedStyle(valueLine).columnGap),
293
+ {paddingLeft, paddingRight, borderLeftWidth, borderRightWidth} =
294
+ window.getComputedStyle(card);
295
+
296
+ return (
297
+ Math.max(valueWidth, px(window.getComputedStyle(header).minWidth)) +
298
+ px(paddingLeft) +
299
+ px(paddingRight) +
300
+ px(borderLeftWidth) +
301
+ px(borderRightWidth)
302
+ );
303
+ }
304
+
305
+ function px(v: string): number {
306
+ return parseFloat(v) || 0;
307
+ }
308
+
309
+ /**
310
+ * Show a line's full text as a native tooltip, but only while it is truncated. Read from the DOM
311
+ * on hover, so it covers element content (e.g. `fmtNumber` output) as well as strings.
312
+ */
313
+ function titleIfTruncated(e: MouseEvent<HTMLElement>) {
314
+ const el = e.currentTarget;
315
+ if (el.scrollWidth > el.clientWidth) {
316
+ el.title = el.textContent;
317
+ } else {
318
+ el.removeAttribute('title');
319
+ }
320
+ }
@@ -0,0 +1 @@
1
+ export * from './StatCard';
@@ -4,8 +4,7 @@
4
4
  *
5
5
  * Copyright © 2026 Extremely Heavy Industries Inc.
6
6
  */
7
- import type {GridModel} from '@xh/hoist/cmp/grid';
8
- import type {ZoneGridModel} from '@xh/hoist/cmp/zoneGrid';
7
+ import type {GridLikeModel} from '@xh/hoist/cmp/grid';
9
8
  import type {DefaultHoistProps, HoistModel} from '@xh/hoist/core';
10
9
  import {hoistCmp, useLocalModel, XH} from '@xh/hoist/core';
11
10
  import type {FilterMatchMode, FilterTestFn, Store} from '@xh/hoist/data';
@@ -39,12 +38,12 @@ export interface StoreFilterFieldProps extends DefaultHoistProps {
39
38
  filterBuffer?: number;
40
39
 
41
40
  /**
42
- * GridModel or ZoneGridModel whose Store this control should filter. When given a GridModel,
43
- * this component will, by default, use the fields for all *visible* columns when matching, as
44
- * well as any groupBy field. When given a ZoneGridModel, it uses the fields currently mapped
45
- * to any of its zones. Do not configure this and `store` on the same component.
41
+ * Model whose Store this control should filter. When given a GridModel or CubeGridModel, this
42
+ * component will, by default, use the fields for all *visible* columns when matching, as well
43
+ * as any groupBy field. When given a ZoneGridModel, it uses the fields currently mapped to any
44
+ * of its zones. Do not configure this and `store` on the same component.
46
45
  */
47
- gridModel?: GridModel | ZoneGridModel;
46
+ gridModel?: GridLikeModel;
48
47
 
49
48
  /**
50
49
  * Names of field(s) to include in search. Required if neither a store nor gridModel are
@@ -87,8 +86,8 @@ export interface StoreFilterFieldProps extends DefaultHoistProps {
87
86
  * object itself is considered a match.
88
87
  *
89
88
  * This component is designed to be bound to a Store via either its `store` OR `gridModel` props,
90
- * the latter accepting either a GridModel or a ZoneGridModel. If not configured with either, it
91
- * binds by default to the nearest GridModel or ZoneGridModel found in context. Binding in this way
89
+ * the latter accepting a GridModel, ZoneGridModel or CubeGridModel. If not configured with either,
90
+ * it binds by default to the nearest such model found in context. Binding in this way
92
91
  * allows the component to auto-generate the fields in the store to be included in the filter and
93
92
  * to automatically apply the filter to the Store.
94
93
  *
@@ -4,8 +4,9 @@
4
4
  *
5
5
  * Copyright © 2026 Extremely Heavy Industries Inc.
6
6
  */
7
- import type {Column} from '@xh/hoist/cmp/grid';
8
- import {GridModel} from '@xh/hoist/cmp/grid';
7
+ import type {Column, GridLikeModel, GridModel} from '@xh/hoist/cmp/grid';
8
+ import {isGridLikeModel} from '@xh/hoist/cmp/grid/impl/GridLikeModel';
9
+ import {DataViewModel} from '@xh/hoist/cmp/dataview';
9
10
  import {ZoneGridModel} from '@xh/hoist/cmp/zoneGrid';
10
11
  import {HoistModel, lookup} from '@xh/hoist/core';
11
12
  import type {FilterMatchMode, StoreRecord, Store} from '@xh/hoist/data';
@@ -39,15 +40,12 @@ export class StoreFilterFieldImplModel extends HoistModel {
39
40
  return this.componentProps.matchMode ?? 'startWord';
40
41
  }
41
42
 
42
- /** GridModel or ZoneGridModel to filter - from props, or the nearest found in context. */
43
+ /** Model to filter - from props, or the nearest found in context. */
43
44
  @computed
44
- get boundModel(): GridModel | ZoneGridModel {
45
+ get boundModel(): GridLikeModel {
45
46
  const {gridModel, store} = this.componentProps;
46
47
  if (store) return null;
47
- return (
48
- gridModel ??
49
- this.lookupModel(it => it instanceof GridModel || it instanceof ZoneGridModel)
50
- );
48
+ return gridModel ?? this.lookupModel(isGridLikeModel);
51
49
  }
52
50
 
53
51
  @computed
@@ -236,19 +234,21 @@ export class StoreFilterFieldImplModel extends HoistModel {
236
234
  }
237
235
 
238
236
  private get innerGridModel(): GridModel {
239
- const {boundModel} = this;
240
- return boundModel instanceof ZoneGridModel ? boundModel.gridModel : boundModel;
237
+ return this.boundModel?.innerGridModel ?? null;
241
238
  }
242
239
 
243
240
  /**
244
241
  * Columns whose fields the user can see, and so should be able to search. A ZoneGrid renders
245
242
  * its mapped fields within two zone columns, so use the columns backing those fields instead.
243
+ * A DataView renders every field through one item renderer, so search them all.
246
244
  */
247
245
  private getSearchColumns(): Column[] {
248
- const {boundModel} = this;
246
+ const {boundModel, innerGridModel} = this;
249
247
  if (!boundModel) return [];
250
- return boundModel instanceof ZoneGridModel
251
- ? boundModel.getMappedColumns()
252
- : boundModel.getVisibleLeafColumns();
248
+ if (boundModel instanceof ZoneGridModel) return boundModel.getMappedColumns();
249
+ if (boundModel instanceof DataViewModel) {
250
+ return innerGridModel.getLeafColumns().filter(it => it.field);
251
+ }
252
+ return innerGridModel.getVisibleLeafColumns();
253
253
  }
254
254
  }
@@ -17,7 +17,11 @@ import type {
17
17
  GridConfig,
18
18
  GridContextMenuItemLike,
19
19
  GridContextMenuSpec,
20
+ GridEnsureVisibleOptions,
20
21
  GridGroupSortFn,
22
+ GridLikeModel,
23
+ GridSelectFirstOptions,
24
+ GridSelectOptions,
21
25
  GridSorterLike,
22
26
  GroupRowRenderer,
23
27
  RowClassFn,
@@ -322,7 +326,7 @@ export interface ZoneGridConfig {
322
326
  * @see ZoneGrid
323
327
  * @see ZoneGridConfig
324
328
  */
325
- export class ZoneGridModel extends HoistModel {
329
+ export class ZoneGridModel extends HoistModel implements GridLikeModel {
326
330
  @managed
327
331
  gridModel: GridModel;
328
332
 
@@ -509,6 +513,10 @@ export class ZoneGridModel extends HoistModel {
509
513
  return this.gridModel.store;
510
514
  }
511
515
 
516
+ get innerGridModel(): GridModel {
517
+ return this.gridModel;
518
+ }
519
+
512
520
  get empty() {
513
521
  return this.gridModel.empty;
514
522
  }
@@ -537,10 +545,7 @@ export class ZoneGridModel extends HoistModel {
537
545
  return this.gridModel.groupBy;
538
546
  }
539
547
 
540
- selectAsync(
541
- records: Some<StoreRecordOrId>,
542
- opts: {ensureVisible?: boolean; clearSelection?: boolean}
543
- ) {
548
+ selectAsync(records: Some<StoreRecordOrId>, opts?: GridSelectOptions) {
544
549
  return this.gridModel.selectAsync(records, opts);
545
550
  }
546
551
 
@@ -548,12 +553,12 @@ export class ZoneGridModel extends HoistModel {
548
553
  return this.gridModel.preSelectFirstAsync();
549
554
  }
550
555
 
551
- selectFirstAsync(opts: {ensureVisible?: boolean} = {}) {
556
+ selectFirstAsync(opts?: GridSelectFirstOptions) {
552
557
  return this.gridModel.selectFirstAsync(opts);
553
558
  }
554
559
 
555
- ensureSelectionVisibleAsync() {
556
- return this.gridModel.ensureSelectionVisibleAsync();
560
+ ensureSelectionVisibleAsync(opts?: GridEnsureVisibleOptions) {
561
+ return this.gridModel.ensureSelectionVisibleAsync(opts);
557
562
  }
558
563
 
559
564
  override doLoadAsync(loadSpec: LoadSpec) {
@@ -14,6 +14,13 @@ import type {Route} from 'router5';
14
14
  /** Values available for intents. */
15
15
  export type Intent = 'primary' | 'success' | 'warning' | 'danger';
16
16
 
17
+ /**
18
+ * Sizes a component can be drawn at, chosen by the developer for emphasis or space. Distinct from
19
+ * `SizingMode`, the density preference that a user can change for the whole app. A component
20
+ * that takes this type may support only some of the sizes.
21
+ */
22
+ export type ComponentSize = 'compact' | 'standard' | 'large';
23
+
17
24
  /** Values available for App Theme. */
18
25
  export type Theme = 'system' | 'dark' | 'light';
19
26
 
package/data/Field.ts CHANGED
@@ -30,6 +30,13 @@ export interface FieldSpec {
30
30
  */
31
31
  displayName?: string;
32
32
 
33
+ /**
34
+ * Shorter name for headers, where space is tight - a grid column's default `headerName`, and a
35
+ * pivot grid's headers. Choosers, menus and exports keep `displayName`. Defaults to
36
+ * `displayName`.
37
+ */
38
+ shortDisplayName?: string;
39
+
33
40
  /** Supplementary descriptive text for this field, for use in tooltips and other UI. */
34
41
  description?: string;
35
42
 
@@ -79,6 +86,7 @@ export class Field {
79
86
  readonly name: string;
80
87
  readonly type: FieldType;
81
88
  readonly displayName: string;
89
+ readonly shortDisplayName: string;
82
90
  readonly description: string;
83
91
  readonly defaultValue: any;
84
92
  readonly isDimension: boolean;
@@ -89,6 +97,7 @@ export class Field {
89
97
  name,
90
98
  type = 'auto',
91
99
  displayName,
100
+ shortDisplayName,
92
101
  description,
93
102
  defaultValue = null,
94
103
  isDimension = false,
@@ -98,6 +107,7 @@ export class Field {
98
107
  this.name = name;
99
108
  this.type = type;
100
109
  this.displayName = withDefault(displayName, genDisplayName(name));
110
+ this.shortDisplayName = withDefault(shortDisplayName, this.displayName);
101
111
  this.description = description;
102
112
  this.isDimension = isDimension;
103
113
  this.rules = this.processRuleSpecs(rules);
package/data/Store.ts CHANGED
@@ -287,6 +287,10 @@ export interface StoreTransaction {
287
287
  * supply them cheaply. Providing this asserts that updates change record values only - no
288
288
  * structural/parent changes - and that no field outside the set changed. Enables downstream
289
289
  * consumers (e.g. Grid) to prove a change cannot affect sort order and skip re-sorting.
290
+ *
291
+ * Cube Views rely on it too: a set naming no dimension or bucket field lets a View skip its
292
+ * per-record structural check, so a set that omits a changed dimension leaves the View's row
293
+ * hierarchy stale.
290
294
  */
291
295
  changedFields?: Set<string>;
292
296
  }
@@ -405,6 +409,7 @@ export class Store
405
409
  @observableRef private accessor _current: RecordSet;
406
410
  @observableRef accessor _filtered: RecordSet;
407
411
 
412
+ private _fieldDefaults: Omit<FieldSpec, 'name'>;
408
413
  private _dataTemplate: PlainObject = null;
409
414
  private _dataDefaults: PlainObject = null;
410
415
  private _denseRecordThreshold: number;
@@ -456,7 +461,10 @@ export class Store
456
461
 
457
462
  this.xhName = xhName;
458
463
  this.experimental = this.parseExperimental(experimental);
464
+ this._fieldDefaults = fieldDefaults;
459
465
  this.fields = this.parseFields(fields, fieldDefaults);
466
+ // Before anything below that may call `getField()`.
467
+ this._fieldMap = this.createFieldMap();
460
468
  this.idSpec = this.parseIdSpec(idSpec);
461
469
  this.processRawData = processRawData;
462
470
  this.filter = parseFilter(filter);
@@ -475,7 +483,6 @@ export class Store
475
483
  this.resetRecords();
476
484
 
477
485
  this.validator = new StoreValidator({store: this});
478
- this._fieldMap = this.createFieldMap();
479
486
  this._dataDefaults = this.createDataDefaults();
480
487
  this._dataTemplate = {...this._dataDefaults}; // Clone for fast-props mode.
481
488
  this._denseRecordThreshold =
@@ -986,9 +993,25 @@ export class Store
986
993
  this.incrementalRefilter();
987
994
  }
988
995
 
996
+ /**
997
+ * Replace this Store's fields wholesale, re-applying `fieldDefaults` and rebuilding the derived
998
+ * field map and data defaults. Drops all records, which were built against the outgoing
999
+ * defaults - callers reload immediately.
1000
+ * @internal - supports pivoted Views, whose cell fields are discovered from data.
1001
+ */
1002
+ @action
1003
+ setFields(fields: Array<string | FieldSpec | Field>) {
1004
+ this.fields = this.parseFields(fields, this._fieldDefaults);
1005
+ this._fieldMap = this.createFieldMap();
1006
+ this._dataDefaults = this.createDataDefaults();
1007
+ this._dataTemplate = {...this._dataDefaults}; // Clone for fast-props mode.
1008
+
1009
+ this.resetRecords();
1010
+ }
1011
+
989
1012
  /** Get a specific Field by name.*/
990
1013
  getField(name: string): Field {
991
- return this.fields.find(it => it.name === name);
1014
+ return this._fieldMap.get(name);
992
1015
  }
993
1016
 
994
1017
  get fieldNames(): string[] {
package/data/cube/Cube.ts CHANGED
@@ -226,6 +226,11 @@ export class Cube extends HoistBase {
226
226
  return this.fields.filter(it => it.isDimension);
227
227
  }
228
228
 
229
+ /** Fields a pivot can show as measures - those with an aggregator, other than dimensions. */
230
+ get measures(): CubeField[] {
231
+ return this.fields.filter(it => it.aggregator && !it.isDimension);
232
+ }
233
+
229
234
  /** Records loaded in to this Cube. */
230
235
  get records(): StoreRecord[] {
231
236
  return this.store.records;
@@ -15,6 +15,7 @@ import {
15
15
  Field,
16
16
  LeafCountAggregator,
17
17
  MaxAggregator,
18
+ MedianAggregator,
18
19
  MinAggregator,
19
20
  NullAggregator,
20
21
  SingleAggregator,
@@ -66,6 +67,7 @@ export type AggregatorToken =
66
67
  | 'CHILD_COUNT'
67
68
  | 'LEAF_COUNT'
68
69
  | 'MAX'
70
+ | 'MEDIAN'
69
71
  | 'MIN'
70
72
  | 'NULL'
71
73
  | 'SINGLE'
@@ -104,6 +106,7 @@ export class CubeField extends Field {
104
106
  static childCountAggregator = new ChildCountAggregator();
105
107
  static leafCountAggregator = new LeafCountAggregator();
106
108
  static maxAggregator = new MaxAggregator();
109
+ static medianAggregator = new MedianAggregator();
107
110
  static minAggregator = new MinAggregator();
108
111
  static nullAggregator = new NullAggregator();
109
112
  static singleAggregator = new SingleAggregator();
@@ -145,6 +148,8 @@ export class CubeField extends Field {
145
148
  return CubeField.leafCountAggregator;
146
149
  case 'MAX':
147
150
  return CubeField.maxAggregator;
151
+ case 'MEDIAN':
152
+ return CubeField.medianAggregator;
148
153
  case 'MIN':
149
154
  return CubeField.minAggregator;
150
155
  case 'NULL':