@molecule/app-query-svelte 1.2.0 → 1.3.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 +20 -1
- package/dist/QueryContent.svelte +3 -0
- 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 +9 -0
- 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-16T21:21:19.334Z
|
|
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,6 +444,16 @@ 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. Omit it to keep empty arrays as data.
|
|
451
|
+
*/
|
|
452
|
+
empty?: {
|
|
453
|
+
when: (data: NonNullable<T>) => boolean
|
|
454
|
+
render: NonNullable<QueryContentProps<T>['children']>
|
|
455
|
+
}
|
|
456
|
+
|
|
445
457
|
/**
|
|
446
458
|
* State from `useQuery` — as the readable store the hook returns, or as a
|
|
447
459
|
* compatible observer's plain state object. Both follow the query.
|
|
@@ -711,3 +723,10 @@ Peer dependencies:
|
|
|
711
723
|
- Keep every resource identity in the query key. A boundary cannot correct a
|
|
712
724
|
query that supplies another record's cached data. QueryContent is headless
|
|
713
725
|
and owns no translations or styling.
|
|
726
|
+
|
|
727
|
+
For a collection, `QueryContent` also accepts one `empty` branch:
|
|
728
|
+
`{ when: page => page.rows.length === 0, render: page => selectedEmptyState }`.
|
|
729
|
+
It is exclusive with loaded children, so a selected view chooses its message and
|
|
730
|
+
recovery action once rather than rendering a general empty message beside it.
|
|
731
|
+
`when` receives a loaded document; empty arrays remain data when this prop is omitted.
|
|
732
|
+
The render value uses this framework's existing children function, snippet or template.
|
package/dist/QueryContent.svelte
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
pending = null,
|
|
26
26
|
missing = null,
|
|
27
27
|
error = null,
|
|
28
|
+
empty,
|
|
28
29
|
}: QueryContentProps<T> = $props()
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -48,6 +49,8 @@
|
|
|
48
49
|
{/if}
|
|
49
50
|
{:else if $view.data === null}
|
|
50
51
|
{#if missing}{@render missing()}{/if}
|
|
52
|
+
{:else if empty?.when($view.data)}
|
|
53
|
+
{@render empty.render($view.data)}
|
|
51
54
|
{:else}
|
|
52
55
|
{@render children($view.data)}
|
|
53
56
|
{/if}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryContent.svelte.d.ts","sourceRoot":"","sources":["../src/QueryContent.svelte"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,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,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,6 +34,15 @@ 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. Omit it to keep empty arrays as data.
|
|
41
|
+
*/
|
|
42
|
+
empty?: {
|
|
43
|
+
when: (data: NonNullable<T>) => boolean;
|
|
44
|
+
render: NonNullable<QueryContentProps<T>['children']>;
|
|
45
|
+
};
|
|
37
46
|
/**
|
|
38
47
|
* State from `useQuery` — as the readable store the hook returns, or as a
|
|
39
48
|
* compatible observer's plain state object. Both follow the query.
|
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,EACD,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC,GAC1D,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAA;IACpD,kFAAkF;IAClF,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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,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC,GAC1D,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAA;IACpD,kFAAkF;IAClF,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.0",
|
|
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.
|
|
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.1",
|
|
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",
|