@molecule/app-query-react 1.6.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/query-content.d.ts +1 -1
- package/dist/query-content.d.ts.map +1 -1
- package/dist/query-content.js +3 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
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-
|
|
6
|
+
Generated: 2026-11-16T21:21:11.635Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-query-react
|
|
@@ -419,6 +419,8 @@ interface QueryResource<T, Create = Partial<T>, Update = Partial<T>> {
|
|
|
419
419
|
/**
|
|
420
420
|
* `useQuery` options for the collection. `viewer` is who the answer is for (the signed-in id,
|
|
421
421
|
* or `'anonymous'`); a page or filter change keeps the rows on screen until the next answer.
|
|
422
|
+
* One record per URL identity, retaining the first occurrence. Equal values without an
|
|
423
|
+
* addressable id remain separate. Writes already refresh the collection.
|
|
422
424
|
*/
|
|
423
425
|
list(viewer: string, params?: Record<string, unknown>): QueryOptions<T[]>
|
|
424
426
|
/**
|
|
@@ -491,6 +493,16 @@ A loaded document owns its controls; absent documents expose only status content
|
|
|
491
493
|
|
|
492
494
|
```typescript
|
|
493
495
|
interface QueryContentProps<T> {
|
|
496
|
+
/**
|
|
497
|
+
* One optional empty branch, exclusive with children. The pure predicate reads the
|
|
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.
|
|
500
|
+
*/
|
|
501
|
+
empty?: {
|
|
502
|
+
when: (data: NonNullable<T>) => boolean
|
|
503
|
+
render: NonNullable<QueryContentProps<T>['children']>
|
|
504
|
+
}
|
|
505
|
+
|
|
494
506
|
/** State from useQuery, or any compatible query observer. */
|
|
495
507
|
query: Pick<QueryState<T>, 'data' | 'status' | 'error'>
|
|
496
508
|
/** Mounted only with a real document, including false, zero and an empty list. */
|
|
@@ -580,6 +592,7 @@ function QueryContent<T>({
|
|
|
580
592
|
pending = null,
|
|
581
593
|
missing = null,
|
|
582
594
|
error,
|
|
595
|
+
empty,
|
|
583
596
|
}: QueryContentProps<T>): ReactNode
|
|
584
597
|
```
|
|
585
598
|
|
|
@@ -763,3 +776,10 @@ a reader that finds the container and reads its paragraph must read the record,
|
|
|
763
776
|
Keep every resource identity in the query key. A boundary cannot correct a query that supplies
|
|
764
777
|
another record's cached data. For a list, map real rows inside the child; never style a status
|
|
765
778
|
placeholder as a row. QueryContent is headless and owns no translations or styling.
|
|
779
|
+
|
|
780
|
+
For a collection, `QueryContent` also accepts one `empty` branch:
|
|
781
|
+
`{ when: page => page.rows.length === 0, render: page => selectedEmptyState }`.
|
|
782
|
+
It is exclusive with loaded children, so a selected view chooses its message and
|
|
783
|
+
recovery action once rather than rendering a general empty message beside it.
|
|
784
|
+
`when` receives a loaded document; empty arrays remain data when this prop is omitted.
|
|
785
|
+
The render value uses this framework's existing children function, snippet or template.
|
package/dist/index.d.ts
CHANGED
|
@@ -384,6 +384,13 @@
|
|
|
384
384
|
* another record's cached data. For a list, map real rows inside the child; never style a status
|
|
385
385
|
* placeholder as a row. QueryContent is headless and owns no translations or styling.
|
|
386
386
|
*
|
|
387
|
+
* For a collection, `QueryContent` also accepts one `empty` branch:
|
|
388
|
+
* `{ when: page => page.rows.length === 0, render: page => selectedEmptyState }`.
|
|
389
|
+
* It is exclusive with loaded children, so a selected view chooses its message and
|
|
390
|
+
* recovery action once rather than rendering a general empty message beside it.
|
|
391
|
+
* `when` receives a loaded document; empty arrays remain data when this prop is omitted.
|
|
392
|
+
* The render value uses this framework's existing children function, snippet or template.
|
|
393
|
+
*
|
|
387
394
|
* @module
|
|
388
395
|
*/
|
|
389
396
|
export * from './query-content.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0YG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -384,6 +384,13 @@
|
|
|
384
384
|
* another record's cached data. For a list, map real rows inside the child; never style a status
|
|
385
385
|
* placeholder as a row. QueryContent is headless and owns no translations or styling.
|
|
386
386
|
*
|
|
387
|
+
* For a collection, `QueryContent` also accepts one `empty` branch:
|
|
388
|
+
* `{ when: page => page.rows.length === 0, render: page => selectedEmptyState }`.
|
|
389
|
+
* It is exclusive with loaded children, so a selected view chooses its message and
|
|
390
|
+
* recovery action once rather than rendering a general empty message beside it.
|
|
391
|
+
* `when` receives a loaded document; empty arrays remain data when this prop is omitted.
|
|
392
|
+
* The render value uses this framework's existing children function, snippet or template.
|
|
393
|
+
*
|
|
387
394
|
* @module
|
|
388
395
|
*/
|
|
389
396
|
export * from './query-content.js';
|
package/dist/query-content.d.ts
CHANGED
|
@@ -14,5 +14,5 @@ import type { QueryContentProps } from './types.js';
|
|
|
14
14
|
* @param props - Query state, loaded content and optional status fallbacks.
|
|
15
15
|
* @returns Loaded content or the appropriate fallback.
|
|
16
16
|
*/
|
|
17
|
-
export declare function QueryContent<T>({ query, children, pending, missing, error, }: QueryContentProps<T>): ReactNode;
|
|
17
|
+
export declare function QueryContent<T>({ query, children, pending, missing, error, empty, }: QueryContentProps<T>): ReactNode;
|
|
18
18
|
//# sourceMappingURL=query-content.d.ts.map
|
|
@@ -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,GACN,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,SAAS,
|
|
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"}
|
package/dist/query-content.js
CHANGED
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
* @param props - Query state, loaded content and optional status fallbacks.
|
|
9
9
|
* @returns Loaded content or the appropriate fallback.
|
|
10
10
|
*/
|
|
11
|
-
export function QueryContent({ query, children, pending = null, missing = null, error, }) {
|
|
11
|
+
export function QueryContent({ query, children, pending = null, missing = null, error, empty, }) {
|
|
12
12
|
if (query.data === undefined) {
|
|
13
13
|
return query.status === 'error' && error ? error(query.error) : pending;
|
|
14
14
|
}
|
|
15
15
|
if (query.data === null)
|
|
16
16
|
return missing;
|
|
17
|
+
if (empty?.when(query.data))
|
|
18
|
+
return empty.render(query.data);
|
|
17
19
|
return children(query.data);
|
|
18
20
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -25,6 +25,15 @@ export interface UseQueryResult<T> extends QueryState<T> {
|
|
|
25
25
|
}
|
|
26
26
|
/** A loaded document owns its controls; absent documents expose only status content. */
|
|
27
27
|
export interface QueryContentProps<T> {
|
|
28
|
+
/**
|
|
29
|
+
* One optional empty branch, exclusive with children. The pure predicate reads the
|
|
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.
|
|
32
|
+
*/
|
|
33
|
+
empty?: {
|
|
34
|
+
when: (data: NonNullable<T>) => boolean;
|
|
35
|
+
render: NonNullable<QueryContentProps<T>['children']>;
|
|
36
|
+
};
|
|
28
37
|
/** State from useQuery, or any compatible query observer. */
|
|
29
38
|
query: Pick<QueryState<T>, 'data' | 'status' | 'error'>;
|
|
30
39
|
/** Mounted only with a real document, including false, zero and an empty list. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceR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,CAAC,CAAC;IACtD;;;;;;;;OAQG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,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;;;;OAIG;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,CAAC,CAAA;IACvD,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.
|
|
3
|
+
"version": "1.7.0",
|
|
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,9 +40,9 @@
|
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@molecule/app-query": "1.
|
|
44
|
-
"@molecule/app-query-memory": "1.0
|
|
45
|
-
"@molecule/app-query-tanstack": "1.0
|
|
43
|
+
"@molecule/app-query": "1.3.1",
|
|
44
|
+
"@molecule/app-query-memory": "1.1.0",
|
|
45
|
+
"@molecule/app-query-tanstack": "1.1.0",
|
|
46
46
|
"@types/node": "26.6.5",
|
|
47
47
|
"@types/react": "19.3.0",
|
|
48
48
|
"@types/react-dom": "19.3.0",
|