@fanfare-io/fanfare-sdk-react 0.5.0 → 0.7.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 +16 -0
- package/dist/components/auth/otp-input.d.ts +2 -0
- package/dist/hooks/use-experience-journey.d.ts +4 -0
- package/dist/index.js +2071 -2045
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -44,6 +44,22 @@ Customization has four levels of increasing specificity: `theme`, `variant`, `sl
|
|
|
44
44
|
|
|
45
45
|
`slots` override targeted states while keeping the default widget flow. `children` receives `{ journey, view, snapshot, error, start, isStarting }` when you want to render the full state yourself.
|
|
46
46
|
|
|
47
|
+
## Error handling
|
|
48
|
+
|
|
49
|
+
The widget classifies every failure into one of four **dispositions** and surfaces it accordingly, so a recoverable error stays in context instead of replacing the screen:
|
|
50
|
+
|
|
51
|
+
- **INLINE** — recoverable in place (e.g. a wrong OTP). Shown under the active field; journey state is preserved.
|
|
52
|
+
- **STEP_RESET** — the current step's setup is stale (e.g. an expired code). The step re-arms (resend).
|
|
53
|
+
- **RESTART** — the session/admission is no longer valid. The widget reroutes via the journey rather than dead-ending.
|
|
54
|
+
- **PANEL** — terminal. The full-screen error panel — now the exception, not the default.
|
|
55
|
+
|
|
56
|
+
The displayed copy is **always SDK-owned i18n** (localized via your `FanfareProvider` locale), never the raw server response — a raw payload can never reach the UI.
|
|
57
|
+
|
|
58
|
+
`onError(error)` receives the real, structured `FanfareError` (it is an `Error` subclass, so the `(error: Error) => void` signature is unchanged). Read `error.code`, `error.status`, `error.action`, and `error.details` for telemetry/handling. Two notes:
|
|
59
|
+
|
|
60
|
+
- **`onError` now fires more often.** Recoverable inline errors (e.g. an incorrect OTP) now reach `onError` too, not just terminal failures. Treat `onError` as a notification/telemetry channel — do **not** drive full-screen rendering from it, or an inline typo would flash a full-screen error. Filter on `error.code` or the disposition if you need to react only to terminal failures.
|
|
61
|
+
- **Copy is sanitized; details are not.** The strings the widget renders are i18n copy; `error.details` may contain raw server data — log it deliberately, don't surface it to end users.
|
|
62
|
+
|
|
47
63
|
## Documentation
|
|
48
64
|
|
|
49
65
|
- [React components guide](https://docs.fanfare.io/sdk/components/react)
|
|
@@ -26,6 +26,8 @@ export interface OTPInputProps {
|
|
|
26
26
|
disabled?: boolean;
|
|
27
27
|
/** Auto focus first input */
|
|
28
28
|
autoFocus?: boolean;
|
|
29
|
+
/** id of an external element describing the current error (links digits to an AlertPanel). */
|
|
30
|
+
ariaDescribedBy?: string;
|
|
29
31
|
/** Additional class name */
|
|
30
32
|
className?: string;
|
|
31
33
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FanfareError } from '@fanfare-io/fanfare-sdk-core/errors';
|
|
1
2
|
import { JourneyHandle, JourneySnapshot, JourneyView } from '@fanfare-io/fanfare-sdk-core/experiences';
|
|
2
3
|
export interface ExperienceJourneyOptions {
|
|
3
4
|
accessCode?: string;
|
|
@@ -14,7 +15,10 @@ export interface UseExperienceJourneyResult {
|
|
|
14
15
|
journey: JourneyHandle | null;
|
|
15
16
|
view: JourneyView | null;
|
|
16
17
|
snapshot: JourneySnapshot | null;
|
|
18
|
+
/** @deprecated Prefer `fanfareError` for structured, leak-safe handling. */
|
|
17
19
|
error: string | null;
|
|
20
|
+
/** Structured error from the last failed `start`, preserved for classification. */
|
|
21
|
+
fanfareError: FanfareError | null;
|
|
18
22
|
start: (options?: ExperienceJourneyOptions) => Promise<JourneyView>;
|
|
19
23
|
}
|
|
20
24
|
export declare function useExperienceJourney(experienceId: string | undefined, options?: UseExperienceJourneyOptions): UseExperienceJourneyResult;
|