@fanfare-io/fanfare-sdk-solid 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 CHANGED
@@ -38,6 +38,10 @@ npm install @fanfare-io/fanfare-sdk-core @fanfare-io/fanfare-sdk-solid solid-js
38
38
 
39
39
  Solid applications can use `FanfareProvider`, `ExperienceWidget`, and `useExperienceJourney` directly: the same journey contract as the React adapter, with Solid reactivity.
40
40
 
41
+ `auto-start` (`autoStart` in Solid) routes the journey on mount; entering is a separate matter. A queue, draw or timed release the merchant set to enter on arrival needs no Enter click: the SDK enters the consumer inside the routing operation that lands on it, and the widget shows a joining wait — no Enter control — until they have their place, then the participating screen. If the entry is turned down, the widget falls back to the ordinary Enter screen with the refusal beside it. A host that wants every entry to stay an explicit press passes `automaticEntry={false}` to the Solid `ExperienceWidget`, the same `automaticEntry` option to `useExperienceJourney`, or `automatic-entry="false"` on `<fanfare-experience-widget>`; all three reach the ready view's `start`, and omitting it keeps the SDK default of entering on arrival. The contract is in the core package's `docs/UPGRADING-automatic-entry.md` in the SDK repository.
42
+
43
+ `loadFonts` (`load-fonts` on `<fanfare-experience-widget>`) is off by default. Turned on, the widget fetches the Google Fonts its theme and variant name after mount, through a link that never blocks rendering and fails silently to the fallback stack. A host that already loads its own fonts — or serves them from its own origin — leaves it off.
44
+
41
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. Solid `ExperienceWidget` accepts both `class` and `className`.
42
46
 
43
47
  ## Selection
@@ -0,0 +1,28 @@
1
+ import { Accessor } from 'solid-js';
2
+ /**
3
+ * A server-anchored clock for time-derived rendering (countdowns). `nowMs()`
4
+ * returns "now" corrected to the server's clock, so a skewed device clock
5
+ * doesn't shift what renders.
6
+ *
7
+ * Two phases, provided by `<FanfareProvider serverNow>`:
8
+ * - the first render uses a CONSTANT anchor (`serverNow` itself);
9
+ * - once the provider has mounted, `nowMs()` advances with real time on a fixed
10
+ * server↔device offset, so a countdown mounted later (a routed view shown
11
+ * minutes after the provider mounted) reads the current corrected time rather
12
+ * than the frozen anchor.
13
+ */
14
+ export interface FanfareClock {
15
+ nowMs(): number;
16
+ }
17
+ /** Constant-anchor clock for server render + first paint (deterministic). Null for an absent/invalid anchor. */
18
+ export declare function makeAnchorClock(serverNow: string | undefined): FanfareClock | null;
19
+ /** Live offset clock captured at provider mount: advances with real time, corrected for device skew. */
20
+ export declare function makeOffsetClock(serverNow: string, deviceNowMs: number): FanfareClock | null;
21
+ /**
22
+ * Carries an accessor rather than the clock itself: the provider swaps the
23
+ * anchor clock for the offset clock after mount, and a Solid context value is
24
+ * read once at creation, so the swap only reaches consumers through a signal.
25
+ */
26
+ export declare const FanfareClockContext: import('solid-js').Context<Accessor<FanfareClock | null>>;
27
+ /** The provided server-anchored clock, or null when no anchor is in scope. */
28
+ export declare function useClock(): Accessor<FanfareClock | null>;
@@ -11,10 +11,5 @@ export interface StripeCardFieldProps {
11
11
  complete: boolean;
12
12
  errorMessage: string | null;
13
13
  }) => void;
14
- /**
15
- * The owning panel's account of everything it renders above this field. Its value carries no
16
- * meaning; a change to it means the anchor may have moved and the portal frame needs re-measuring.
17
- */
18
- reflowKey?: string;
19
14
  }
20
15
  export declare function StripeCardField(props: StripeCardFieldProps): JSX.Element;
@@ -1,4 +1,4 @@
1
- import { Accessor, JSX } from 'solid-js';
1
+ import { JSX } from 'solid-js';
2
2
  export type LedgerTone = "default" | "muted" | "live" | "danger" | "success";
