@xh/hoist 89.0.1 → 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 (59) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/build/types/cmp/input/impl/LiveCommas.d.ts +21 -0
  3. package/build/types/core/model/HoistModel.d.ts +1 -0
  4. package/build/types/core/model/ManagedRefreshContextModel.d.ts +1 -0
  5. package/build/types/data/cube/View.d.ts +0 -2
  6. package/build/types/data/cube/impl/RowCache.d.ts +1 -1
  7. package/build/types/data/cube/row/BaseRow.d.ts +5 -0
  8. package/build/types/desktop/cmp/grid/editors/impl/InlineEditorModel.d.ts +6 -1
  9. package/build/types/desktop/cmp/input/NumberInput.d.ts +5 -2
  10. package/build/types/mobile/cmp/input/NumberInput.d.ts +5 -2
  11. package/build/types/test-support/agGrid.d.ts +2 -0
  12. package/build/types/test-support/hoistCore.d.ts +7 -1
  13. package/build/types/test-support/index.d.ts +1 -0
  14. package/build/types/test-support/jsonBlobs.d.ts +130 -0
  15. package/build/types/test-support/testApp.d.ts +5 -2
  16. package/cmp/grid/columns/Column.ts +1 -1
  17. package/cmp/input/impl/LiveCommas.ts +59 -0
  18. package/core/model/HoistModel.ts +4 -2
  19. package/core/model/Hooks.ts +1 -0
  20. package/core/model/ManagedRefreshContextModel.ts +5 -1
  21. package/data/cube/View.ts +3 -9
  22. package/data/cube/impl/RowCache.ts +2 -2
  23. package/data/cube/row/BaseRow.ts +14 -1
  24. package/data/cube/row/ParentRow.ts +1 -1
  25. package/desktop/cmp/grid/editors/BooleanEditor.ts +2 -1
  26. package/desktop/cmp/grid/editors/DateEditor.ts +4 -1
  27. package/desktop/cmp/grid/editors/SelectEditor.ts +4 -1
  28. package/desktop/cmp/grid/editors/impl/InlineEditorModel.ts +17 -5
  29. package/desktop/cmp/input/NumberInput.ts +51 -12
  30. package/desktop/cmp/input/Select.ts +25 -7
  31. package/docs/README.md +2 -0
  32. package/docs/companion-library-docs.md +205 -0
  33. package/docs/doc-registry.json +8 -0
  34. package/docs/lifecycle-app.md +17 -0
  35. package/docs/unit-testing.md +54 -3
  36. package/docs/upgrade-notes/v89-upgrade-notes.md +7 -1
  37. package/docs/version-compatibility.md +2 -1
  38. package/icon/README.md +4 -1
  39. package/mcp/README.md +79 -4
  40. package/mcp/cli/docs.ts +75 -30
  41. package/mcp/data/doc-id-resolver.ts +50 -9
  42. package/mcp/data/doc-registry.ts +462 -44
  43. package/mcp/data/doc-search.ts +25 -6
  44. package/mcp/formatters/docs.ts +136 -36
  45. package/mcp/instructions.ts +69 -0
  46. package/mcp/resources/docs.ts +10 -8
  47. package/mcp/server.ts +7 -13
  48. package/mcp/tools/docs.ts +64 -18
  49. package/mcp/util/paths.ts +85 -2
  50. package/mobile/cmp/input/NumberInput.ts +42 -4
  51. package/package.json +19 -19
  52. package/public/msal-redirect-bridge.min.js +1 -1
  53. package/svc/JsonBlobService.ts +7 -4
  54. package/test-support/agGrid.ts +12 -2
  55. package/test-support/hoistCore.ts +32 -5
  56. package/test-support/index.ts +1 -0
  57. package/test-support/jsonBlobs.ts +543 -0
  58. package/test-support/setup.ts +8 -6
  59. package/test-support/testApp.ts +36 -7
package/CHANGELOG.md CHANGED
@@ -11,6 +11,42 @@
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).
14
50
 
15
51
  ## 89.0.1 - 2026-10-14
16
52
 
