@runic-artifex/react 0.7.0-preview.7 → 0.7.0-preview.8
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 +41 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -140,7 +140,7 @@ neither.
|
|
|
140
140
|
## `useOperation(start, options?)`
|
|
141
141
|
|
|
142
142
|
Observes a generated `start<Command>()` operation through the framework-neutral
|
|
143
|
-
[operation controller](https://github.com/Runic-Artifex/runic-sdk/tree/v0.7.0-preview.
|
|
143
|
+
[operation controller](https://github.com/Runic-Artifex/runic-sdk/tree/v0.7.0-preview.8/packages/web/views#operation-feedback-and-latest-selection).
|
|
144
144
|
`run(...args)` calls the latest `start`, so it may close over the current client:
|
|
145
145
|
|
|
146
146
|
```tsx
|
|
@@ -161,10 +161,49 @@ Unmounting stops rendering feedback but never cancels accepted work. The optiona
|
|
|
161
161
|
`cancel(operation)` and `waitForCompletion(operation, status)` callbacks are the
|
|
162
162
|
controller's options.
|
|
163
163
|
|
|
164
|
+
## Interactions
|
|
165
|
+
|
|
166
|
+
A ReactiveUI `Interaction<TInput, TOutput>` on the ViewModel, such as the
|
|
167
|
+
question of a `ReactiveLeaveConfirmation.WithInteraction` leave guard, is
|
|
168
|
+
`client.interactions.<name>` on the generated client. Register the page's
|
|
169
|
+
answer in an effect: `handle((prompt, { signal }) => …)` returns the function
|
|
170
|
+
that removes it, so React removes the handler when the page unmounts or its
|
|
171
|
+
client changes:
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
export function EditPage({ page }: { page: EditPageReference }) {
|
|
175
|
+
const { state, client } = useView(page);
|
|
176
|
+
useEffect(() => client?.interactions.confirmDiscard.handle(
|
|
177
|
+
async (prompt, { signal }) => confirmDialog(`Discard the changes to ${prompt.itemName}?`, signal),
|
|
178
|
+
), [client]);
|
|
179
|
+
const close = useCommand(() => client?.close());
|
|
180
|
+
return <button disabled={!client || close.pending} onClick={() => void close.run()}>Close {state?.name}</button>;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`prompt` and the answer are typed from the ViewModel's interaction. The
|
|
185
|
+
handler may return the answer or a promise of it; `confirmDialog` stands for
|
|
186
|
+
the application's own dialog.
|
|
187
|
+
|
|
188
|
+
- The page is asked for a departure that its own window starts: its Close, the
|
|
189
|
+
shell's Back in the same window, or a guarded window close.
|
|
190
|
+
- `signal` aborts when .NET no longer needs the answer, for example when the
|
|
191
|
+
departure is superseded or the window closes. Close the dialog then; a late
|
|
192
|
+
answer is ignored.
|
|
193
|
+
- The handler exists only after the effect has run. A departure before that,
|
|
194
|
+
such as a close during the page's first render, is answered by the
|
|
195
|
+
ViewModel's .NET fallback handler, or fails closed without one.
|
|
196
|
+
|
|
197
|
+
The [ReactiveUI leave confirmation](https://github.com/Runic-Artifex/runic-sdk/blob/v0.7.0-preview.8/packages/dotnet/Runic.Application.Views.ReactiveUI/README.md#leave-confirmation-in-a-web-view)
|
|
198
|
+
has the .NET side and which View answers which departure. In a frontend test,
|
|
199
|
+
the generated mock's `interactions.<name>.request(input)` resolves with the
|
|
200
|
+
registered handler's answer; see the
|
|
201
|
+
[Testing guide](https://github.com/Runic-Artifex/runic-sdk/tree/v0.7.0-preview.8/packages/web/views#testing).
|
|
202
|
+
|
|
164
203
|
## `useCollectionViewport(options)`
|
|
165
204
|
|
|
166
205
|
Follows a fixed-row-height scroll container and returns `{ viewport, ref }`.
|
|
167
|
-
`viewport` is the [`collectionViewport`](https://github.com/Runic-Artifex/runic-sdk/tree/v0.7.0-preview.
|
|
206
|
+
`viewport` is the [`collectionViewport`](https://github.com/Runic-Artifex/runic-sdk/tree/v0.7.0-preview.8/packages/web/views#collectionviewportoptions)
|
|
168
207
|
range for the container; it changes only when the range or sizes change. Send
|
|
169
208
|
the range to the ViewModel from an effect:
|
|
170
209
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runic-artifex/react",
|
|
3
|
-
"version": "0.7.0-preview.
|
|
3
|
+
"version": "0.7.0-preview.8",
|
|
4
4
|
"description": "React hooks for generated Runic Views clients",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": ">=18.3.0 <20",
|
|
32
|
-
"@runic-artifex/views": "0.7.0-preview.
|
|
32
|
+
"@runic-artifex/views": "0.7.0-preview.8"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@runic-artifex/views": "0.7.0-preview.
|
|
35
|
+
"@runic-artifex/views": "0.7.0-preview.8",
|
|
36
36
|
"@types/react": "19.3.0",
|
|
37
37
|
"@types/react-dom": "19.3.0",
|
|
38
38
|
"happy-dom": "20.14.5",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"url": "git+https://github.com/Runic-Artifex/runic-sdk.git",
|
|
54
54
|
"directory": "packages/web/react"
|
|
55
55
|
},
|
|
56
|
-
"homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/v0.7.0-preview.
|
|
56
|
+
"homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/v0.7.0-preview.8/packages/web/react#readme",
|
|
57
57
|
"bugs": {
|
|
58
58
|
"url": "https://github.com/Runic-Artifex/runic-sdk/issues"
|
|
59
59
|
},
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"views",
|
|
64
64
|
"react"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "39655f2c894d611c794fe7378ef5a953ab082118"
|
|
67
67
|
}
|