3
3
  export interface LedgerRowProps {
4
4
  /** Decorative leading glyph; the label carries the row's meaning for assistive technology. */
@@ -29,7 +29,7 @@ export declare namespace Ledger {
29
29
  var displayName: string;
30
30
  }
31
31
  /**
32
- * Discrete unit pips for a Dutch remaining count, at the wide adaptation only.
32
+ * Discrete unit pips for a Dutch remaining count, shown only at the wide container width.
33
33
  *
34
34
  * The pips are decorative; the grid states the count once in its own label so a screen reader
35
35
  * hears "7 of 20 units remaining" rather than twenty unlabelled cells.
@@ -42,10 +42,3 @@ export declare function UnitPips(props: {
42
42
  export declare namespace UnitPips {
43
43
  var displayName: string;
44
44
  }
45
- /**
46
- * Whether the panel's own rendered width has reached `threshold`.
47
- *
48
- * The adaptation is the panel's, not the viewport's: the widget is embedded at whatever width its
49
- * host gives it, and a viewport query would split the columns on a page that never made room.
50
- */
51
- export declare function useIsWide(threshold: number): [(element: HTMLDivElement) => void, Accessor<boolean>];
@@ -1,22 +1,6 @@
1
- import { GrantedSelection, SelectionAvailability, SelectionChoice, SelectionDraft, SelectionOptions } from '@fanfare-io/fanfare-sdk-core/selections';
1
+ import { SelectionAvailability, SelectionChoice, SelectionDraft, SelectionOptions } from '@fanfare-io/fanfare-sdk-core/selections';
2
2
  import { JSX } from 'solid-js';
3
3
  import { ProductSelectorHandle } from './product-selector';
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
- /** The granted-arm selection props every distribution module threads into its granted panel. */
7
- export interface GrantedPickProps {
8
- grantedSelection?: GrantedSelection;
9
- loadSelectionOptions?: () => Promise<SelectionOptions>;
10
- onSelect?: (choice: SelectionChoice) => Promise<void>;
11
- selectionLockedReason?: "checkout" | "final";
12
- }
13
- /**
14
- * Whether the granted panel can still open a pick surface, which is the only place the panel's
15
- * height cap may be lifted — the Confirm control below an open picker has to stay reachable.
16
- *
17
- * Reads its fields on call, so a module passes its own props object and gets a live answer.
18
- */
19
- export declare function grantedPickReachable(props: GrantedPickProps): boolean;
20
4
  export interface EntrySelectionSurfaceProps {
21
5
  /** Fetch-on-open; must be referentially stable — a new identity re-fetches the catalogue. */
22
6
  loadOptions(): Promise<SelectionOptions>;
@@ -1,20 +1,22 @@
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
- * - "swiss" (default): Prominent display with animated digits and labels above
9
- * - "compact": Simple text-based countdown that inherits parent styling
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
10
9
  *
11
- * The Solid adapter resolves the remaining time on the client, from the device
12
- * clock, because the adapter renders on the client. The React adapter anchors
13
- * to a server-supplied instant because it renders on the server, where a
14
- * device clock is not available and the markup has to match on hydration.
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.
13
+ *
14
+ * With a server-anchored clock in scope (`<FanfareProvider serverNow>`) the
15
+ * remaining time is corrected for device skew; with none it derives from the
16
+ * device clock.
15
17
  */
16
18
  export type CountdownSize = "default" | "hero";
17
- export type CountdownTone = "calm" | "warning" | "critical";
19
+ export type CountdownTone = "calm" | "warning" | "critical" | "auto";
18
20
  export interface CountdownProps {
19
21
  /** Target date/time to count down to */
20
22
  targetDate: Date | string | number;
@@ -32,19 +34,55 @@ export interface CountdownProps {
32
34
  showMinutes?: boolean;
33
35
  /** Show seconds in countdown */
34
36
  showSeconds?: boolean;
35
- /** Layout: "swiss" for prominent animated display, "compact" for simple text */
36
- layout?: "swiss" | "compact";
37
- /** Size: "default" (compact display) or "hero" (52px monospace, urgency-driver). */
37
+ /** Layout: "cells" for a box per unit, "inline" for a single line */
38
+ layout?: "cells" | "inline";
39
+ /** Numeral granularity under `layout="cells"`: one text node per unit, or one box per digit. */
40
+ cells?: "unit" | "digit";
41
+ /**
42
+ * How the time is spelled wherever it is written as one line: the inline
43
+ * layout, the narrow fallback the cells layout falls back to, and — always in
44
+ * `clock` spelling — the string assistive technology is given.
45
+ * `labelled` renders `14m 57s`, with a literal space between units.
46
+ * `clock` renders `02:00` / `1:15:17`, and always carries minutes and seconds
47
+ * whatever `showMinutes` and `showSeconds` say.
48
+ */
49
+ format?: "labelled" | "clock";
50
+ /**
51
+ * Hold the last rendered value. A paused countdown runs no interval, never
52
+ * calls `onComplete` and stops announcing; on resume it re-reads the clock
53
+ * rather than continuing from the held value.
54
+ */
55
+ paused?: boolean;
56
+ /** Size: "default" (compact display) or "hero" (the larger urgency-driver); the two differ only in scale. */
38
57
  size?: CountdownSize;
39
58
  /**
40
- * Presentational urgency tone. Caller derives from phase + time-remaining and passes it.
41
- * - calm: foreground color (default)
42
- * - warning: warning token color
43
- * - critical: danger token color (in retro, also flips the unit container bg)
59
+ * Presentational urgency tone, published as `data-tone` on both layout roots
60
+ * and on each cell, and coloured from the `--ff-countdown-tone-*` tokens.
61
+ * - calm: numeral colour (default)
62
+ * - warning: warning tone colour
63
+ * - critical: critical tone colour (in retro, also flips the unit container bg)
64
+ * - auto: resolved from the time remaining on every tick
44
65
  */
45
66
  tone?: CountdownTone;
46
67
  }
68
+ type TimeRemaining = {
69
+ days: number;
70
+ hours: number;
71
+ minutes: number;
72
+ seconds: number;
73
+ total: number;
74
+ };
75
+ /** Which units the caller allows on screen; a hidden unit rolls into the next shown one. */
76
+ type ShownUnits = {
77
+ days: boolean;
78
+ hours: boolean;
79
+ minutes: boolean;
80
+ seconds: boolean;
81
+ };
82
+ /** Time left on a target, decomposed across the units the caller shows. */
83
+ export declare function calculateTimeRemaining(targetDate: Date | string | number, shown: ShownUnits, nowMs?: number): TimeRemaining;
47
84
  export declare function Countdown(props: CountdownProps): import("solid-js").JSX.Element;
48
85
  export declare namespace Countdown {
49
86
  var displayName: string;
50
87
  }
88
+ export {};
@@ -5,6 +5,11 @@ export interface FanfareProviderProps {
5
5
  sdk: FanfareSDK;
6
6
  locale?: Locale;
7
7
  translations?: PartialTranslationMessages<TranslationMessageKey>;
8
+ /**
9
+ * Server-minted ISO timestamp anchoring time-derived rendering (countdowns),
10
+ * so a skewed device clock doesn't shift the display.
11
+ */
12
+ serverNow?: string;
8
13
  children: JSX.Element;
9
14
  }
10
15
  /**
@@ -9,6 +9,11 @@ export interface FanfareWebComponentProviderProps {
9
9
  autoResume?: boolean;
10
10
  locale?: Locale;
11
11
  translations?: PartialTranslationMessages<TranslationMessageKey>;
12
+ /**
13
+ * Server-minted ISO timestamp anchoring time-derived rendering (countdowns),
14
+ * so a skewed device clock doesn't shift the display.
15
+ */
16
+ serverNow?: string;
12
17
  themeConfig?: BrandTheme | null;
13
18
  variant?: WidgetVariant;
14
19
  className?: string;
@@ -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;
@@ -172,6 +179,17 @@ export interface ExperienceRenderProps {
172
179
  export interface ExperienceWidgetProps {
173
180
  experienceId: string;
174
181
  autoStart?: boolean;
182
+ /**
183
+ * Whether the widget fetches the Google Fonts stylesheets for the families its theme names.
184
+ * Off unless asked: an embed's page owns its own font delivery and its own content policy.
185
+ * The fetch never blocks rendering and a failure is silent.
186
+ */
187
+ loadFonts?: boolean;
188
+ /**
189
+ * Whether the SDK may enter the consumer on arrival at a distribution the merchant set to enter
190
+ * automatically. Omit to keep the default (`true`); pass `false` to keep every entry explicit.
191
+ */
192
+ automaticEntry?: boolean;
175
193
  accessCode?: string;
176
194
  autoEnterWaitlist?: boolean;
177
195
  theme?: BrandTheme;
@@ -201,6 +219,16 @@ export interface ExperienceWidgetProps {
201
219
  /** Called when a Fanfare-managed checkout completes */
202
220
  onFanfareCheckout?: (result: FanfareCheckoutResult) => void;
203
221
  onError?: (error: Error) => void;
222
+ /**
223
+ * Horizontal placement of the widget inside the host's container. The widget is start-aligned
224
+ * unless this is `"center"`.
225
+ */
226
+ align?: "start" | "center";
227
+ /**
228
+ * Explicit override of the widget's adaptive maximum width. Omit to keep the value of
229
+ * the `--ff-widget-max-width` custom property.
230
+ */
231
+ size?: "compact" | "regular" | "wide";
204
232
  class?: string;
205
233
  className?: string;
206
234
  }
@@ -4,6 +4,12 @@ import { MaybeAccessor } from '../utils/to-accessor';
4
4
  export interface ExperienceJourneyOptions {
5
5
  accessCode?: MaybeAccessor<string | undefined>;
6
6
  autoEnterWaitlist?: MaybeAccessor<boolean | undefined>;
7
+ /**
8
+ * Whether core may enter the consumer on the consumer's behalf when routing lands on a
9
+ * distribution the merchant set to enter on arrival. Left unset, core's default (`true`)
10
+ * applies; `false` keeps every entry an explicit one the consumer presses.
11
+ */
12
+ automaticEntry?: MaybeAccessor<boolean | undefined>;
7
13
  }
8
14
  export interface UseExperienceJourneyOptions extends ExperienceJourneyOptions {
9
15
  autoStart?: MaybeAccessor<boolean | undefined>;