@@ -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;
@@ -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.
@@ -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
+ }
@@ -136,9 +136,11 @@ export abstract class HoistModel extends HoistBase implements Loadable {
136
136
 
137
137
  // Internal State
138
138
  // - `_componentProps` is only set for linked models and mirrors the current React props.
139
- // - `_modelLookup` is injected by Hoist when this model is linked into a component hierarchy.
139
+ // - `_linked` is set by Hoist when this model is linked into a component hierarchy.
140
+ // - `_modelLookup` is injected on link, and is null for a model linked at the root.
140
141
  // - `_created` is basic lifecycle metadata (useful for diagnostics/ordering).
141
142
  @observableRef accessor _componentProps: DefaultHoistProps | null = null;
143
+ _linked: boolean = false;
142
144
  _modelLookup: any = null;
143
145
  _created: number = Date.now();
144
146
 
@@ -201,7 +203,7 @@ export abstract class HoistModel extends HoistBase implements Loadable {
201
203
  // Linked model support
202
204
  //---------------------------
203
205
  get isLinked(): boolean {
204
- return !!this._modelLookup;
206
+ return this._linked;
205
207
  }
206
208
 
207
209
  /**
@@ -67,6 +67,7 @@ export function useModelLinker(model: HoistModel, modelLookup: ModelLookup, prop
67
67
 
68
68
  // 1) Linking synchronous work: resolve lookups, initialize props, and call onLinked()
69
69
  if (isLinking) {
70
+ model._linked = true;
70
71
  model._modelLookup = modelLookup;
71
72
  each(model['_xhInjectedParentProperties'], (selector, name) => {
72
73
  const parentModel = modelLookup?.lookupModel(selector);
@@ -22,6 +22,7 @@ export class ManagedRefreshContextModel extends RefreshContextModel {
22
22
 
23
23
  model: ManagedRefreshTarget;
24
24
  refreshPending: boolean = false;
25
+ private pendingIsAutoRefresh: boolean = false;
25
26
 
26
27
  constructor(model: ManagedRefreshTarget) {
27
28
  super();
@@ -42,6 +43,9 @@ export class ManagedRefreshContextModel extends RefreshContextModel {
42
43
  }
43
44
 
44
45
  if (mode === 'onShowLazy') {
46
+ // Replay as an auto-refresh only if every missed refresh was one.
47
+ this.pendingIsAutoRefresh =
48
+ loadSpec.isAutoRefresh && (!this.refreshPending || this.pendingIsAutoRefresh);
45
49
  this.refreshPending = true;
46
50
  }
47
51
  }
@@ -53,7 +57,7 @@ export class ManagedRefreshContextModel extends RefreshContextModel {
53
57
  this.refreshAsync();
54
58
  } else if (mode === 'onShowLazy' && this.refreshPending) {
55
59
  this.refreshPending = false;
56
- this.refreshAsync();
60
+ this.pendingIsAutoRefresh ? this.autoRefreshAsync() : this.refreshAsync();
57
61
  }
58
62
  }
59
63
  }
package/data/cube/View.ts CHANGED
@@ -149,8 +149,6 @@ export class View
149
149
 
150
150
  private _fieldsByName: Map<string, CubeField> = null;
151
151
  private _rowDataGenerator: RowDataGenerator = null;
152
- // Monotonic source for cubeRowDigest stamps - safe-integer headroom spans centuries of use.
153
- _rowDigest = 0;
154
152
  // Fields eligible for aggregation at each level of the query - i.e. those with an aggregator
155
153
  // that are not themselves an applied dimension there - and useful subsets of same. Indexed by
156
154
  // row depth, with entry 0 (no dimensions applied) holding the superset for the whole query.
@@ -335,7 +333,7 @@ export class View
335
333
  */
336
334
  newParentRowData(id: string): ViewRowData {
337
335
  const ret = this._rowDataGenerator.newParentRowData(id);
338
- this.assignDigest(ret);
336
+ BaseRow.assignDigest(ret);
339
337
  return ret;
340
338
  }
341
339
 
@@ -345,14 +343,10 @@ export class View
345
343
  */
346
344
  newLeafRowData(id: string, src: PlainObject): ViewRowData {
347
345
  const ret = this._rowDataGenerator.newLeafRowData(id, src);
348
- this.assignDigest(ret);
346
+ BaseRow.assignDigest(ret);
349
347
  return ret;
350
348
  }
351
349
 
352
- assignDigest(data: ViewRowData) {
353
- data.cubeRowDigest = ++this._rowDigest;
354
- }
355
-
356
350
  private buildIndices() {
357
351
  this._fieldsByName = new Map(this.fields.map(it => [it.name, it]));
358
352
 
@@ -419,7 +413,7 @@ export class View
419
413
  _leafMap.get(rec.id)?.applyLeafDataUpdate(rec, checkFields, changed);
420
414
  });
421
415
 
422
- changed.rows.forEach(rowData => this.assignDigest(rowData));
416
+ changed.rows.forEach(rowData => BaseRow.assignDigest(rowData));
423
417
 
424
418
  this.createAggregationContext();
425
419
 
@@ -8,7 +8,7 @@
8
8
  import type {StoreRecord} from '@xh/hoist/data';
9
9
  import {isEqual, map} from 'lodash';
10
10
  import type {Query} from '../Query';
11
- import type {BaseRow} from '../row/BaseRow';
11
+ import {BaseRow} from '../row/BaseRow';
12
12
  import {ExposedLeafRow, type LeafRow} from '../row/LeafRow';
13
13
  import type {ParentRow} from '../row/ParentRow';
14
14
  import type {View} from '../View';
@@ -93,7 +93,7 @@ export class RowCache {
93
93
  beginGeneration() {
94
94
  const {view} = this;
95
95
  this.pruneForQueryChange(view.query);
96
- this.genStartDigest = view._rowDigest;
96
+ this.genStartDigest = BaseRow.currentDigest;
97
97
  this.exposedLeaves = view.exposesLeaves;
98
98
  this.reused = this.rebuilt = this.created = 0;
99
99
  }
@@ -19,6 +19,19 @@ import type {ParentRow} from './ParentRow';
19
19
  * @internal
20
20
  */
21
21
  export abstract class BaseRow implements ViewRow {
22
+ // Shared by all Views, so stamps never repeat across Views on the same Store.
23
+ private static lastDigest = 0;
24
+
25
+ /** The latest cubeRowDigest stamp given out by any View. */
26
+ static get currentDigest(): number {
27
+ return BaseRow.lastDigest;
28
+ }
29
+
30
+ /** Stamp row data with a new cubeRowDigest, marking it changed. */
31
+ static assignDigest(data: ViewRowData) {
32
+ data.cubeRowDigest = ++BaseRow.lastDigest;
33
+ }
34
+
22
35
  readonly view: View = null;
23
36
  readonly id: string = null;
24
37
 
@@ -53,7 +66,7 @@ export abstract class BaseRow implements ViewRow {
53
66
 
54
67
  if (!shallowEqualObjects(data.cubeBuckets, buckets)) {
55
68
  data.cubeBuckets = buckets;
56
- this.view.assignDigest(data as ViewRowData);
69
+ BaseRow.assignDigest(data as ViewRowData);
57
70
  }
58
71
 
59
72
  this.children?.forEach(it => it.syncBuckets(buckets));
@@ -136,7 +136,7 @@ export abstract class ParentRow extends BaseRow {
136
136
  changed = this.recomputeAggregatesForContextChange(this.recomputeCanAggregate());
137
137
  }
138
138
 
139
- if (changed) view.assignDigest(this.data);
139
+ if (changed) BaseRow.assignDigest(this.data);
140
140
  return this;
141
141
  }
142
142
 
@@ -46,7 +46,8 @@ export const [BooleanEditor, booleanEditor] = hoistCmp.withFactory<BooleanEditor
46
46
 
47
47
  return quickToggle
48
48
  ? useInstantEditor(props.agParams, ref)
49
- : useInlineEditorModel(checkbox, props, ref);
49
+ : // A checkbox's value is a boolean, so ignore the key that started the edit.
50
+ useInlineEditorModel(checkbox, props, ref, () => {});
50
51
  }
51
52
  });
52
53
 
@@ -46,6 +46,9 @@ export const [DateEditor, dateEditor] = hoistCmp.withFactory<DateEditorProps>({
46
46
  ...inputProps
47
47
  }
48
48
  };
49
- return useInlineEditorModel(dateInput, props, ref);
49
+ // A date input's value holds a date, so enter the key that started the edit as its text.
50
+ return useInlineEditorModel(dateInput, props, ref, (input, key) =>
51
+ (input as any).textInputRef.current?.noteValueChange(key)
52
+ );
50
53
  }
51
54
  });
@@ -49,6 +49,9 @@ export const [SelectEditor, selectEditor] = hoistCmp.withFactory<SelectEditorPro
49
49
  }
50
50
  };
51
51
 
52
- return useInlineEditorModel(select, props, ref);
52
+ // A select's value holds an option, so enter the key that started the edit as search text.
53
+ return useInlineEditorModel(select, props, ref, (input, key) =>
54
+ (input as any).enterSearchText(key)
55
+ );
53
56
  }
54
57
  });