@veriforms/webapp-react 0.1.3 → 0.1.4
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 +5 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +9 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ over `@veriforms/webapp-sdk`.
|
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
9
|
npm i @veriforms/webapp-sdk @veriforms/webapp-react react@18.3.1 react-dom@18.3.1
|
|
10
|
-
npm i -D @veriforms/webapp-vite vite
|
|
10
|
+
npm i -D @veriforms/webapp-vite vite@6 # or let `vf app init <appId>` write the whole project
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
The packages are public on npm (owner decision 2026-12-03). Web apps built in code are open to
|
|
@@ -56,6 +56,10 @@ function Book() {
|
|
|
56
56
|
`KnowledgeSearchError` — never an empty answer. Show `sourceLine` under anything built from the
|
|
57
57
|
passages. No question, no search: pass the question the visitor submitted, not every keystroke
|
|
58
58
|
(each search is metered).
|
|
59
|
+
- `useValues(keys?)` (0.1.4) — Definitions values the app's `config.json` declares in `"values"`:
|
|
60
|
+
`data` maps each key to its text, formatted in the app's language as `{{value:<key>}}` writes it.
|
|
61
|
+
A key that is not declared, or a value the space does not serve, is `error`, a `ValuesError` with
|
|
62
|
+
its `code` and `keys` — never an empty text. The draft (`vf app dev`) serves the real values too.
|
|
59
63
|
- `useAccess()`, `useTheme()`.
|
|
60
64
|
- `<PageLink to="admin">` — the way across pages (each page is its own access area).
|
|
61
65
|
- `<VfForm source="booking" />` — the platform's form with its server rules mirrored.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnchorHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import type { FormKey, PageName, ParamsOf, ReadKey, ResultOf, RowOf, SendKey, SendResultOf, BodyOf, SubmissionsReadKey, FieldsOf, TableKey, TablePage, SubmissionsPage, UserInfo, WriteOptions, RoleName, SourceKey, KnowledgeKey, KnowledgeAnswer } from '@veriforms/webapp-sdk';
|
|
2
|
+
import type { FormKey, PageName, ParamsOf, ReadKey, ResultOf, RowOf, SendKey, SendResultOf, BodyOf, SubmissionsReadKey, FieldsOf, TableKey, TablePage, SubmissionsPage, UserInfo, WriteOptions, RoleName, SourceKey, KnowledgeKey, KnowledgeAnswer, ValueKey } from '@veriforms/webapp-sdk';
|
|
3
3
|
/** What a read hook holds: the data once loaded, the error as raised, and a way to read again. */
|
|
4
4
|
export interface Loaded<T> {
|
|
5
5
|
data: T | undefined;
|
|
@@ -26,6 +26,13 @@ export declare function useSubmissions<K extends SubmissionsReadKey>(source: K,
|
|
|
26
26
|
* so pass the question the visitor submitted, not every keystroke.
|
|
27
27
|
*/
|
|
28
28
|
export declare function useKnowledgeSearch<K extends KnowledgeKey>(source: K, question: string | null | undefined): Loaded<KnowledgeAnswer>;
|
|
29
|
+
/**
|
|
30
|
+
* Definitions values the app's config.json declares in "values" (since 0.1.4): `data` maps each key to
|
|
31
|
+
* its text as `{{value:<key>}}` writes it (formatted — parse a number yourself). Without `keys`, every
|
|
32
|
+
* declared value. A refusal (an undeclared key, a value the space does not serve) is `error`, a
|
|
33
|
+
* `ValuesError` naming the code and the keys — never an empty text.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useValues<K extends ValueKey>(keys?: readonly K[]): Loaded<Record<K, string>>;
|
|
29
36
|
/** Who is signed in. */
|
|
30
37
|
export declare function useUser(): Loaded<UserInfo>;
|
|
31
38
|
/** What the visitor may do, as the server told the page (the server checks every call again). */
|
package/dist/index.js
CHANGED
|
@@ -73,6 +73,15 @@ export function useKnowledgeSearch(source, question) {
|
|
|
73
73
|
const q = (question ?? '').trim();
|
|
74
74
|
return useRead(() => sdk.knowledge.search(source, q), keyOf('knowledge', source, q), undefined, q.length > 0);
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Definitions values the app's config.json declares in "values" (since 0.1.4): `data` maps each key to
|
|
78
|
+
* its text as `{{value:<key>}}` writes it (formatted — parse a number yourself). Without `keys`, every
|
|
79
|
+
* declared value. A refusal (an undeclared key, a value the space does not serve) is `error`, a
|
|
80
|
+
* `ValuesError` naming the code and the keys — never an empty text.
|
|
81
|
+
*/
|
|
82
|
+
export function useValues(keys) {
|
|
83
|
+
return useRead(() => sdk.values.get(keys), keyOf('values', keys ?? null), undefined);
|
|
84
|
+
}
|
|
76
85
|
/** Who is signed in. */
|
|
77
86
|
export function useUser() {
|
|
78
87
|
return useRead(() => sdk.user(), 'user', undefined);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veriforms/webapp-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "React hooks and components for VeriForms web apps built in code: data sources, tables, submissions, the visitor, access, page links and the platform's form — over @veriforms/webapp-sdk.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veriforms",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepublishOnly": "npm run build"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@veriforms/webapp-sdk": "0.1.
|
|
39
|
+
"@veriforms/webapp-sdk": "0.1.4",
|
|
40
40
|
"react": "^18.3.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|