@xh/hoist 89.0.0 → 89.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 (68) hide show
  1. package/CHANGELOG.md +61 -5
  2. package/appcontainer/MessageModel.ts +11 -10
  3. package/appcontainer/README.md +6 -2
  4. package/build/types/appcontainer/MessageModel.d.ts +4 -1
  5. package/build/types/cmp/input/impl/LiveCommas.d.ts +21 -0
  6. package/build/types/core/XH.d.ts +7 -6
  7. package/build/types/core/model/HoistModel.d.ts +1 -0
  8. package/build/types/core/model/ManagedRefreshContextModel.d.ts +1 -0
  9. package/build/types/data/cube/View.d.ts +0 -2
  10. package/build/types/data/cube/impl/RowCache.d.ts +1 -1
  11. package/build/types/data/cube/row/BaseRow.d.ts +5 -0
  12. package/build/types/desktop/cmp/grid/editors/impl/InlineEditorModel.d.ts +6 -1
  13. package/build/types/desktop/cmp/input/NumberInput.d.ts +5 -2
  14. package/build/types/mobile/cmp/input/NumberInput.d.ts +5 -2
  15. package/build/types/test-support/agGrid.d.ts +2 -0
  16. package/build/types/test-support/hoistCore.d.ts +7 -1
  17. package/build/types/test-support/index.d.ts +1 -0
  18. package/build/types/test-support/jsonBlobs.d.ts +130 -0
  19. package/build/types/test-support/testApp.d.ts +5 -2
  20. package/cmp/grid/Grid.ts +1 -1
  21. package/cmp/grid/GridModel.ts +8 -3
  22. package/cmp/grid/columns/Column.ts +1 -1
  23. package/cmp/input/impl/LiveCommas.ts +59 -0
  24. package/core/XH.ts +7 -6
  25. package/core/model/HoistModel.ts +4 -2
  26. package/core/model/Hooks.ts +1 -0
  27. package/core/model/ManagedRefreshContextModel.ts +5 -1
  28. package/data/README.md +3 -2
  29. package/data/cube/View.ts +3 -9
  30. package/data/cube/impl/RowCache.ts +2 -2
  31. package/data/cube/row/BaseRow.ts +14 -1
  32. package/data/cube/row/ParentRow.ts +1 -1
  33. package/desktop/cmp/dash/canvas/impl/DashCanvasView.ts +49 -52
  34. package/desktop/cmp/grid/editors/BooleanEditor.ts +2 -1
  35. package/desktop/cmp/grid/editors/DateEditor.ts +4 -1
  36. package/desktop/cmp/grid/editors/SelectEditor.ts +4 -1
  37. package/desktop/cmp/grid/editors/impl/InlineEditorModel.ts +17 -5
  38. package/desktop/cmp/input/NumberInput.ts +51 -12
  39. package/desktop/cmp/input/Select.ts +25 -7
  40. package/docs/README.md +2 -0
  41. package/docs/companion-library-docs.md +205 -0
  42. package/docs/doc-registry.json +8 -0
  43. package/docs/lifecycle-app.md +17 -0
  44. package/docs/unit-testing.md +54 -3
  45. package/docs/upgrade-notes/v89-upgrade-notes.md +101 -2
  46. package/docs/version-compatibility.md +2 -1
  47. package/icon/README.md +4 -1
  48. package/mcp/README.md +79 -4
  49. package/mcp/cli/docs.ts +75 -30
  50. package/mcp/data/doc-id-resolver.ts +50 -9
  51. package/mcp/data/doc-registry.ts +462 -44
  52. package/mcp/data/doc-search.ts +25 -6
  53. package/mcp/formatters/docs.ts +136 -36
  54. package/mcp/instructions.ts +69 -0
  55. package/mcp/resources/docs.ts +10 -8
  56. package/mcp/server.ts +7 -13
  57. package/mcp/tools/docs.ts +64 -18
  58. package/mcp/util/paths.ts +85 -2
  59. package/mobile/cmp/input/NumberInput.ts +42 -4
  60. package/package.json +19 -19
  61. package/public/msal-redirect-bridge.min.js +1 -1
  62. package/svc/JsonBlobService.ts +7 -4
  63. package/test-support/agGrid.ts +12 -2
  64. package/test-support/hoistCore.ts +32 -5
  65. package/test-support/index.ts +1 -0
  66. package/test-support/jsonBlobs.ts +543 -0
  67. package/test-support/setup.ts +16 -6
  68. package/test-support/testApp.ts +36 -7
package/CHANGELOG.md CHANGED
@@ -11,10 +11,63 @@
11
11
  codebase, or with the symbol itself (`Foo.bar` now ...) when a living API changed behavior.
12
12
  3. Plain ASCII punctuation only. Use " - " for in-sentence breaks, never an em dash.
13
13
  -->
