@molecule/app-query-svelte 1.2.0 → 1.3.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 +23 -3
- package/dist/QueryContent.svelte +7 -3
- package/dist/QueryContent.svelte.d.ts.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/types.d.ts +11 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
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-17T05:19:22.368Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-query-svelte
|
|
@@ -333,6 +333,8 @@ interface QueryResource<T, Create = Partial<T>, Update = Partial<T>> {
|
|
|
333
333
|
/**
|
|
334
334
|
* `useQuery` options for the collection. `viewer` is who the answer is for (the signed-in id,
|
|
335
335
|
* or `'anonymous'`); a page or filter change keeps the rows on screen until the next answer.
|
|
336
|
+
* One record per URL identity, retaining the first occurrence. Equal values without an
|
|
337
|
+
* addressable id remain separate. Writes already refresh the collection.
|
|
336
338
|
*/
|
|
337
339
|
list(viewer: string, params?: Record<string, unknown>): QueryOptions<T[]>
|
|
338
340
|
/**
|
|
@@ -442,13 +444,24 @@ A loaded document owns its controls; absent documents expose only status content
|
|
|
442
444
|
|
|
443
445
|
```typescript
|
|
444
446
|
interface QueryContentProps<T> {
|
|
447
|
+
/**
|
|
448
|
+
* One optional empty branch, exclusive with children. The pure predicate reads the
|
|
449
|
+
* loaded document (an array or an application-owned envelope); render selects the
|
|
450
|
+
* current view's message and recovery action. A previous key's empty document uses
|
|
451
|
+
* pending/error instead. Omit it to keep empty arrays as data.
|
|
452
|
+
*/
|
|
453
|
+
empty?: {
|
|
454
|
+
when: (data: NonNullable<T>) => boolean
|
|
455
|
+
render: NonNullable<QueryContentProps<T>['children']>
|
|
456
|
+
}
|
|
457
|
+
|
|
445
458
|
/**
|
|
446
459
|
* State from `useQuery` — as the readable store the hook returns, or as a
|
|
447
460
|
* compatible observer's plain state object. Both follow the query.
|
|
448
461
|
*/
|
|
449
462
|
query:
|
|
450
|
-
| Readable<Pick<QueryState<T>, 'data' | 'status' | 'error'>>
|
|
451
|
-
| Pick<QueryState<T>, 'data' | 'status' | 'error'>
|
|
463
|
+
| Readable<Pick<QueryState<T>, 'data' | 'status' | 'error' | 'isPreviousData'>>
|
|
464
|
+
| Pick<QueryState<T>, 'data' | 'status' | 'error' | 'isPreviousData'>
|
|
452
465
|
/** Mounted only with a real document, including false, zero and an empty list. */
|
|
453
466
|
children: Snippet<[NonNullable<T>]>
|
|
454
467
|
/** Initial idle/loading content. Render a status snippet, never a fake item or action. */
|
|
@@ -711,3 +724,10 @@ Peer dependencies:
|
|
|
711
724
|
- Keep every resource identity in the query key. A boundary cannot correct a
|
|
712
725
|
query that supplies another record's cached data. QueryContent is headless
|
|
713
726
|
and owns no translations or styling.
|
|
727
|
+
|
|
728
|
+
For a collection, `QueryContent` also accepts one `empty` branch:
|
|
729
|
+
`{ when: page => page.rows.length === 0, render: page => selectedEmptyState }`.
|
|
730
|
+
It is exclusive with loaded children, so a selected view chooses its message and
|
|
731
|
+
recovery action once rather than rendering a general empty message beside it.
|
|
732
|
+
`when` receives a loaded document; empty arrays remain data when this prop is omitted.
|
|
733
|
+
The render value uses this framework's existing children function, snippet or template.
|
package/dist/QueryContent.svelte
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
refresh, including a failed refresh. Status fallbacks belong outside the
|
|
8
8
|
list or record container rendered by `children`, and so does a refresh
|
|
9
9
|
line; the default fallbacks render nothing. Headless: it owns no
|
|
10
|
-
translations and no styling.
|
|
10
|
+
translations and no styling. A previous key's empty or missing document
|
|
11
|
+
renders pending/error until the current key answers.
|
|
11
12
|
-->
|
|
12
13
|
<script lang="ts" generics="T">
|
|
13
14
|
import { type Readable, readonly, writable } from 'svelte/store'
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
import type { QueryContentProps } from './types.js'
|
|
18
19
|
|
|
19
20
|
/** The part of a query state this component renders from. */
|
|
20
|
-
type QueryView = Pick<QueryState<T>, 'data' | 'status' | 'error'>
|
|
21
|
+
type QueryView = Pick<QueryState<T>, 'data' | 'status' | 'error' | 'isPreviousData'>
|
|
21
22
|
|
|
22
23
|
let {
|
|
23
24
|
query,
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
pending = null,
|
|
26
27
|
missing = null,
|
|
27
28
|
error = null,
|
|
29
|
+
empty,
|
|
28
30
|
}: QueryContentProps<T> = $props()
|
|
29
31
|
|
|
30
32
|
/**
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
)
|
|
41
43
|
</script>
|
|
42
44
|
|
|
43
|
-
{#if $view.data === undefined}
|
|
45
|
+
{#if $view.data === undefined || ($view.isPreviousData && ($view.data === null || empty?.when($view.data)))}
|
|
44
46
|
{#if $view.status === 'error' && error}
|
|
45
47
|
{@render error($view.error)}
|
|
46
48
|
{:else if pending}
|
|
@@ -48,6 +50,8 @@
|
|
|
48
50
|
{/if}
|
|
49
51
|
{:else if $view.data === null}
|
|
50
52
|
{#if missing}{@render missing()}{/if}
|
|
53
|
+
{:else if empty?.when($view.data)}
|
|
54
|
+
{@render empty.render($view.data)}
|
|
51
55
|
{:else}
|
|
52
56
|
{@render children($view.data)}
|
|
53
57
|
{/if}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryContent.svelte.d.ts","sourceRoot":"","sources":["../src/QueryContent.svelte"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EA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AAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3H,YAAY,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACjE;AACD,QAAA,MAAM,YAAY,EAAE,qBAAmC,CAAC;AACtC,KAAK,YAAY,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,eAAe,YAAY,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -290,6 +290,13 @@
|
|
|
290
290
|
* query that supplies another record's cached data. QueryContent is headless
|
|
291
291
|
* and owns no translations or styling.
|
|
292
292
|
*
|
|
293
|
+
* For a collection, `QueryContent` also accepts one `empty` branch:
|
|
294
|
+
* `{ when: page => page.rows.length === 0, render: page => selectedEmptyState }`.
|
|
295
|
+
* It is exclusive with loaded children, so a selected view chooses its message and
|
|
296
|
+
* recovery action once rather than rendering a general empty message beside it.
|
|
297
|
+
* `when` receives a loaded document; empty arrays remain data when this prop is omitted.
|
|
298
|
+
* The render value uses this framework's existing children function, snippet or template.
|
|
299
|
+
*
|
|
293
300
|
* @module
|
|
294
301
|
*/
|
|
295
302
|
export * from './components.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4SG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -290,6 +290,13 @@
|
|
|
290
290
|
* query that supplies another record's cached data. QueryContent is headless
|
|
291
291
|
* and owns no translations or styling.
|
|
292
292
|
*
|
|
293
|
+
* For a collection, `QueryContent` also accepts one `empty` branch:
|
|
294
|
+
* `{ when: page => page.rows.length === 0, render: page => selectedEmptyState }`.
|
|
295
|
+
* It is exclusive with loaded children, so a selected view chooses its message and
|
|
296
|
+
* recovery action once rather than rendering a general empty message beside it.
|
|
297
|
+
* `when` receives a loaded document; empty arrays remain data when this prop is omitted.
|
|
298
|
+
* The render value uses this framework's existing children function, snippet or template.
|
|
299
|
+
*
|
|
293
300
|
* @module
|
|
294
301
|
*/
|
|
295
302
|
export * from './components.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -34,11 +34,21 @@ export interface UseQueryResult<T> extends QueryState<T> {
|
|
|
34
34
|
}
|
|
35
35
|
/** A loaded document owns its controls; absent documents expose only status content. */
|
|
36
36
|
export interface QueryContentProps<T> {
|
|
37
|
+
/**
|
|
38
|
+
* One optional empty branch, exclusive with children. The pure predicate reads the
|
|
39
|
+
* loaded document (an array or an application-owned envelope); render selects the
|
|
40
|
+
* current view's message and recovery action. A previous key's empty document uses
|
|
41
|
+
* pending/error instead. Omit it to keep empty arrays as data.
|
|
42
|
+
*/
|
|
43
|
+
empty?: {
|
|
44
|
+
when: (data: NonNullable<T>) => boolean;
|
|
45
|
+
render: NonNullable<QueryContentProps<T>['children']>;
|
|
46
|
+
};
|
|
37
47
|
/**
|
|
38
48
|
* State from `useQuery` — as the readable store the hook returns, or as a
|
|
39
49
|
* compatible observer's plain state object. Both follow the query.
|
|
40
50
|
*/
|
|
41
|
-
query: Readable<Pick<QueryState<T>, 'data' | 'status' | 'error'>> | Pick<QueryState<T>, 'data' | 'status' | 'error'>;
|
|
51
|
+
query: Readable<Pick<QueryState<T>, 'data' | 'status' | 'error' | 'isPreviousData'>> | Pick<QueryState<T>, 'data' | 'status' | 'error' | 'isPreviousData'>;
|
|
42
52
|
/** Mounted only with a real document, including false, zero and an empty list. */
|
|
43
53
|
children: Snippet<[NonNullable<T>]>;
|
|
44
54
|
/** Initial idle/loading content. Render a status snippet, never a fake item or action. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IACtD;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,IAAI,CAAA;IAC1E;;;;;OAKG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;CACtC;AAED,wFAAwF;AACxF,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC;;;OAGG;IACH,KAAK,EAC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AClF,QAAQ,EAAE,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnC,0FAA0F;IAC1F,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAA;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,4CAA4C;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,IAAI,CAAA;CACzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-query-svelte",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Svelte 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-svelte",
|
|
6
6
|
"type": "module",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
59
|
-
"@molecule/app-i18n": "1.2.
|
|
59
|
+
"@molecule/app-i18n": "1.2.2",
|
|
60
60
|
"@molecule/app-icons": "1.0.4",
|
|
61
|
-
"@molecule/app-query": "1.2
|
|
62
|
-
"@molecule/app-query-memory": "1.0
|
|
63
|
-
"@molecule/app-query-tanstack": "1.0
|
|
64
|
-
"@molecule/app-svelte": "3.
|
|
65
|
-
"@molecule/app-ui": "1.
|
|
66
|
-
"@molecule/app-ui-svelte": "1.1.
|
|
61
|
+
"@molecule/app-query": "1.3.2",
|
|
62
|
+
"@molecule/app-query-memory": "1.1.0",
|
|
63
|
+
"@molecule/app-query-tanstack": "1.1.0",
|
|
64
|
+
"@molecule/app-svelte": "3.7.1",
|
|
65
|
+
"@molecule/app-ui": "1.4.0",
|
|
66
|
+
"@molecule/app-ui-svelte": "1.1.6",
|
|
67
67
|
"@sveltejs/package": "3.0.2",
|
|
68
68
|
"@sveltejs/vite-plugin-svelte": "7.1.2",
|
|
69
69
|
"@types/node": "26.6.5",
|