@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
@@ -16,7 +16,7 @@ import { GridModelDiagnostics } from './impl/GridModelDiagnostics';
16
16
  import type { GridContextMenuItemLike, GridContextMenuSpec, GridHeaderContextMenuSpec } from './GridContextMenu';
17
17
  import type { GridSorterLike } from './GridSorter';
18
18
  import { GridSorter } from './GridSorter';
19
- import type { ColChooserConfig, ColChooserMode, ColumnGroupState, ColumnState, ColumnStateOptions, GridModelPersistOptions, GridScrollPosition, GroupRowRenderer, RowClassFn, RowClassRuleFn } from './Types';
19
+ import type { ColChooserConfig, ColChooserMode, ColumnGroupState, ColumnState, ColumnStateOptions, GridEnsureVisibleOptions, GridLikeModel, GridModelPersistOptions, GridSelectFirstOptions, GridSelectOptions, GroupRowRenderer, RowClassFn, RowClassRuleFn } from './Types';
20
20
  /**
21
21
  * Configuration for a {@link GridModel} - the primary model backing the Hoist Grid component.
22
22
  *
@@ -318,7 +318,7 @@ export interface GridModelDefaults {
318
318
  *
319
319
  * @mcpHint model backing all grid components
320
320
  */
321
- export declare class GridModel extends HoistModel {
321
+ export declare class GridModel extends HoistModel implements GridLikeModel {
322
322
  /**
323
323
  * Ceilings (ms) on how long deferred grid work may be held back, calibrated to what going
324
324
  * stale costs the user: a deferred sort leaves row order wrong, while a deferred autosize
@@ -442,17 +442,7 @@ export declare class GridModel extends HoistModel {
442
442
  * @param records - one or more record(s) / ID(s) to select.
443
443
  * @param opts - additional post-selection options
444
444
  */
445
- selectAsync(records: Some<StoreRecordOrId>, opts?: {
446
- /**
447
- * True (default) to scroll the grid or expand nodes as needed to make selection
448
- * visible if it is within a collapsed node or outside of the visible scroll window.
449
- */
450
- ensureVisible?: boolean;
451
- /** Position of the selection in the viewport - default null scrolls minimally. */
452
- ensureVisiblePosition?: GridScrollPosition;
453
- /** True (default) to clear previous selection (rather than add to it). */
454
- clearSelection?: boolean;
455
- }): Promise<void>;
445
+ selectAsync(records: Some<StoreRecordOrId>, opts?: GridSelectOptions): Promise<void>;
456
446
  /**
457
447
  * Select the first row in the grid.
458
448
  *
@@ -460,18 +450,7 @@ export declare class GridModel extends HoistModel {
460
450
  * any pre-existing selection unchanged, which is what apps typically want when reloading an
461
451
  * already-populated grid.
462
452
  */
463
- selectFirstAsync(opts?: {
464
- /**
465
- * True (default) to expand nodes as needed to allow selection when the first selectable
466
- * node is in a collapsed group.
467
- */
468
- expandParentGroups?: boolean;
469
- /**
470
- * True (default) to scroll the grid or expand nodes as needed to make selection
471
- * visible if it is outside of the visible scroll window.
472
- */
473
- ensureVisible?: boolean;
474
- }): Promise<void>;
453
+ selectFirstAsync(opts?: GridSelectFirstOptions): Promise<void>;
475
454
  /**
476
455
  * Select the first row in the grid, if no other selection present.
477
456
  * This method delegates to {@link selectFirstAsync}.
@@ -491,10 +470,7 @@ export declare class GridModel extends HoistModel {
491
470
  *
492
471
  * @param opts - additional scrolling options
493
472
  */
494
- ensureSelectionVisibleAsync(opts?: {
495
- /** Position of the selection in the viewport - default null scrolls minimally. */
496
- position?: GridScrollPosition;
497
- }): Promise<void>;
473
+ ensureSelectionVisibleAsync(opts?: GridEnsureVisibleOptions): Promise<void>;
498
474
  /**
499
475
  * Scroll to ensure the provided record or records are visible.
500
476
  *
@@ -508,10 +484,7 @@ export declare class GridModel extends HoistModel {
508
484
  * @param records - one or more record(s) for which to ensure visibility.
509
485
  * @param opts - additional scrolling options
510
486
  */
511
- ensureRecordsVisibleAsync(records: Some<StoreRecord>, opts?: {
512
- /** Position of the record in the viewport - default null scrolls minimally. */
513
- position?: GridScrollPosition;
514
- }): Promise<void>;
487
+ ensureRecordsVisibleAsync(records: Some<StoreRecord>, opts?: GridEnsureVisibleOptions): Promise<void>;
515
488
  /** True if any records are selected. */
516
489
  get hasSelection(): boolean;
517
490
  /** Currently selected records. */
@@ -536,6 +509,7 @@ export declare class GridModel extends HoistModel {
536
509
  get selectedId(): StoreRecordId;
537
510
  /** True if this grid has no records to show in its store. */
538
511
  get empty(): boolean;
512
+ get innerGridModel(): GridModel;
539
513
  /**
540
514
  * Records in the order this grid renders them - sorted by {@link groupBy} and {@link sortBy},
541
515
  * and flattened depth-first for tree grids. Leaf records only - group rows have no StoreRecord.
@@ -785,6 +759,7 @@ export declare class GridModel extends HoistModel {
785
759
  private cleanColumnGroupState;
786
760
  private cleanColumnState;
787
761
  private enhanceColConfigsFromStore;
762
+ private enhanceColConfigs;
788
763
  private enhanceStoreConfigFromColumns;
789
764
  private leafColsByFieldName;
790
765
  private parseSizingMode;
@@ -1,6 +1,6 @@
1
1
  import type { HoistModel, HSide, Intent, PersistOptions, Some } from '@xh/hoist/core';
2
2
  import type { PanelConfig } from '@xh/hoist/desktop/cmp/panel';
3
- import type { FilterBindTarget, FilterMatchMode, FilterValueSource, Store, StoreRecord } from '@xh/hoist/data';
3
+ import type { FilterBindTarget, FilterMatchMode, FilterValueSource, Store, StoreRecord, StoreRecordId, StoreRecordOrId, StoreSelectionModel } from '@xh/hoist/data';
4
4
  import type { CellClassParams, CustomCellEditorProps, HeaderClassParams, HeaderValueGetterParams, ICellRendererParams, IRowNode, ITooltipParams, RowClassParams, ValueSetterParams } from '@xh/hoist/kit/ag-grid';
5
5
  import type { ReactElement, ReactNode } from 'react';
6
6
  import type { Column, ColumnSpec } from './columns/Column';
@@ -52,6 +52,56 @@ export type GridGroupSortFn = (groupAVal: string, groupBVal: string, groupField:
52
52
  }) => number;
53
53
  /** Position of a row in the viewport when scrolled into view - default null scrolls minimally. */
54
54
  export type GridScrollPosition = 'top' | 'middle' | 'bottom';
55
+ /** Options for {@link GridModel.selectAsync}. */
56
+ export interface GridSelectOptions {
57
+ /**
58
+ * True (default) to scroll the grid or expand nodes as needed to make selection visible if it
59
+ * is within a collapsed node or outside of the visible scroll window.
60
+ */
61
+ ensureVisible?: boolean;
62
+ /** Position of the selection in the viewport - default null scrolls minimally. */
63
+ ensureVisiblePosition?: GridScrollPosition;
64
+ /** True (default) to clear previous selection (rather than add to it). */
65
+ clearSelection?: boolean;
66
+ }
67
+ /** Options for {@link GridModel.selectFirstAsync}. */
68
+ export interface GridSelectFirstOptions {
69
+ /**
70
+ * True (default) to expand nodes as needed to allow selection when the first selectable node
71
+ * is in a collapsed group.
72
+ */
73
+ expandParentGroups?: boolean;
74
+ /**
75
+ * True (default) to scroll the grid or expand nodes as needed to make selection visible if it
76
+ * is outside of the visible scroll window.
77
+ */
78
+ ensureVisible?: boolean;
79
+ }
80
+ /** Options for {@link GridModel.ensureSelectionVisibleAsync} and `ensureRecordsVisibleAsync`. */
81
+ export interface GridEnsureVisibleOptions {
82
+ /** Position of the record(s) in the viewport - default null scrolls minimally. */
83
+ position?: GridScrollPosition;
84
+ }
85
+ /**
86
+ * A GridModel, or a model wrapping one that exposes its store and selection - what grid-bound
87
+ * fields and buttons accept. Implemented by {@link GridModel}, `ZoneGridModel`, `DataViewModel`
88
+ * and `CubeGridModel`.
89
+ */
90
+ export interface GridLikeModel extends HoistModel {
91
+ /** The GridModel behind this model - itself, for a GridModel. */
92
+ readonly innerGridModel: GridModel;
93
+ readonly store: Store;
94
+ readonly empty: boolean;
95
+ readonly selModel: StoreSelectionModel;
96
+ readonly hasSelection: boolean;
97
+ readonly selectedRecords: StoreRecord[];
98
+ readonly selectedRecord: StoreRecord;
99
+ readonly selectedId: StoreRecordId;
100
+ selectAsync(records: Some<StoreRecordOrId>, opts?: GridSelectOptions): Promise<void>;
101
+ preSelectFirstAsync(): Promise<void>;
102
+ selectFirstAsync(opts?: GridSelectFirstOptions): Promise<void>;
103
+ ensureSelectionVisibleAsync(opts?: GridEnsureVisibleOptions): Promise<void>;
104
+ }
55
105
  /**
56
106
  * Closure to generate CSS class names for a row.
57
107
  * @param record - the StoreRecord associated with the rendered row.
@@ -51,7 +51,8 @@ export interface ColumnSpec {
51
51
  description?: string;
52
52
  /**
53
53
  * User-facing text/element displayed in the Column header, or a function to produce the same.
54
- * Defaulted from `displayName`.
54
+ * Defaulted from the field's `shortDisplayName` unless this Column sets its own `displayName`,
55
+ * then from `displayName`.
55
56
  */
56
57
  headerName?: ColumnHeaderNameFn | ReactNode;
57
58
  /** Tooltip text for grid header. Defaults from `description` when not explicitly set. */
@@ -28,6 +28,11 @@ export interface ColumnGroupSpec {
28
28
  headerAlign?: HAlign;
29
29
  /** Tooltip text for grid header. */
30
30
  headerTooltip?: string;
31
+ /**
32
+ * Name to display within the column chooser. Defaults to `headerName` when that is a string,
33
+ * otherwise derived from `groupId`. Specify when `headerName` is a function or element.
34
+ */
35
+ chooserName?: string;
31
36
  /** True to render borders on column group edges. */
32
37
  borders?: boolean;
33
38
  /**
@@ -67,6 +72,7 @@ export declare class ColumnGroup {
67
72
  readonly headerClass: Some<string> | ColumnHeaderClassFn;
68
73
  readonly headerAlign: HAlign;
69
74
  readonly headerTooltip: string;
75
+ readonly chooserName: string;
70
76
  readonly borders: boolean;
71
77
  readonly groupShowMode: ColumnGroupShowMode;
72
78
  readonly collapsed: boolean;
@@ -1,8 +1,11 @@
1
1
  import type { BoxProps, HoistProps } from '@xh/hoist/core';
2
- import { GridModel } from '../GridModel';
2
+ import type { GridLikeModel } from '../Types';
3
3
  export interface GridCountLabelProps extends HoistProps, BoxProps {
4
- /** GridModel to which this component should bind. */
5
- gridModel?: GridModel;
4
+ /**
5
+ * GridModel, or a model wrapping one, to which this component should bind. Will find the
6
+ * nearest in context if not provided.
7
+ */
8
+ gridModel?: GridLikeModel;
6
9
  /**
7
10
  * True to count nested child records.
8
11
  * If false (default) only root records will be included in count.
@@ -1,4 +1,5 @@
1
1
  import type { GridAutosizeOptions } from '@xh/hoist/cmp/grid/GridAutosizeOptions';
2
+ import type { SizingMode } from '@xh/hoist/core';
2
3
  import type { Filter, StoreRecord } from '@xh/hoist/data';
3
4
  import type { Column } from '../columns';
4
5
  import type { GridModel } from '../GridModel';
@@ -27,6 +28,11 @@ export declare class ColumnWidthCalculator {
27
28
  calcDataWidthAsync(gridModel: any, records: any, column: any, options: any): Promise<number>;
28
29
  calcLevelWidthAsync(gridModel: GridModel, records: StoreRecord[], column: Column, options: Omit<GridAutosizeOptions, 'columns'>, indentationPx?: number): Promise<number>;
29
30
  getHeaderWidth(gridModel: any, column: any, includeHeaderIcons: any, bufferPx: any): any;
31
+ /**
32
+ * Width of a plain-text header label, with the header font and padding of a sizing mode, and
33
+ * optionally the expand icon of a collapsible column group.
34
+ */
35
+ calcHeaderTextWidth(sizingMode: SizingMode, text: string, withExpandIcon?: boolean): number;
30
36
  isColumnFiltered(filter: Filter, column: Column): boolean;
31
37
  getHeaderHtml(gridModel: any, column: any): string;
32
38
  resetHeaderClassNames(): void;
@@ -0,0 +1,3 @@
1
+ import type { GridLikeModel } from '@xh/hoist/cmp/grid';
2
+ /** True for a GridModel, or any model exposing one as `innerGridModel`. */
3
+ export declare function isGridLikeModel(it: unknown): it is GridLikeModel;
@@ -1,4 +1,5 @@
1
1
  import type { GridModel } from '@xh/hoist/cmp/grid';
2
+ import { RecordAction } from '@xh/hoist/data';
2
3
  import { type GetContextMenuItemsParams, type GetMainMenuItemsParams, type MenuItemDef } from '@xh/hoist/kit/ag-grid';
3
4
  import type { GridContextMenuSpec, GridHeaderContextMenuSpec } from '../GridContextMenu';
4
5
  /** ag-Grid params for a cell context menu, or for a column header one, which carries no row. */
@@ -9,4 +10,16 @@ type GridMenuAgParams = GetContextMenuItemsParams | (GetMainMenuItemsParams & {
9
10
  * @internal
10
11
  */
11
12
  export declare function getAgGridMenuItems(params: GridMenuAgParams, model: GridModel, spec: GridContextMenuSpec | GridHeaderContextMenuSpec): Array<string | MenuItemDef>;
13
+ /** Levels that expand and collapse together - the rows of a GridModel, or a pivot's columns. */
14
+ export interface ExpandLevelTarget {
15
+ maxDepth: number;
16
+ /** Label per level, by index. A null label leaves its level out of "Expand to...". */
17
+ resolvedLevelLabels: string[];
18
+ isCurrentExpandLevel(idx: number): boolean;
19
+ expandToLevel(level: number): void;
20
+ expandAll(): void;
21
+ collapseAll(): void;
22
+ }
23
+ /** @internal - Expand All, Collapse All and Expand to... items for the target's levels. */
24
+ export declare function createExpandCollapseItem(target: ExpandLevelTarget): RecordAction[];
12
25
  export {};
@@ -0,0 +1,14 @@
1
+ import type { HoistProps, LayoutProps, TestSupportProps } from '@xh/hoist/core';
2
+ import { PdfViewerModel } from './PdfViewerModel';
3
+ import './PdfViewer.scss';
4
+ export interface PdfViewerProps extends HoistProps<PdfViewerModel>, LayoutProps, TestSupportProps {
5
+ }
6
+ /**
7
+ * Displays a PDF document with a built-in toolbar for page navigation, zoom, find, and
8
+ * download. Pages render on demand as they scroll into view, with selectable text.
9
+ *
10
+ * Configure the document and toolbar via the backing {@link PdfViewerModel}.
11
+ *
12
+ * @see PdfViewerModel
13
+ */
14
+ export declare const PdfViewer: import("react").FC<PdfViewerProps>, pdfViewer: import("@xh/hoist/core").ElementFactory<PdfViewerProps>;
@@ -0,0 +1,150 @@
1
+ import type { LoadSpec, PersistOptions } from '@xh/hoist/core';
2
+ import { HoistModel } from '@xh/hoist/core';
3
+ import type { PDFDocumentProxy } from 'pdfjs-dist/legacy/build/pdf.mjs';
4
+ import type { ReactNode } from 'react';
5
+ import type { PdfViewerToolbarModel } from './impl/PdfViewerToolbarModel';
6
+ import type { PdfFindResult, PdfScale, PdfSource, PdfViewerToolbarItem, PdfViewerToolbarSpec } from './Types';
7
+ export interface PdfViewerConfig {
8
+ /** The document to display. See {@link PdfViewerModel.setSource}. */
9
+ source?: PdfSource;
10
+ /** Filename for downloads. Defaults to the last segment of a URL source, or 'document.pdf'. */
11
+ filename?: string;
12
+ /** Initial zoom level. Default 'page-width'. */
13
+ scale?: PdfScale;
14
+ /** Toolbar items to display, or false to hide. Default true. See {@link PdfViewerToolbarSpec}. */
15
+ toolbar?: PdfViewerToolbarSpec;
16
+ /** Content to display when there is no document. Default 'No document to display.' */
17
+ emptyText?: ReactNode;
18
+ /** Options to persist the user's chosen zoom level. */
19
+ persistWith?: PersistOptions;
20
+ /** See {@link HoistBase.xhName}. */
21
+ xhName?: string;
22
+ }
23
+ export interface PdfViewerModelDefaults {
24
+ /** Default toolbar items for desktop apps. */
25
+ toolbar?: PdfViewerToolbarItem[];
26
+ /** Default toolbar items for mobile apps. */
27
+ mobileToolbar?: PdfViewerToolbarItem[];
28
+ }
29
+ /**
30
+ * Model for a {@link PdfViewer}, built on Mozilla's pdf.js. Loads a document from a URL, a
31
+ * {@link FetchOptions} object, or bytes held by the app, and exposes observable state and
32
+ * actions for page navigation, zoom, rotation, find, and download.
33
+ *
34
+ * Bind any of these to custom controls, or drive the viewer programmatically - the built-in
35
+ * toolbar is implemented entirely on this public API.
36
+ *
37
+ * Requires the app to add `pdfjs-dist` to its own dependencies. See the package README.
38
+ *
39
+ * @see PdfViewer
40
+ */
41
+ export declare class PdfViewerModel extends HoistModel implements PdfViewerToolbarModel {
42
+ /** App-level defaults for PdfViewerModel. Instance config takes precedence. */
43
+ static defaults: PdfViewerModelDefaults;
44
+ /** The document being displayed. */
45
+ accessor source: PdfSource;
46
+ /** The loaded pdf.js document, for direct access to its API. Null until loaded. */
47
+ accessor pdfDocument: PDFDocumentProxy;
48
+ /** Current page number, from 1. Tracks scrolling - call {@link goToPage} to change. */
49
+ accessor pageNumber: number;
50
+ /** Requested zoom level - a preset or a number. Call {@link setScale} to change. */
51
+ accessor scale: PdfScale;
52
+ /** Effective numeric scale, as resolved from {@link scale} for the current viewer size. */
53
+ accessor currentScale: number;
54
+ /** Page rotation in degrees - 0, 90, 180, or 270. */
55
+ accessor rotation: number;
56
+ /** Query of the current find, or '' if none. Call {@link findAsync} to change. */
57
+ accessor findQuery: string;
58
+ /** Count of find matches across the document. */
59
+ accessor findMatchCount: number;
60
+ /** Index of the selected find match, from 1. Zero if no matches. */
61
+ accessor findMatchNumber: number;
62
+ filename: string;
63
+ emptyText: ReactNode;
64
+ toolbar: PdfViewerToolbarItem[];
65
+ get isPdfViewerModel(): boolean;
66
+ /** Number of pages in the loaded document. */
67
+ get pageCount(): number;
68
+ /** True if a document is loaded and ready to display. */
69
+ get hasDocument(): boolean;
70
+ /** True while a find is searching the document. */
71
+ get isFinding(): boolean;
72
+ /** True if a document is set, whether or not it has loaded. */
73
+ get hasSource(): boolean;
74
+ /** @internal - scroll container for the pdf.js viewer, set by the component. */
75
+ containerRef: import("react").RefObject<HTMLDivElement> & import("react").RefCallback<HTMLDivElement>;
76
+ private pdfJs;
77
+ private loadingTask;
78
+ private viewer;
79
+ private linkService;
80
+ private findController;
81
+ private eventBus;
82
+ private eventsAbort;
83
+ private accessor pendingFind;
84
+ constructor(config?: PdfViewerConfig);
85
+ /** Set the document to display. Pass null to clear. */
86
+ setSource(source: PdfSource): void;
87
+ /** Download the loaded document. */
88
+ downloadAsync(): Promise<void>;
89
+ /** Filename used by {@link downloadAsync}. */
90
+ get downloadFilename(): string;
91
+ /** Scroll to a page, from 1. Out-of-range values are clamped. */
92
+ goToPage(pageNumber: number): void;
93
+ nextPage(): void;
94
+ previousPage(): void;
95
+ get canGoNext(): boolean;
96
+ get canGoPrevious(): boolean;
97
+ /** Set the zoom level. */
98
+ setScale(scale: PdfScale): void;
99
+ zoomIn(): void;
100
+ zoomOut(): void;
101
+ /** Rotate all pages by the given number of degrees - a multiple of 90. Default 90. */
102
+ rotate(degrees?: number): void;
103
+ /**
104
+ * Search the document for text, and resolve once every page has been searched. Sets
105
+ * {@link findQuery}, highlights all matches, and scrolls to the first match at or after the
106
+ * current page. Pass '' to clear the find.
107
+ *
108
+ * Each call runs a new search, even for an unchanged query. A call made before the document
109
+ * has loaded waits for it to load and display, then searches. A newer find, a source change,
110
+ * a failed load, or `destroy()` resolves a call still in progress as `cancelled`.
111
+ *
112
+ * The query stays set when the source changes, and runs again on the new document.
113
+ *
114
+ * Matching is case-insensitive and ignores diacritics. pdf.js normalizes quotes, ligatures,
115
+ * whitespace, and line breaks, but a match cannot span pages.
116
+ */
117
+ findAsync(query: string): Promise<PdfFindResult>;
118
+ /** Clear the find query and its highlights. */
119
+ clearFind(): void;
120
+ /** Select and scroll to the next match for {@link findQuery}. */
121
+ findNext(): void;
122
+ /** Select and scroll to the previous match for {@link findQuery}. */
123
+ findPrevious(): void;
124
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
125
+ private isObsolete;
126
+ private getDataAsync;
127
+ private closeDocumentAsync;
128
+ private syncViewer;
129
+ private createViewer;
130
+ private destroyViewer;
131
+ private onPagesInit;
132
+ private onPageChanging;
133
+ private onScaleChanging;
134
+ private onFindMatchesCount;
135
+ private onFindControlState;
136
+ private onTextLayerMatches;
137
+ /**
138
+ * Settle the pending find once its result is final. pdf.js reports not found only after
139
+ * searching every page, but reports found at the first match - wait for all pages then,
140
+ * so the count is complete.
141
+ */
142
+ private checkFindDone;
143
+ private settleFind;
144
+ private applyScale;
145
+ private dispatchFind;
146
+ /** @internal - called by the component when the viewer is resized or shown. */
147
+ onResize(): void;
148
+ private parseToolbar;
149
+ destroy(): void;
150
+ }
@@ -0,0 +1,55 @@
1
+ import type { FetchOptions } from '@xh/hoist/svc';
2
+ import type { ReactNode } from 'react';
3
+ /**
4
+ * A PDF document to display. Either:
5
+ * - a URL, fetched via `XH.fetch()` - relative URLs resolve against `XH.baseUrl`.
6
+ * - a {@link FetchOptions} object, for POSTs, params, or custom headers.
7
+ * - the PDF bytes, as a `Blob` (or `File`), `ArrayBuffer`, or `Uint8Array`.
8
+ */
9
+ export type PdfSource = string | FetchOptions | Blob | ArrayBuffer | Uint8Array;
10
+ /**
11
+ * Zoom level for a {@link PdfViewerModel}. Either a numeric scale (1 = 100%) or a preset that
12
+ * re-fits the document as the viewer resizes:
13
+ * - `page-width` - fit page width to the viewer.
14
+ * - `page-fit` - fit the entire page within the viewer.
15
+ * - `page-actual` - display at actual size (100%).
16
+ * - `auto` - page width, capped at actual size.
17
+ */
18
+ export type PdfScale = 'page-width' | 'page-fit' | 'page-actual' | 'auto' | number;
19
+ /** Result of {@link PdfViewerModel.findAsync}. */
20
+ export interface PdfFindResult {
21
+ /**
22
+ * Outcome of the search:
23
+ * - `found` - the query matched, and the viewer scrolled to the selected match.
24
+ * - `notFound` - the query matched nowhere in the document, or was empty.
25
+ * - `cancelled` - the search ended early, due to a newer find, a source change, a failed
26
+ * load, or `destroy()`. Also returned when there is no source to search.
27
+ */
28
+ status: 'found' | 'notFound' | 'cancelled';
29
+ /** The query searched for. */
30
+ query: string;
31
+ /** Count of matches across the document. */
32
+ matchCount: number;
33
+ /** Index of the selected match across the document, from 1. Zero if none. */
34
+ matchNumber: number;
35
+ /** Page of the selected match, from 1. Null if none. */
36
+ pageNumber: number;
37
+ }
38
+ /**
39
+ * Built-in toolbar items:
40
+ * - `pageNav` - previous/next buttons and a page number input.
41
+ * - `zoom` - zoom in/out buttons and a zoom level menu.
42
+ * - `find` - search input with match count and previous/next buttons.
43
+ * - `rotate` - rotate pages clockwise.
44
+ * - `download` - download the document.
45
+ * - `-` - a separator.
46
+ * - `filler` - a flexible spacer, to right-align subsequent items.
47
+ */
48
+ export type PdfViewerToolbarToken = 'pageNav' | 'zoom' | 'find' | 'rotate' | 'download' | '-' | 'filler';
49
+ /** A built-in toolbar token or any custom element, such as a button. */
50
+ export type PdfViewerToolbarItem = PdfViewerToolbarToken | ReactNode;
51
+ /**
52
+ * Toolbar config for a {@link PdfViewerModel} - `true` for the platform default items (see
53
+ * {@link PdfViewerModel.defaults}), `false` to hide the toolbar, or a list of items.
54
+ */
55
+ export type PdfViewerToolbarSpec = boolean | PdfViewerToolbarItem[];
@@ -0,0 +1,14 @@
1
+ import { HoistModel } from '@xh/hoist/core';
2
+ import type { PdfViewerToolbarModel } from './PdfViewerToolbarModel';
3
+ /**
4
+ * Local model for a toolbar find input. Holds the text as the user types, and runs a find once
5
+ * typing pauses. Shows a query set by the app via `findAsync()`.
6
+ *
7
+ * @internal
8
+ */
9
+ export declare class PdfFindInputModel extends HoistModel {
10
+ xhImpl: boolean;
11
+ accessor query: string;
12
+ private readonly viewerModel;
13
+ constructor(viewerModel: PdfViewerToolbarModel);
14
+ }
@@ -0,0 +1,34 @@
1
+ import type { HoistModel } from '@xh/hoist/core';
2
+ import type { PdfScale, PdfViewerToolbarItem } from '../Types';
3
+ /**
4
+ * The members of {@link PdfViewerModel} that the platform toolbars use.
5
+ *
6
+ * Every app's AppContainer loads the toolbars. Typing them against this interface, not the model,
7
+ * keeps `tsc` from reaching the model's pdf.js imports in apps that do not install `pdfjs-dist`.
8
+ *
9
+ * @internal
10
+ */
11
+ export interface PdfViewerToolbarModel extends HoistModel {
12
+ readonly toolbar: PdfViewerToolbarItem[];
13
+ readonly hasDocument: boolean;
14
+ readonly pageNumber: number;
15
+ readonly pageCount: number;
16
+ readonly canGoNext: boolean;
17
+ readonly canGoPrevious: boolean;
18
+ goToPage(pageNumber: number): void;
19
+ nextPage(): void;
20
+ previousPage(): void;
21
+ readonly scale: PdfScale;
22
+ setScale(scale: PdfScale): void;
23
+ zoomIn(): void;
24
+ zoomOut(): void;
25
+ rotate(degrees?: number): void;
26
+ readonly findQuery: string;
27
+ readonly findMatchCount: number;
28
+ readonly findMatchNumber: number;
29
+ readonly isFinding: boolean;
30
+ findAsync(query: string): Promise<unknown>;
31
+ findNext(): void;
32
+ findPrevious(): void;
33
+ downloadAsync(): Promise<void>;
34
+ }
@@ -0,0 +1,10 @@
1
+ import type { PdfViewerToolbarModel } from './PdfViewerToolbarModel';
2
+ import type { PdfScale } from '../Types';
3
+ /**
4
+ * Options for a zoom level select, including the current scale if not otherwise listed.
5
+ * @internal
6
+ */
7
+ export declare function getZoomOptions(model: PdfViewerToolbarModel): {
8
+ value: PdfScale;
9
+ label: string;
10
+ }[];
@@ -0,0 +1,3 @@
1
+ export * from './PdfViewer';
2
+ export * from './PdfViewerModel';
3
+ export type * from './Types';
@@ -0,0 +1,90 @@
1
+ import type { KeyboardEvent, MouseEvent, ReactElement, ReactNode } from 'react';
2
+ import type { ComponentSize, DomAttrsProps, HoistProps, Intent, LayoutProps, TestSupportProps } from '@xh/hoist/core';
3
+ import './StatCard.scss';
4
+ export interface StatCardProps extends HoistProps, LayoutProps, TestSupportProps, DomAttrsProps {
5
+ /** Caption shown above the value. */
6
+ title: ReactNode;
7
+ /**
8
+ * Primary content, pre-formatted by the caller. The card never formats - currency, percent,
9
+ * precision and color decisions belong to the caller. A unit added with `fmtNumber`'s `label`
10
+ * option renders smaller than the figure.
11
+ *
12
+ * The value and sub-value are never truncated in normal layout - a card does not get narrower
13
+ * than them, and a {@link StatCardStrip} wraps cards to a new row instead. Compact large
14
+ * values with `fmtMillions` or `fmtQuantity` (e.g. `48.5m`). Only a card held narrower than
15
+ * its value - by an explicit `width` or `maxWidth` - shows an ellipsis.
16
+ */
17
+ value: ReactNode;
18
+ /**
19
+ * Smaller figure rendered inline after the value, e.g. a change vs. a prior period, a target
20
+ * or an average. Pass a `fmtNumber` result to color it by sign - and invert its `colorSpec`
21
+ * for a metric where down is good:
22
+ *
23
+ * ```ts
24
+ * subValue: fmtPercent(delta, {withSignGlyph: true, colorSpec: {pos: 'xh-neg-val', neg: 'xh-pos-val'}})
25
+ * ```
26
+ */
27
+ subValue?: ReactNode;
28
+ /** Sub-line beneath the value, e.g. what a change is measured against. */
29
+ detail?: ReactNode;
30
+ /**
31
+ * Supporting detail shown as a tooltip on an info icon after the title. Omit to render no icon.
32
+ * Desktop only - on mobile the icon shows, but its tooltip does not.
33
+ */
34
+ infoTooltip?: ReactElement | string;
35
+ /** Icon that shows `infoTooltip`. Default `Icon.info()`. */
36
+ infoIcon?: ReactElement;
37
+ /**
38
+ * Flags the card with a semantic color on its border, as with {@link Card}. Does not color
39
+ * the value - to do so, format the value with a `colorSpec` or wrap it in a styled element.
40
+ */
41
+ intent?: Intent;
42
+ /**
43
+ * CSS color for an accent bar, e.g. `var(--xh-blue)`, to mark a category or series identity.
44
+ * Use `intent` to flag a status.
45
+ *
46
+ * The bar runs along the top edge by default. Set the `--stat-card-accent-top`, `-right`,
47
+ * `-bottom` and `-left` CSS variables to choose its edge and thickness - e.g. a left bar with
48
+ * `--stat-card-accent-top: 0; --stat-card-accent-left: 4px`.
49
+ */
50
+ accent?: string;
51
+ /**
52
+ * Size of the card - `large` for a headline figure, with a bigger value, captions and padding.
53
+ * Default `standard`. Set the `--xh-stat-card-large-*` CSS variables to tune the large size.
54
+ *
55
+ * A large card stands best on its own or in a strip of large cards. In a wrapped strip, every
56
+ * column takes the width of the widest card.
57
+ */
58
+ size?: Extract<ComponentSize, 'standard' | 'large'>;
59
+ /**
60
+ * Handler for a click or Enter/Space keypress on the card, e.g. to drill into the figure.
61
+ * Makes the card focusable and styles it as clickable.
62
+ */
63
+ onClick?: (e: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>) => void;
64
+ }
65
+ /**
66
+ * A tile that calls out a key figure: a caption over a prominent value, with an optional inline
67
+ * sub-value, info tooltip and sub-line.
68
+ *
69
+ * The card is presentation-only. Callers pass an already-formatted `value` - the card never
70
+ * formats or colors a value based on its content.
71
+ *
72
+ * A card on its own sizes to its content. For a row of cards, use {@link StatCardStrip} rather
73
+ * than an `hbox` - a strip shares out the width, wraps cards before a value is cut short, and
74
+ * truncates other lines with an ellipsis, showing their full text in a tooltip.
75
+ */
76
+ export declare const StatCard: import("react").FC<StatCardProps>, statCard: import("@xh/hoist/core").ElementFactory<StatCardProps>;
77
+ export interface StatCardStripProps extends HoistProps, LayoutProps, TestSupportProps, DomAttrsProps {
78
+ }
79
+ /**
80
+ * A row of {@link StatCard}s, passed as `items`, each given an equal share of the strip's width.
81
+ * Pass `flex` or `width` to a card to weight or fix its share.
82
+ *
83
+ * When the cards no longer fit on one row, the strip becomes an even grid with as many columns as
84
+ * fit its widest card, so cards on later rows line up under those above. A card is never narrower
85
+ * than its value and sub-value, or than the `--xh-stat-card-min-content-width` CSS variable. A
86
+ * card's `flex` does not apply in the grid.
87
+ *
88
+ * Renders nothing if given no cards - use `omit` on a card to leave it out.
89
+ */
90
+ export declare const StatCardStrip: import("react").FC<StatCardStripProps>, statCardStrip: import("@xh/hoist/core").ElementFactory<StatCardStripProps>;
@@ -0,0 +1 @@
1
+ export * from './StatCard';