14
+ ## 89.1.0 - 2026-10-19
15
+
16
+ ### 🎁 New Features
17
+
18
+ * `Column.DEFAULT_WIDTH` is now 100px, up from 60px, to reduce layout shift when autosizing.
19
+ * Added JsonBlob and ViewManager support to the fake hoist-core in `@xh/hoist/test-support`. App
20
+ specs can now boot an app that creates `ViewManagerModel`s with no setup, and seed views and view
21
+ state with `hoistCore.jsonBlobs`.
22
+ * `NumberInput.displayWithCommas` now accepts `'always'` to insert commas while the user types,
23
+ on desktop and mobile. `'whenBlurred'` names the existing behavior, and `true` remains its alias.
24
+
25
+ ### 🐞 Bug Fixes
26
+
27
+ * Fixed stale records in a `Store` rebound from one Cube `View` to another.
28
+ * Fixed `SelectEditor`, `DateEditor`, and `BooleanEditor` overwriting a cell's value when an edit
29
+ was started by typing a character. `SelectEditor` now enters the character as search text,
30
+ `DateEditor` as typed text, and `BooleanEditor` ignores it.
31
+ * Fixed `XH.jsonBlobService.findAsync()` finding only global blobs. It sent no owner, so it never
32
+ returned a blob owned by the current user, as its docs describe.
33
+ * Fixed desktop `NumberInput` with `min` or `max` rendering blank on mount when its formatted value
34
+ was not a plain number, as with `displayWithCommas` and a value of 1,000 or more, or a
35
+ `valueLabel`. Changing `min` or `max` on such an input could also set its value to 0.
36
+ * Fixed `onShowLazy` tabs and other managed refresh contexts replaying a missed auto-refresh as a
37
+ manual refresh when shown. The replay now stays an auto-refresh unless a missed refresh was manual.
38
+ * Fixed a model created with `creates()` re-running `onLinked()` on every render when its component
39
+ had no Hoist model above it, as in a component test rendered at the root.
40
+
41
+ ### 🤖 AI Docs + Tooling
42
+
43
+ * The hoist-react MCP server and `hoist-docs` CLI now serve docs from companion libraries that build
44
+ on Hoist, such as `@xh/hoist-chat-kit` or a client firm's shared package. A library opts in with
45
+ `"hoist": {"docRegistry": "<path>"}` in its `package.json`. Its doc ids take the package name as
46
+ a prefix, and the server instructions name each library. A library can also add guidance for
47
+ agents with `mcpInstructions`, for example which Hoist components it replaces, and keep its
48
+ maintainer docs out of apps with `"mcpAudience": "maintainers"`. See
49
+ [Companion Library Docs](docs/companion-library-docs.md).
50
+
51
+ ## 89.0.1 - 2026-10-14
52
+
53
+ ### 🐞 Bug Fixes
54
+
55
+ * `GridModel.setColumnState()` now drops repeated `colId` entries from saved column state, keeping
56
+ the first. Saved state with a repeated column made the v87 column chooser silently error and break.
57
+ * Fixed desktop `DashCanvas` failing to render in v89.0.0.
58
+ * Fixed `XH.message()`, `XH.confirm()`, and `XH.prompt()` resolving to `null` when a route change
59
+ or other forced close shut the dialog. Callers that tested `!== false` ran the confirmed action.
60
+ A dialog closed without a choice now resolves to `false`, the same as a cancel. A dismiss with
61
+ `cancelOnDismiss: false` also resolves to `false` - the flag now only skips `onCancel`.
62
+
63
+ ### ⚙️ Technical
64
+
65
+ * The unit test kit now stubs `ResizeObserver`, which jsdom lacks, so app specs can render
66
+ components that track their own size.
14
67
 
15
68
  ## 89.0.0 - 2026-10-13
16
69
 
17
- ### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW - filter specs, app option presets, icon listing, grid defaults, badge spacing, column library config)
70
+ ### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW - filter specs, app option presets, icon listing, grid defaults, grid options, badge spacing, column library config)
18
71
 
19
72
  See [`docs/upgrade-notes/v89-upgrade-notes.md`](docs/upgrade-notes/v89-upgrade-notes.md) for
20
73
  detailed, step-by-step upgrade instructions with before/after code examples.
@@ -35,6 +88,9 @@ detailed, step-by-step upgrade instructions with before/after code examples.
35
88
  `span('Users ', badge(n))`, or with a `gap` on an enclosing `hbox`.
36
89
  * Removed `ColLibraryConfig.autoExpandOnFilter`. The Column Library now expands every group with a
37
90
  match while a search is active. Remove the key from any `columnLibrary` config.
91
+ * `Grid` now ignores `agOptions.groupDefaultExpanded`. Set `GridModel.expandLevel` instead.
92
+ * Removed `GridExperimentalFlags.disableScrollOptimization`. The post-load row height pass it
93
+ disabled now runs only for grids whose rows vary in height. Remove the key from grid configs.
38
94
 
39
95
  ### 🎁 New Features
40
96
 
@@ -123,7 +179,8 @@ detailed, step-by-step upgrade instructions with before/after code examples.
123
179
  * Fixed `@sharePendingPromise` running a method twice when it threw synchronously.
