@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
|
@@ -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 {
|
|
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
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
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?:
|
|
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
|
|
91
|
-
* binds by default to the nearest
|
|
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 {
|
|
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
|
-
/**
|
|
43
|
+
/** Model to filter - from props, or the nearest found in context. */
|
|
43
44
|
@computed
|
|
44
|
-
get boundModel():
|
|
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
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
|
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) {
|
package/core/types/Types.ts
CHANGED
|
@@ -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.
|
|
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;
|
package/data/cube/CubeField.ts
CHANGED
|
@@ -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':
|