@fanfare-io/fanfare-sdk-react 0.20.1 → 0.22.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 +14 -0
- package/dist/components/primitives/countdown.d.ts +53 -14
- package/dist/components/widgets/experience-widget.d.ts +28 -0
- package/dist/components/widgets/internal/auction-ledger.d.ts +1 -12
- package/dist/components/widgets/internal/selection-branches.d.ts +0 -2
- package/dist/hooks/use-experience-journey.d.ts +6 -0
- package/dist/index-DMy2IUi5.js +8011 -0
- package/dist/index.js +1 -1
- package/dist/stripe-card-field-DaNEAuCE.js +175 -0
- package/dist/styles/base.css +1 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/theme.css +449 -1
- package/dist/theme/font-loader.d.ts +58 -0
- package/dist/theme/theme-context.d.ts +8 -0
- package/package.json +6 -7
- package/dist/index-BRXy30hl.js +0 -7837
- package/dist/stripe-card-field-D9L3ASYF.js +0 -170
package/README.md
CHANGED
|
@@ -40,6 +40,20 @@ export function App() {
|
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
`autoStart` routes the journey on mount; entering is a separate matter. A queue, draw or timed
|
|
44
|
+
release the merchant set to enter on arrival needs no Enter click: the SDK enters the consumer
|
|
45
|
+
inside the routing operation that lands on it, and the widget shows a joining wait — no Enter
|
|
46
|
+
control — until they have their place, then the participating screen. If the entry is turned down,
|
|
47
|
+
the widget falls back to the ordinary Enter screen with the refusal beside it. A host that wants
|
|
48
|
+
every entry to stay an explicit press passes `automaticEntry={false}` to `ExperienceWidget`, or the
|
|
49
|
+
same `automaticEntry` option to `useExperienceJourney`; both reach the ready view's `start`, and
|
|
50
|
+
omitting it keeps the SDK default of entering on arrival. The contract is in the core package's
|
|
51
|
+
`docs/UPGRADING-automatic-entry.md` in the SDK repository.
|
|
52
|
+
|
|
53
|
+
`loadFonts` is off by default. Turned on, the widget fetches the Google Fonts its theme and variant
|
|
54
|
+
name after mount, through a link that never blocks rendering and fails silently to the fallback
|
|
55
|
+
stack. A host that already loads its own fonts — or serves them from its own origin — leaves it off.
|
|
56
|
+
|
|
43
57
|
Customization has four levels of increasing specificity: `theme`, `variant`, `slots`, and `children` or `useExperienceJourney`.
|
|
44
58
|
|
|
45
59
|
`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.
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Countdown Component
|
|
3
3
|
*
|
|
4
|
-
* Displays time remaining until a target date.
|
|
5
|
-
* Automatically updates every second.
|
|
4
|
+
* Displays time remaining until a target date, refreshed every second.
|
|
6
5
|
*
|
|
7
|
-
* Two layouts:
|
|
8
|
-
* - "
|
|
9
|
-
* - "
|
|
6
|
+
* Two layouts share one `--ff-countdown-*` token set:
|
|
7
|
+
* - "cells" (default): one box per time unit
|
|
8
|
+
* - "inline": a single line that fits inside a sentence, a ledger row or a button
|
|
9
|
+
*
|
|
10
|
+
* The visual layouts are `aria-hidden`; one visually-hidden sibling carries
|
|
11
|
+
* `role="timer"`, so exactly one live region exists whatever the container
|
|
12
|
+
* width makes visible.
|
|
10
13
|
*/
|
|
11
14
|
export type CountdownSize = "default" | "hero";
|
|
12
|
-
export type CountdownTone = "calm" | "warning" | "critical";
|
|
15
|
+
export type CountdownTone = "calm" | "warning" | "critical" | "auto";
|
|
13
16
|
export interface CountdownProps {
|
|
14
17
|
/** Target date/time to count down to */
|
|
15
18
|
targetDate: Date | string | number;
|
|
@@ -27,16 +30,52 @@ export interface CountdownProps {
|
|
|
27
30
|
showMinutes?: boolean;
|
|
28
31
|
/** Show seconds in countdown */
|
|
29
32
|
showSeconds?: boolean;
|
|
30
|
-
/** Layout: "
|
|
31
|
-
layout?: "
|
|
32
|
-
/**
|
|
33
|
+
/** Layout: "cells" for a box per unit, "inline" for a single line */
|
|
34
|
+
layout?: "cells" | "inline";
|
|
35
|
+
/** Numeral granularity under `layout="cells"`: one text node per unit, or one box per digit. */
|
|
36
|
+
cells?: "unit" | "digit";
|
|
37
|
+
/**
|
|
38
|
+
* How the time is spelled wherever it is written as one line: the inline
|
|
39
|
+
* layout, the narrow fallback the cells layout falls back to, and — always in
|
|
40
|
+
* `clock` spelling — the string assistive technology is given.
|
|
41
|
+
* `labelled` renders `14m 57s`, with a literal space between units.
|
|
42
|
+
* `clock` renders `02:00` / `1:15:17`, and always carries minutes and seconds
|
|
43
|
+
* whatever `showMinutes` and `showSeconds` say.
|
|
44
|
+
*/
|
|
45
|
+
format?: "labelled" | "clock";
|
|
46
|
+
/**
|
|
47
|
+
* Hold the last rendered value. A paused countdown runs no interval, never
|
|
48
|
+
* calls `onComplete` and stops announcing; on resume it re-reads the clock
|
|
49
|
+
* rather than continuing from the held value.
|
|
50
|
+
*/
|
|
51
|
+
paused?: boolean;
|
|
52
|
+
/** Size: "default" (compact display) or "hero" (the larger urgency-driver); the two differ only in scale. */
|
|
33
53
|
size?: CountdownSize;
|
|
34
54
|
/**
|
|
35
|
-
* Presentational urgency tone
|
|
36
|
-
*
|
|
37
|
-
* -
|
|
38
|
-
* -
|
|
55
|
+
* Presentational urgency tone, published as `data-tone` on both layout roots
|
|
56
|
+
* and on each cell, and coloured from the `--ff-countdown-tone-*` tokens.
|
|
57
|
+
* - calm: numeral colour (default)
|
|
58
|
+
* - warning: warning tone colour
|
|
59
|
+
* - critical: critical tone colour (in retro, also flips the unit container bg)
|
|
60
|
+
* - auto: resolved from the time remaining on every tick
|
|
39
61
|
*/
|
|
40
62
|
tone?: CountdownTone;
|
|
41
63
|
}
|
|
42
|
-
|
|
64
|
+
interface TimeRemaining {
|
|
65
|
+
days: number;
|
|
66
|
+
hours: number;
|
|
67
|
+
minutes: number;
|
|
68
|
+
seconds: number;
|
|
69
|
+
total: number;
|
|
70
|
+
}
|
|
71
|
+
/** Which units the caller allows on screen; a hidden unit rolls into the next shown one. */
|
|
72
|
+
interface ShownUnits {
|
|
73
|
+
days: boolean;
|
|
74
|
+
hours: boolean;
|
|
75
|
+
minutes: boolean;
|
|
76
|
+
seconds: boolean;
|
|
77
|
+
}
|
|
78
|
+
/** Time left on a target, decomposed across the units the caller shows. */
|
|
79
|
+
export declare function calculateTimeRemaining(targetDate: Date | string | number, shown: ShownUnits, nowMs?: number): TimeRemaining;
|
|
80
|
+
export declare function Countdown({ targetDate, onComplete, expiredLabel, className, showDays, showHours, showMinutes, showSeconds, layout, cells, format, paused, size, tone, }: CountdownProps): import("react/jsx-runtime").JSX.Element | null;
|
|
81
|
+
export {};
|
|
@@ -86,6 +86,13 @@ interface PaymentCollectionBaseSlotProps extends SlotProps {
|
|
|
86
86
|
export type PaymentCollectionSlotProps = PaymentCollectionBaseSlotProps & ({
|
|
87
87
|
intent: "checkout";
|
|
88
88
|
onResume: () => Promise<void>;
|
|
89
|
+
/** Grant expiry as a ms epoch: the deadline the claim window counts down to. */
|
|
90
|
+
expiresAt?: number;
|
|
91
|
+
/**
|
|
92
|
+
* True while the deadline is the server's alone, so the claim window holds its last value
|
|
93
|
+
* instead of counting a limit the SDK is no longer enforcing.
|
|
94
|
+
*/
|
|
95
|
+
expiryPaused: boolean;
|
|
89
96
|
} | {
|
|
90
97
|
intent: "enter" | "reenter";
|
|
91
98
|
preAuthAmount: string;
|
|
@@ -176,6 +183,17 @@ export interface ExperienceWidgetProps {
|
|
|
176
183
|
experienceId: string;
|
|
177
184
|
/** Automatically start journey on mount */
|
|
178
185
|
autoStart?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Whether the SDK may enter the consumer on arrival at a distribution the merchant set to enter
|
|
188
|
+
* automatically. Omit to keep the default (`true`); pass `false` to keep every entry explicit.
|
|
189
|
+
*/
|
|
190
|
+
automaticEntry?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Whether the widget fetches the Google Fonts stylesheets for the families its theme names.
|
|
193
|
+
* Off unless asked: an embed's page owns its own font delivery and its own content policy.
|
|
194
|
+
* The fetch never blocks rendering and a failure is silent.
|
|
195
|
+
*/
|
|
196
|
+
loadFonts?: boolean;
|
|
179
197
|
/** Pre-fill access code */
|
|
180
198
|
accessCode?: string;
|
|
181
199
|
/** Auto-enter waitlist when available */
|
|
@@ -215,6 +233,16 @@ export interface ExperienceWidgetProps {
|
|
|
215
233
|
onFanfareCheckout?: (result: FanfareCheckoutResult) => void;
|
|
216
234
|
/** Called when an error occurs */
|
|
217
235
|
onError?: (error: Error) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Horizontal placement of the widget inside the host's container. The widget is start-aligned
|
|
238
|
+
* unless this is `"center"`.
|
|
239
|
+
*/
|
|
240
|
+
align?: "start" | "center";
|
|
241
|
+
/**
|
|
242
|
+
* Explicit override of the widget's adaptive maximum width. Omit to keep the value of
|
|
243
|
+
* the `--ff-widget-max-width` custom property.
|
|
244
|
+
*/
|
|
245
|
+
size?: "compact" | "regular" | "wide";
|
|
218
246
|
/** Additional class name */
|
|
219
247
|
className?: string;
|
|
220
248
|
}
|
|
@@ -36,7 +36,7 @@ export declare namespace Ledger {
|
|
|
36
36
|
var displayName: string;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Discrete unit pips for a Dutch remaining count, at the wide
|
|
39
|
+
* Discrete unit pips for a Dutch remaining count, shown only at the wide container width.
|
|
40
40
|
*
|
|
41
41
|
* The pips are decorative; the grid states the count once in its own label so a screen reader
|
|
42
42
|
* hears "7 of 20 units remaining" rather than twenty unlabelled cells.
|
|
@@ -49,14 +49,3 @@ export declare function UnitPips({ remaining, total, label }: {
|
|
|
49
49
|
export declare namespace UnitPips {
|
|
50
50
|
var displayName: string;
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Whether the panel's own rendered width has reached `threshold`.
|
|
54
|
-
*
|
|
55
|
-
* The adaptation is the panel's, not the viewport's: the widget is embedded at whatever width its
|
|
56
|
-
* host gives it, and a viewport query would split the columns on a page that never made room.
|
|
57
|
-
*
|
|
58
|
-
* The measured node is attached through a callback ref rather than observed once after mount: the
|
|
59
|
-
* panel swaps its skeleton for the live ledger, so the node the observer holds is replaced under
|
|
60
|
-
* it and a width read after the swap would come from a detached element.
|
|
61
|
-
*/
|
|
62
|
-
export declare function useIsWide(threshold: number): readonly [(element: HTMLDivElement | null) => void, boolean];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { SelectionAvailability, SelectionChoice, SelectionDraft, SelectionOptions } from '@fanfare-io/fanfare-sdk-core/selections';
|
|
2
2
|
import { ProductSelectorHandle } from './selection';
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
/** Widened so a selection-bearing panel stacks its rows instead of clipping them at the card cap. */
|
|
5
|
-
export declare const SELECTION_PANEL_CLASS = "ff:max-h-none ff:overflow-visible";
|
|
6
4
|
export interface EntrySelectionSurfaceProps {
|
|
7
5
|
loadOptions: () => Promise<SelectionOptions>;
|
|
8
6
|
/** Already-translated heading above the picker. */
|
|
@@ -3,6 +3,12 @@ import { JourneyHandle, JourneySnapshot, JourneyView } from '@fanfare-io/fanfare
|
|
|
3
3
|
export interface ExperienceJourneyOptions {
|
|
4
4
|
accessCode?: string;
|
|
5
5
|
autoEnterWaitlist?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Whether core may enter the consumer on the consumer's behalf when routing lands on a
|
|
8
|
+
* distribution the merchant set to enter on arrival. Left unset, core's default (`true`)
|
|
9
|
+
* applies; `false` keeps every entry an explicit one the consumer presses.
|
|
10
|
+
*/
|
|
11
|
+
automaticEntry?: boolean;
|
|
6
12
|
}
|
|
7
13
|
export interface UseExperienceJourneyOptions extends ExperienceJourneyOptions {
|
|
8
14
|
/**
|