124
180
  * Fixed a cancelled `Timer` keeping its heartbeat alive, and a `Timer` with `delay: true` and a
125
181
  disabled interval scheduling a negative timeout.
126
- * Fixed a `PUT` with `params` labeling its form body `text/plain`, so servers ignored the params.
182
+ * `FetchService` now sends every `PUT` without a `Content-Type` as form-encoded, as for `POST`.
183
+ A `PUT` with `params` sent `text/plain`, so servers ignored the params.
127
184
  * Fixed errors reported by `ExceptionHandler` omitting the type and number of a failed load.
128
185
  Arrays in these reports, such as the stack trace, are also no longer sent as objects.
129
186
  * Fixed `XH.reloadApp()` re-encoding spaces in existing query params as `+`, and leaving its
@@ -155,8 +212,6 @@ detailed, step-by-step upgrade instructions with before/after code examples.
155
212
  * `AgGrid` now publishes its row and header heights to ag-Grid as `--ag-row-height` and
156
213
  `--ag-header-height`. `Grid` and `AgGrid` pass ag-Grid a `getRowHeight` function only when row
157
214
  heights vary, so uniform grids skip per-row height calls and the post-load row height pass.
158
- * Removed `GridExperimentalFlags.disableScrollOptimization`. The post-load row height pass now
159
- runs only for grids whose rows vary in height, where it prevents rows shifting on scroll.
160
215
  * `Column` tooltips no longer mount for rows without a record, or for editable cells with no
161
216
  validation results, and the tooltip component is a plain function component.
162
217
  * `Grid` now passes AG Grid only the pinned rows that changed. A summary row update redraws the
@@ -178,7 +233,8 @@ detailed, step-by-step upgrade instructions with before/after code examples.
178
233
  spurious one-time re-render.
179
234
  * `Store` now patches small changes by default (`experimental.maxPatchRatio` of 0.1). Records added
180
235
  by a change append rather than taking their source position. This may affect the sort ordering
181
- of unsorted grids when data changes.
236
+ of unsorted grids when data changes. Filters that read state outside the record must call
237
+ `Store.refreshFilter()` when that state changes.
182
238
  * `Field` now skips DOMPurify for strings with no `<` when `enableXssProtection` is set. Such
183
239
  strings hold no markup, so large loads skip one DOMPurify call per string value.
184
240
  * `Field` now parses every unparseable `date` value to one shared Invalid Date, preventing an
