@sonata-innovations/fiber-fbre 3.2.0 → 3.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 +26 -3
- package/dist/fiber-fbre.cjs +1 -1
- package/dist/fiber-fbre.css +1 -1
- package/dist/fiber-fbre.js +1346 -1299
- package/dist/index.d.ts +26 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ Render a Flow object you already have in memory.
|
|
|
99
99
|
| `controls` | `ControlsConfig` | No | Override controls settings (merged over `flow.config.controls`) |
|
|
100
100
|
| `context` | `Record<string, string \| boolean \| number>` | No | External context values for condition evaluation and calculations |
|
|
101
101
|
| `storeRef` | `MutableRefObject<StoreApi<FBREStoreState> \| null>` | No | Ref to access the Zustand store |
|
|
102
|
-
| `onFlowComplete` | `(data: FlowData) => void
|
|
102
|
+
| `onFlowComplete` | `(data: FlowData) => void \| ConfirmationResult \| Promise<void \| ConfirmationResult>` | Yes | Called when the user completes the flow. Return/resolve a `ConfirmationResult` to override the configured confirmation message; a rejected Promise surfaces a completion error |
|
|
103
103
|
| `onScreenChange` | `(index: number, data: FlowData) => void` | No | Called on screen navigation |
|
|
104
104
|
| `onScreenValidationChange` | `(index: number, data: any) => void` | No | Called when screen validity changes |
|
|
105
105
|
|
|
@@ -120,7 +120,7 @@ Fetch a published flow from a Fiber API by ID.
|
|
|
120
120
|
| `controls` | `ControlsConfig` | No | Override controls settings |
|
|
121
121
|
| `context` | `Record<string, string \| boolean \| number>` | No | External context values for condition evaluation and calculations |
|
|
122
122
|
| `storeRef` | `MutableRefObject<StoreApi<FBREStoreState> \| null>` | No | Ref to access the Zustand store |
|
|
123
|
-
| `onFlowComplete` | `(data: FlowData) => void
|
|
123
|
+
| `onFlowComplete` | `(data: FlowData) => void \| ConfirmationResult \| Promise<void \| ConfirmationResult>` | Yes | Called when the user completes the flow. Return/resolve a `ConfirmationResult` to override the configured confirmation message; a rejected Promise surfaces a completion error |
|
|
124
124
|
| `onScreenChange` | `(index: number, data: FlowData) => void` | No | Called on screen navigation |
|
|
125
125
|
| `onScreenValidationChange` | `(index: number, data: any) => void` | No | Called when screen validity changes |
|
|
126
126
|
|
|
@@ -194,6 +194,8 @@ import type {
|
|
|
194
194
|
ThemeConfig,
|
|
195
195
|
NavigationConfig,
|
|
196
196
|
ControlsConfig,
|
|
197
|
+
ConfirmationConfig,
|
|
198
|
+
ConfirmationResult,
|
|
197
199
|
FlowMetadata,
|
|
198
200
|
Component,
|
|
199
201
|
ComponentProperties,
|
|
@@ -220,13 +222,34 @@ import type {
|
|
|
220
222
|
} from "@sonata-innovations/fiber-fbre";
|
|
221
223
|
```
|
|
222
224
|
|
|
225
|
+
## Confirmation Screen
|
|
226
|
+
|
|
227
|
+
A terminal "thank you" screen shown after submission, configured on the flow (`config.confirmation`) — not a `Screen`. Renders only when `show` is not `false` and `title`/`body` has content, replacing the final screen and hiding the controls/stepper. `title`/`body` support `${...}` reference markup (collected fields, calculations, and `context` values by name).
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
const flow = {
|
|
231
|
+
...myFlow,
|
|
232
|
+
config: { ...myFlow.config, confirmation: { show: true, title: "Thank you!", body: "Submitted, ${email}." } },
|
|
233
|
+
};
|
|
234
|
+
<FBRE flow={flow} onFlowComplete={handleComplete} />
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`onFlowComplete` decides *when* it shows: return `void` → shows immediately; return a `Promise` → the submit button stays in-flight until it settles (resolve shows it, **reject** shows a completion error instead); return/resolve a `ConfirmationResult` (`{ title?, body? }`) → overrides the configured message, e.g. with a server reference number.
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
const handleComplete = async (data: FlowData): Promise<ConfirmationResult> => {
|
|
241
|
+
const { referenceId } = await saveToBackend(data);
|
|
242
|
+
return { title: "All done!", body: `Reference: ${referenceId}.` };
|
|
243
|
+
};
|
|
244
|
+
```
|
|
245
|
+
|
|
223
246
|
## Flow JSON Schema
|
|
224
247
|
|
|
225
248
|
```
|
|
226
249
|
Flow
|
|
227
250
|
├── uuid: string
|
|
228
251
|
├── metadata: { name?, description?, ...}
|
|
229
|
-
├── config?: { mode?, theme?: { color?, colorScheme?, style?, background?, surface?, text?, border?, radius?, fontFamily?, error?, success?, warning? }, navigation?: { transition?, allowInvalidTransition? }, controls?: { show?, layout?, showStepper? }, summary? }
|
|
252
|
+
├── config?: { mode?, theme?: { color?, colorScheme?, style?, background?, surface?, text?, border?, radius?, fontFamily?, error?, success?, warning? }, navigation?: { transition?, allowInvalidTransition? }, controls?: { show?, layout?, showStepper? }, summary?, confirmation?: { show?, title?, body? } }
|
|
230
253
|
└── screens: FlowScreen[]
|
|
231
254
|
├── uuid: string
|
|
232
255
|
├── label?: string
|