@molecule/app-query-react 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-16T21:21:11.635Z
6
+ Generated: 2026-11-17T05:18:54.490Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-query-react
@@ -496,7 +496,8 @@ interface QueryContentProps<T> {
496
496
  /**
497
497
  * One optional empty branch, exclusive with children. The pure predicate reads the
498
498
  * loaded document (an array or an application-owned envelope); render selects the
499
- * current view's message and recovery action. Omit it to keep empty arrays as data.
499
+ * current view's message and recovery action. A previous key's empty document uses
500
+ * pending/error instead. Omit it to keep empty arrays as data.
500
501
  */
501
502
  empty?: {
502
503
  when: (data: NonNullable<T>) => boolean
@@ -504,7 +505,7 @@ interface QueryContentProps<T> {
504
505
  }
505
506
 
506
507
  /** State from useQuery, or any compatible query observer. */
507
- query: Pick<QueryState<T>, 'data' | 'status' | 'error'>
508
+ query: Pick<QueryState<T>, 'data' | 'status' | 'error' | 'isPreviousData'>
508
509
  /** Mounted only with a real document, including false, zero and an empty list. */
509
510
  children: (data: NonNullable<T>) => ReactNode
510
511
  /** Initial idle/loading content. Render a status node, never a fake item or action. */
@@ -584,6 +585,7 @@ missing records never mount that branch, so its actions cannot swallow an early
584
585
  Cached data remains mounted during refresh, including a failed refresh. Status fallbacks
585
586
  belong outside the list or record container rendered by `children`, and so does a refresh
586
587
  line; the default fallbacks render nothing.
588
+ A previous key's empty or missing document renders pending/error until the current key answers.
587
589
 
588
590
  ```typescript
589
591
  function QueryContent<T>({
@@ -10,6 +10,7 @@ import type { QueryContentProps } from './types.js';
10
10
  * Cached data remains mounted during refresh, including a failed refresh. Status fallbacks
11
11
  * belong outside the list or record container rendered by `children`, and so does a refresh
12
12
  * line; the default fallbacks render nothing.
13
+ * A previous key's empty or missing document renders pending/error until the current key answers.
13
14
  *
14
15
  * @param props - Query state, loaded content and optional status fallbacks.
15
16
  * @returns Loaded content or the appropriate fallback.
@@ -1 +1 @@
1
- {"version":3,"file":"query-content.d.ts","sourceRoot":"","sources":["../src/query-content.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,KAAK,EACL,QAAQ,EACR,OAAc,EACd,OAAc,EACd,KAAK,EACL,KAAK,GACN,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,SAAS,CAOlC"}
1
+ {"version":3,"file":"query-content.d.ts","sourceRoot":"","sources":["../src/query-content.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,KAAK,EACL,QAAQ,EACR,OAAc,EACd,OAAc,EACd,KAAK,EACL,KAAK,GACN,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,SAAS,CAQlC"}
@@ -4,17 +4,19 @@
4
4
  * Cached data remains mounted during refresh, including a failed refresh. Status fallbacks
5
5
  * belong outside the list or record container rendered by `children`, and so does a refresh
6
6
  * line; the default fallbacks render nothing.
7
+ * A previous key's empty or missing document renders pending/error until the current key answers.
7
8
  *
8
9
  * @param props - Query state, loaded content and optional status fallbacks.
9
10
  * @returns Loaded content or the appropriate fallback.
10
11
  */
11
12
  export function QueryContent({ query, children, pending = null, missing = null, error, empty, }) {
12
- if (query.data === undefined) {
13
+ const data = query.data;
14
+ if (data === undefined || (query.isPreviousData && (data === null || empty?.when(data)))) {
13
15
  return query.status === 'error' && error ? error(query.error) : pending;
14
16
  }
15
- if (query.data === null)
17
+ if (data === null)
16
18
  return missing;
17
- if (empty?.when(query.data))
18
- return empty.render(query.data);
19
- return children(query.data);
19
+ if (empty?.when(data))
20
+ return empty.render(data);
21
+ return children(data);
20
22
  }
package/dist/types.d.ts CHANGED
@@ -28,14 +28,15 @@ export interface QueryContentProps<T> {
28
28
  /**
29
29
  * One optional empty branch, exclusive with children. The pure predicate reads the
30
30
  * loaded document (an array or an application-owned envelope); render selects the
31
- * current view's message and recovery action. Omit it to keep empty arrays as data.
31
+ * current view's message and recovery action. A previous key's empty document uses
32
+ * pending/error instead. Omit it to keep empty arrays as data.
32
33
  */
33
34
  empty?: {
34
35
  when: (data: NonNullable<T>) => boolean;
35
36
  render: NonNullable<QueryContentProps<T>['children']>;
36
37
  };
37
38
  /** State from useQuery, or any compatible query observer. */
38
- query: Pick<QueryState<T>, 'data' | 'status' | 'error'>;
39
+ query: Pick<QueryState<T>, 'data' | 'status' | 'error' | 'isPreviousData'>;
39
40
  /** Mounted only with a real document, including false, zero and an empty list. */
40
41
  children: (data: NonNullable<T>) => ReactNode;
41
42
  /** Initial idle/loading content. Render a status node, never a fake item or action. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,0EAA0E;AAC1E,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IACtD;;;;;;;;OAQG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,C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EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,IAAI,CAAA;IAC1E;;;;OAIG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;CACtC;AAED,wFAAwF;AACxF,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,CAAA;QACvC,MAAM,EAAE,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;KACtD,CAAA;IAED,6DAA6D;IAC7D,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,gBAAgB,CAAC,CAAA;IAC1E,kFAAkF;IAClF,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,CAAA;IAC7C,uFAAuF;IACvF,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,qFAAqF;IACrF,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CAAA;CACtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-query-react",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "React hooks for @molecule/app-query — read a cached document synchronously, observe it, and prefetch on intent",
5
5
  "homepage": "https://www.molecule.dev/packages/app-query-react",
6
6
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  "react": "^18.0.0 || ^19.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@molecule/app-query": "1.3.1",
43
+ "@molecule/app-query": "1.3.2",
44
44
  "@molecule/app-query-memory": "1.1.0",
45
45
  "@molecule/app-query-tanstack": "1.1.0",
46
46
  "@types/node": "26.6.5",