@@ -38,7 +38,7 @@ export class MessageModel extends HoistModel {
38
38
  dismissable;
39
39
  cancelOnDismiss;
40
40
 
41
- // Promise settled when the message closes - with the user's choice, or null if forced close
41
+ // Promise settled when the message closes - with the user's choice, or false if forced closed
42
42
  result;
43
43
  _resolver;
44
44
 
@@ -152,7 +152,8 @@ export class MessageModel extends HoistModel {
152
152
  const {formModel} = this;
153
153
  if (formModel) {
154
154
  await formModel.validateAsync();
155
- if (!formModel.isValid) return;
155
+ // Message may have been force closed while validating - its result is already false.
156
+ if (!this.isOpen || !formModel.isValid) return;
156
157
  const data = formModel.getData();
157
158
  if (formModel.getField('value')) {
158
159
  resolvedVal = data.value;
@@ -169,22 +170,22 @@ export class MessageModel extends HoistModel {
169
170
  @action
170
171
  doCancel() {
171
172
  this.onCancel?.();
172
- this.close(false);
173
+ this.close();
173
174
  }
174
175
 
175
176
  @action
176
177
  doEscape() {
177
178
  if (!this.dismissable) return;
178
- if (this.cancelOnDismiss) {
179
- this.doCancel();
180
- return;
181
- }
182
- this.close();
179
+ this.cancelOnDismiss ? this.doCancel() : this.close();
183
180
  }
184
181
 
185
- /** Close the message, settling `result` with the given value. */
182
+ /**
183
+ * Close the message, settling `result` with the given value. Defaults to false, so a close
184
+ * the user did not choose reads as a cancel to every caller - see `XH.message()`.
185
+ */
186
186
  @action
187
- close(result: unknown = null) {
187
+ close(result: unknown = false) {
188
+ if (!this.isOpen) return;
188
189
  this._resolver(result);
189
190
  this.isOpen = false;
190
191
  }
@@ -84,6 +84,9 @@ methods return a `Promise` that resolves when the user responds, making them ide
84
84
  The generic modal dialog API — all other message methods delegate to it. Returns
85
85
  `Promise<boolean>` that resolves to `true` on confirm, `false` on cancel.
86
86
 
87
+ A message that the user dismisses, or that closes without a choice, also resolves to `false`. A
88
+ route change, a later message with the same `messageKey`, or a destroy closes a message this way.
89
+
87
90
  ```typescript
88
91
  const result = await XH.message({
89
92
  title: 'Export Complete',
@@ -153,7 +156,8 @@ const confirmed = await XH.confirm({
153
156
  ### `XH.prompt(config)`
154
157
 
155
158
  An input collection dialog with a default `TextInput`, "OK" and "Cancel" buttons. Returns
156
- `Promise<value | false>` — the input value on confirm, `false` on cancel.
159
+ `Promise<value | false>` — the input value on confirm, `false` on cancel. If an empty input is a
160
+ valid answer, test the result with `!== false`, because `null` and `''` are confirmed values.
157
161
 
158
162
  The default TextInput comes pre-configured with `autoFocus`, `selectOnFocus`, and
159
163
  enter-to-confirm (desktop only). Custom inputs must set their own props.
@@ -222,7 +226,7 @@ XH.alert({
222
226
  | `onConfirm` | `() => void` | Callback fired on confirm (in addition to Promise resolution) |
223
227
  | `onCancel` | `() => void` | Callback fired on cancel (in addition to Promise resolution) |
224
228
  | `dismissable` | `boolean` | Whether Escape or clicking outside closes the dialog. Defaults to `true` when cancel button is present |
225
- | `cancelOnDismiss` | `boolean` | Whether dismissing executes the cancel action (vs resolving to `null`). Default `true` |
229
+ | `cancelOnDismiss` | `boolean` | Whether dismissing calls `onCancel`. The result is `false` either way. Default `true` |
226
230
 
227
231
  **MessageSpecInput** (for `XH.prompt()` config):
228
232
 
@@ -41,7 +41,10 @@ export declare class MessageModel extends HoistModel {
41
41
  doConfirmAsync(): Promise<void>;
42
42
  doCancel(): void;
43
43
  doEscape(): void;
44
- /** Close the message, settling `result` with the given value. */
44
+ /**
45
+ * Close the message, settling `result` with the given value. Defaults to false, so a close
46
+ * the user did not choose reads as a cancel to every caller - see `XH.message()`.
47
+ */
45
48
  close(result?: unknown): void;
46
49
  destroy(): void;
47
50
  private parseButtonProps;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Helpers for NumberInput's `displayWithCommas: 'always'` mode, which groups digits while the user
3
+ * types. Commas are the only characters a reformat adds or removes, so the caret is tracked as a
4
+ * count of the non-comma characters before it.
5
+ * @internal
6
+ */
7
+ /**
8
+ * Group the leading integer digits of a partially typed number with commas. Everything after them
9
+ * (decimals, exponent, shorthand unit) is kept as typed.
10
+ */
11
+ export declare function addCommasWhileEditing(value: string): string;
12
+ /** Count of non-comma characters before the caret, or null if the input has no caret. */
13
+ export declare function getCaretSkippingCommas(input: HTMLInputElement): number;
14
+ /** Place the caret after the given count of non-comma characters. */
15
+ export declare function setCaretSkippingCommas(input: HTMLInputElement, count: number): void;
16
+ /**
17
+ * `beforeinput` listener that steps the caret over an adjacent comma before Backspace or Delete, so
18
+ * the key removes the digit beyond it. Otherwise the reformat would restore the deleted comma.
19
+ * Listens for the native event, which (unlike `keydown`) reports deletes from mobile soft keyboards.
20
+ */
21
+ export declare function skipCommaOnDelete(ev: InputEvent): void;
@@ -335,10 +335,10 @@ export declare class XHApi {
335
335
  * this method will resolve immediately to their previously saved response, without showing
336
336
  * a dialog. This also applies to the `alert`, `confirm`, and `prompt` variants below.
337
337
  *
338
- * @returns true if user confirms, false if user cancels. If an input is provided, the
339
- * returned Promise will resolve to the input value if user confirms, false if user cancels.
340
- * Resolves to null if the message is closed without a choice - e.g. by a route change or
341
- * when replaced by a later message with the same `messageKey`.
338
+ * @returns true if the user confirms, or the input value if an input is provided. Resolves
339
+ * false for any other outcome - a cancel, a dismiss, or a close without a choice, e.g. by a
340
+ * route change or a later message with the same `messageKey`. With an input, test the result
341
+ * with `!== false`, as null and an empty string are valid confirmed values.
342
342
  */
343
343
  message<T = unknown>(config: MessageSpec): Promise<T | boolean>;
344
344
  /**
@@ -348,7 +348,7 @@ export declare class XHApi {
348
348
  alert(config: MessageSpec): Promise<boolean>;
349
349
  /**
350
350
  * Show a modal 'confirm' dialog with message and default 'OK'/'Cancel' buttons.
351
- * @returns true if user confirms, false if user cancels.
351
+ * @returns true if user confirms, false otherwise. See {@link message} for details.
352
352
  */
353
353
  confirm(config: MessageSpec): Promise<boolean>;
354
354
  /**
@@ -360,7 +360,8 @@ export declare class XHApi {
360
360
  * 3. onKeyDown handler to confirm on <enter> (same as clicking 'OK') (desktop only)
361
361
  * Applications may also provide a custom HoistInput, in which all props must be set.
362
362
  *
363
- * @returns value of input if user confirms, false if user cancels.
363
+ * @returns value of input if user confirms, false otherwise. See {@link message} for details.
364
+ * Test the result with `!== false`, as null and an empty string are valid confirmed values.
364
365
  */
365
366
  prompt<T = unknown>(config: MessageSpec): Promise<T | false>;
366
367
  /**
@@ -110,6 +110,7 @@ export declare abstract class HoistModel extends HoistBase implements Loadable {
110
110
  static get isHoistModel(): boolean;
111
111
  get isHoistModel(): boolean;
112
112
  accessor _componentProps: DefaultHoistProps | null;
113
+ _linked: boolean;
113
114
  _modelLookup: any;
114
115
  _created: number;
115
116
  constructor();
@@ -17,6 +17,7 @@ export declare class ManagedRefreshContextModel extends RefreshContextModel {
17
17
  xhImpl: boolean;
18
18
  model: ManagedRefreshTarget;
19
19
  refreshPending: boolean;
20
+ private pendingIsAutoRefresh;
20
21
  constructor(model: ManagedRefreshTarget);
21
22
  doLoadAsync(loadSpec: LoadSpec): Promise<void>;
22
23
  noteActiveChanged(isActive: boolean): void;
@@ -97,7 +97,6 @@ export declare class View extends HoistBase implements FilterBindTarget, FilterV
97
97
  private _bucketDependentFields;
98
98
  private _fieldsByName;
99
99
  private _rowDataGenerator;
100
- _rowDigest: number;
101
100
  _aggFieldsByDepth: CubeField[][];
102
101
  _aggFieldNamesByDepth: Set<string>[];
103
102
  _canAggregateFnFieldsByDepth: CubeField[][];
@@ -149,7 +148,6 @@ export declare class View extends HoistBase implements FilterBindTarget, FilterV
149
148
  * @internal
150
149
  */
151
150
  newLeafRowData(id: string, src: PlainObject): ViewRowData;
152
- assignDigest(data: ViewRowData): void;
153
151
  private buildIndices;
154
152
  private fullUpdate;
155
153
  private dataOnlyUpdate;
@@ -1,5 +1,5 @@
1
1
  import type { StoreRecord } from '@xh/hoist/data';
2
- import type { BaseRow } from '../row/BaseRow';
2
+ import { BaseRow } from '../row/BaseRow';
3
3
  import type { View } from '../View';
4
4
  /**
5
5
  * Cache of the BaseRows generated by a View, allowing rows - with their published data objects
@@ -9,6 +9,11 @@ import type { ParentRow } from './ParentRow';
9
9
  * @internal
10
10
  */
11
11
  export declare abstract class BaseRow implements ViewRow {
12
+ private static lastDigest;
13
+ /** The latest cubeRowDigest stamp given out by any View. */
14
+ static get currentDigest(): number;
15
+ /** Stamp row data with a new cubeRowDigest, marking it changed. */
16
+ static assignDigest(data: ViewRowData): void;
12
17
  readonly view: View;
13
18
  readonly id: string;
14
19
  data: PlainObject;
@@ -1,3 +1,4 @@
1
+ import { HoistInputModel } from '@xh/hoist/cmp/input';
1
2
  import { ElementFactory } from '@xh/hoist/core';
2
3
  import { EditorProps } from '@xh/hoist/desktop/cmp/grid/editors/EditorProps';
3
4
  import { ForwardedRef, ReactElement } from 'react';
@@ -11,5 +12,9 @@ import { ForwardedRef, ReactElement } from 'react';
11
12
  * @param component - ElementFactory for HoistInput to render.
12
13
  * @param props - props passed to containing component
13
14
  * @param ref - forwardRef passed to containing component
15
+ * @param applyInitialKey - applies a printable key that started the edit to the focused input.
16
+ * Defaults to entering the key as the input's value.
14
17
  */
15
- export declare function useInlineEditorModel(component: ElementFactory, props: EditorProps<any>, ref: ForwardedRef<any>): ReactElement;
18
+ export declare function useInlineEditorModel(component: ElementFactory, props: EditorProps<any>, ref: ForwardedRef<any>, applyInitialKey?: InitialKeyFn): ReactElement;
19
+ /** Applies the printable key that started an edit to the editor's focused input. */
20
+ export type InitialKeyFn = (input: HoistInputModel, key: string) => void;
@@ -10,8 +10,11 @@ export interface NumberInputProps extends HoistProps, LayoutProps, StyleProps, H
10
10
  autoFocus?: boolean;
11
11
  /** True to commit on every change/keystroke, default false. */
12
12
  commitOnChange?: boolean;
13
- /** True to insert commas in displayed value. */
14
- displayWithCommas?: boolean;
13
+ /**
14
+ * Insert commas in displayed value - 'whenBlurred' (or true) to show them only when the input
15
+ * does not have focus, 'always' to also show them while the user types.
16
+ */
17
+ displayWithCommas?: boolean | 'always' | 'whenBlurred';
15
18
  /** True to convert entries suffixed with k/m/b to thousands/millions/billions. */
16
19
  enableShorthandUnits?: boolean;
17
20
  /** Ref handler that receives HTML <input> element backing this component. */
@@ -8,8 +8,11 @@ export interface NumberInputProps extends HoistProps, HoistInputProps, PasswordM
8
8
  value?: number;
9
9
  /** True to commit on every change/keystroke, default false. */
10
10
  commitOnChange?: boolean;
11
- /** True to insert commas in displayed value. */
12
- displayWithCommas?: boolean;
11
+ /**
12
+ * Insert commas in displayed value - 'whenBlurred' (or true) to show them only when the input
13
+ * does not have focus, 'always' to also show them while the user types.
14
+ */
15
+ displayWithCommas?: boolean | 'always' | 'whenBlurred';
13
16
  /** True to convert entries suffixed with k/m/b to thousands/millions/billions. */
14
17
  enableShorthandUnits?: boolean;
15
18
  /**
@@ -11,5 +11,7 @@
11
11
  * ag-Grid renders its header, rows and cells in jsdom, which has no layout. Every row and column
12
12
  * renders regardless of the viewport, so virtualisation cannot be observed here, and measured
13
13
  * sizes read back as zero. Inline styles and CSS variables can be read as set.
14
+ *
15
+ * Throws if the installed ag-Grid is outside the range Hoist supports.
14
16
  */
15
17
  export declare function installAgGridForTests(): void;
@@ -1,5 +1,6 @@
1
1
  import { type PlainObject } from '@xh/hoist/core';
2
2
  import { type HttpHandler } from 'msw';
3
+ import { FakeJsonBlobStore } from './jsonBlobs';
3
4
  /** URL prefix for Hoist server calls - `XH.baseUrl`, from the `xhBaseUrl` build constant. */
4
5
  export declare const BASE_URL: string;
5
6
  /** A request served by the fake, recorded so tests can assert what the client sent. */
@@ -84,9 +85,14 @@ export declare class FakeHoistCore {
84
85
  * each zone's offset when it answers, as hoist-core does.
85
86
  */
86
87
  environment: PlainObject;
88
+ /** JsonBlobs, including ViewManager views and each user's view state. Starts empty. */
89
+ readonly jsonBlobs: FakeJsonBlobStore;
87
90
  /** Every request the fake has served in this test - the kit's setup clears it before each. */
88
91
  requests: RecordedRequest[];
89
- /** @internal - called with a message when a route throws. The kit's setup fails the test. */
92
+ /**
93
+ * @internal - called with a message for each problem the kit's guards catch, such as a route
94
+ * that throws. The kit's setup fails the running test, or `initTestAppAsync()` the boot.
95
+ */
90
96
  onProblem: (msg: string) => void;
91
97
  private routes;
92
98
  private testRouteCount;
@@ -3,4 +3,5 @@
3
3
  * See docs/unit-testing.md.
4
4
  */
5
5
  export * from './hoistCore';
6
+ export { type FakeJsonBlob, FakeJsonBlobStore, type JsonBlobSpec, type ViewSpec } from './jsonBlobs';
6
7
  export * from './testApp';
@@ -0,0 +1,130 @@
1
+ import type { ViewUserState } from '@xh/hoist/cmp/viewmanager';
2
+ import type { PlainObject } from '@xh/hoist/core';
3
+ import type { JsonBlob } from '@xh/hoist/svc';
4
+ import type { FakeHoistCore, HoistError } from './hoistCore';
5
+ /** A JsonBlob as the fake stores it. `meta` is always an object, or null. */
6
+ export interface FakeJsonBlob extends JsonBlob {
7
+ meta: PlainObject;
8
+ }
9
+ /** A JsonBlob to add to the fake, with the fields `JsonBlobService.create` stores. */
10
+ export interface JsonBlobSpec {
11
+ type: string;
12
+ name: string;
13
+ /** Defaults to an empty object. */
14
+ value?: any;
15
+ /** Defaults to the current user. Pass `null` for a global blob. */
16
+ owner?: string;
17
+ /** `'*'` to let every user read the blob. */
18
+ acl?: '*';
19
+ meta?: PlainObject;
20
+ description?: string;
21
+ /** Defaults to a generated token. */
22
+ token?: string;
23
+ }
24
+ /** A ViewManager view to add to the fake, as `ViewService.create` stores it. */
25
+ export interface ViewSpec {
26
+ /** The `type` of the `ViewManagerModel` that loads the view. */
27
+ type: string;
28
+ name: string;
29
+ /** Defaults to an empty object. */
30
+ value?: PlainObject;
31
+ group?: string;
32
+ description?: string;
33
+ /** True to let every user read the view. */
34
+ isShared?: boolean;
35
+ /** True for a global view, which has no owner. */
36
+ isGlobal?: boolean;
37
+ /** Defaults to the current user. Ignored for a global view. */
38
+ owner?: string;
39
+ /** Defaults to a generated token. */
40
+ token?: string;
41
+ }
42
+ /**
43
+ * The JsonBlobs on the fake hoist-core, including ViewManager views and view state. Use the
44
+ * `hoistCore.jsonBlobs` instance. The store starts empty, so a `ViewManagerModel` loads no views
45
+ * and selects its in-code default.
46
+ */
47
+ export declare class FakeJsonBlobStore {
48
+ private readonly core;
49
+ /**
50
+ * Roles that may write global blobs, by blob type, with `*` for any type not listed - as in
51
+ * hoist-core's `xhJsonBlobConfig`. A view manager reports `manageGlobal` from these and
52
+ * `hoistCore.roles`. List the role `*` to allow every user.
53
+ */
54
+ globalWriteRoles: Record<string, string[]>;
55
+ private blobs;
56
+ private nextId;
57
+ constructor(core: FakeHoistCore);
58
+ /** Add a blob, as `JsonBlobService.create` stores it. Returns the stored blob. */
59
+ add(spec: JsonBlobSpec): FakeJsonBlob;
60
+ /** Add a ViewManager view, as `ViewService.create` stores it. Returns the stored blob. */
61
+ addView(spec: ViewSpec): FakeJsonBlob;
62
+ /**
63
+ * Set the current user's state for one view type, as `ViewService.updateState` saves it.
64
+ * Changes only the keys given.
65
+ *
66
+ * @param opts - `viewInstance`, the `instance` of the view manager whose current view is
67
+ * set. Defaults to 'default'.
68
+ */
69
+ setViewState(type: string, state: Partial<ViewUserState>, opts?: {
70
+ viewInstance?: string;
71
+ }): void;
72
+ /** The current user's state for one view type, as the server sends it to a view manager. */
73
+ viewState(type: string, viewInstance?: string): ViewUserState;
74
+ /**
75
+ * The stored blob with a token, archived or not. Change it to model an edit made elsewhere,
76
+ * e.g. advance `lastUpdated` to model a save by another session.
77
+ */
78
+ get(token: string): FakeJsonBlob;
79
+ /** Remove every blob. */
80
+ clear(): void;
81
+ /** @internal - empty the store and restore the default `globalWriteRoles`. */
82
+ reset(): void;
83
+ /**
84
+ * @internal - remove the current user's view state for every type, as hoist-core's
85
+ * `xh/clearUserState` does through `ViewService.clearAllState`.
86
+ */
87
+ clearViewState(): void;
88
+ /** @internal - the endpoints served by `serve()`, relative to `XH.baseUrl`. */
89
+ get paths(): string[];
90
+ /**
91
+ * @internal - answer a request to one of `paths`. Returns the response body, or undefined for
92
+ * an empty 204. Throws a `FakeServerError` for an error response.
93
+ *
94
+ * @param params - the query string and form body merged, as Grails `params` read them.
95
+ * @param json - the parsed JSON body, if any.
96
+ */
97
+ serve(path: string, params: PlainObject, json: any): unknown;
98
+ private endpoints;
99
+ private getAllData;
100
+ private updateState;
101
+ private createView;
102
+ private updateViewInfo;
103
+ private bulkUpdateViewInfo;
104
+ private deleteViews;
105
+ private applyViewInfo;
106
+ private updatePinned;
107
+ private insertView;
108
+ private insertState;
109
+ private getBlob;
110
+ private findBlob;
111
+ private listBlobs;
112
+ private createBlob;
113
+ private updateBlob;
114
+ private createOrUpdateBlob;
115
+ private archiveBlob;
116
+ private renameGroup;
117
+ private canRead;
118
+ private ensureReadable;
119
+ private canWriteGlobal;
120
+ private insert;
121
+ private newToken;
122
+ }
123
+ /**
124
+ * @internal - an error that the fake renders as hoist-core would, with `hoistError()`.
125
+ */
126
+ export declare class FakeServerError extends Error {
127
+ readonly status: number;
128
+ readonly error: HoistError;
129
+ constructor(status: number, error: HoistError);
130
+ }
@@ -11,8 +11,11 @@ export type TestAppSpec = Partial<ConstructorParameters<typeof AppSpec>[0]>;
11
11
  * graph, and with it a fresh `XH`. Adjust `hoistCore` state first to boot against other server
12
12
  * data (e.g. `hoistCore.configs.myConfig = 42`).
13
13
  *
14
- * Resolves once the app is `RUNNING`. Rejects, naming `XH.appState`, if boot stops anywhere else -
15
- * `ACCESS_DENIED`, `LOAD_FAILED`, or `LOGIN_REQUIRED`, where boot waits for the user to sign in.
14
+ * Resolves once the app is `RUNNING` and the requests boot started have finished. Rejects, naming
15
+ * `XH.appState`, if boot stops anywhere else - `ACCESS_DENIED`, `LOAD_FAILED`, or
16
+ * `LOGIN_REQUIRED`, where boot waits for the user to sign in. Also rejects if boot triggers a
17
+ * problem that the kit's guards catch, such as a request the fake does not handle. Logs any error
18
+ * that the app handles during boot.
16
19
  *
17
20
  * @param spec - overrides for the test app's `AppSpec`. Defaults to a desktop app with a minimal
18
21
  * app model, open to any user. Pass `checkAccess` to require a role.
package/cmp/grid/Grid.ts CHANGED
@@ -242,7 +242,7 @@ export class GridLocalModel extends HoistModel {
242
242
  this.agOptions = merge(this.createDefaultAgOptions(), this.componentProps.agOptions || {});
243
243
  warnIf(
244
244
  this.componentProps.agOptions?.groupDefaultExpanded != null,
245
- 'agOptions.groupDefaultExpanded is not supported. Use GridModel.expandLevel instead.'
245
+ 'agOptions.groupDefaultExpanded is ignored. Set GridModel.expandLevel instead.'
246
246
  );
247
247
  this.rowHeightSupport = new RowHeightSupport(this);
248
248
  this.transactionMgr = new GridTransactionManager(this.model);
@@ -115,7 +115,8 @@ import {
115
115
  omit,
116
116
  pick,
117
117
  pull,
118
- take
118
+ take,
119
+ uniqBy
119
120
  } from 'lodash';
120
121
  import {createRef, ReactNode, RefObject} from 'react';
121
122
  import {GridAutosizeOptions} from './GridAutosizeOptions';
@@ -2024,8 +2025,12 @@ export class GridModel extends HoistModel {
2024
2025
  const gridCols = this.getLeafColumns();
2025
2026
 
2026
2027
  // REMOVE any state columns that are no longer found in the grid. These were likely saved
2027
- // under a prior release of the app and have since been removed from the code.
2028
- let ret = columnState.filter(({colId}) => this.getColumn(colId));
2028
+ // under a prior release of the app and have since been removed from the code. Also
2029
+ // REMOVE any repeated columns, keeping the first.
2030
+ let ret = uniqBy<any>(
2031
+ columnState.filter(({colId}) => this.getColumn(colId)),
2032
+ 'colId'
2033
+ );
2029
2034
 
2030
2035
  // ADD any grid columns that are not found in state. These are newly added to the code.
2031
2036
  // Insert these columns in position based on the index at which they are defined.
@@ -473,7 +473,7 @@ export interface ColumnSpec {
473
473
  * @mcpHint column configuration for grids
474
474
  */
475
475
  export class Column {
476
- static DEFAULT_WIDTH = 60;
476
+ static DEFAULT_WIDTH = 100;
477
477
  static FLEX_COL_MIN_WIDTH = 30;
478
478
 
479
479
  /**
@@ -0,0 +1,59 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2026 Extremely Heavy Industries Inc.
6
+ */
7
+
8
+ /**
9
+ * Helpers for NumberInput's `displayWithCommas: 'always'` mode, which groups digits while the user
10
+ * types. Commas are the only characters a reformat adds or removes, so the caret is tracked as a
11
+ * count of the non-comma characters before it.
12
+ * @internal
13
+ */
14
+
15
+ /**
16
+ * Group the leading integer digits of a partially typed number with commas. Everything after them
17
+ * (decimals, exponent, shorthand unit) is kept as typed.
18
+ */
19
+ export function addCommasWhileEditing(value: string): string {
20
+ return value
21
+ .replace(/,/g, '')
22
+ .replace(
23
+ /^(\s*[-+]?)(\d+)/,
24
+ (_, sign, digits) => sign + digits.replace(/\B(?=(\d{3})+$)/g, ',')
25
+ );
26
+ }
27
+
28
+ /** Count of non-comma characters before the caret, or null if the input has no caret. */
29
+ export function getCaretSkippingCommas(input: HTMLInputElement): number {
30
+ const {selectionStart, value} = input;
31
+ return selectionStart == null ? null : value.slice(0, selectionStart).replace(/,/g, '').length;
32
+ }
33
+
34
+ /** Place the caret after the given count of non-comma characters. */
35
+ export function setCaretSkippingCommas(input: HTMLInputElement, count: number) {
36
+ const {value} = input;
37
+ let idx = 0;
38
+ for (; idx < value.length && count > 0; idx++) {
39
+ if (value[idx] !== ',') count--;
40
+ }
41
+ input.setSelectionRange(idx, idx);
42
+ }
43
+
44
+ /**
45
+ * `beforeinput` listener that steps the caret over an adjacent comma before Backspace or Delete, so
46
+ * the key removes the digit beyond it. Otherwise the reformat would restore the deleted comma.
47
+ * Listens for the native event, which (unlike `keydown`) reports deletes from mobile soft keyboards.
48
+ */
49
+ export function skipCommaOnDelete(ev: InputEvent) {
50
+ const input = ev.target as HTMLInputElement,
51
+ {selectionStart: start, selectionEnd: end, value} = input;
52
+ if (start == null || start !== end) return;
53
+
54
+ if (ev.inputType === 'deleteContentBackward' && value[start - 1] === ',') {
55
+ input.setSelectionRange(start - 1, start - 1);
56
+ } else if (ev.inputType === 'deleteContentForward' && value[start] === ',') {
57
+ input.setSelectionRange(start + 1, start + 1);
58
+ }
59
+ }