@fanfare-io/fanfare-sdk-react 0.17.0 → 0.19.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.
@@ -1,5 +1,8 @@
1
+ import { ClaimableSettlement, PreAuthSettlement } from '@fanfare-io/fanfare-sdk-core/experiences';
1
2
  import { TimedReleaseDisplayState } from '@fanfare-io/fanfare-sdk-core/internals';
3
+ import { GrantedSelection, SelectionAvailability, SelectionChoice, SelectionDraft, SelectionOptions } from '@fanfare-io/fanfare-sdk-core/selections';
2
4
  import { ReadableAtom } from 'nanostores';
5
+ import { SelectionCheckoutDetails } from '../../../lib/selection-display';
3
6
  import { OutcomeAction } from '../../compositions/outcome-panel';
4
7
  import { OutcomeReason } from '../../module';
5
8
  export interface TimedReleaseModuleProps {
@@ -7,14 +10,41 @@ export interface TimedReleaseModuleProps {
7
10
  sequencePhase: "enterable" | "participating" | "granted" | "ended";
8
11
  canEnter: boolean;
9
12
  canLeave: boolean;
10
- onEnter: () => Promise<void>;
13
+ onEnter: (selection?: SelectionChoice) => Promise<void>;
11
14
  onLeave: () => Promise<void>;
12
15
  onComplete?: () => Promise<void>;
13
16
  isEntering: boolean;
14
17
  isLeaving: boolean;
15
18
  countdownTo?: Date;
16
19
  checkoutUrl?: string;
17
- onCheckoutClick?: () => void;
20
+ /** Override checkout click handler (granted); carries the pair the grant resolved to. */
21
+ /**
22
+ * Activating the checkout CTA. Receives the pick the grant settled on, with the catalogue
23
+ * objects behind it, whenever the panel has loaded the catalogue that carries them.
24
+ */
25
+ onCheckoutClick?: (details?: SelectionCheckoutDetails) => void | Promise<void>;
26
+ /** The release captures a product choice at entry, so the entry branch renders the picker. */
27
+ selectionRequired?: boolean;
28
+ /** Bound by the widget against the journey; must be referentially stable. */
29
+ loadSelectionOptions?: () => Promise<SelectionOptions>;
30
+ /** The choice already recorded for this entry. */
31
+ recordedSelection?: SelectionChoice | null;
32
+ /** Live availability of the recorded pick. */
33
+ selectionAvailability?: SelectionAvailability;
34
+ /** Granted-state selection arm; a release resolves or awaits an assignment, never requires a pick. */
35
+ grantedSelection?: GrantedSelection;
36
+ /** How the win settles; selects the granted confirm label and payment affordance. */
37
+ settlement?: ClaimableSettlement | PreAuthSettlement;
38
+ /** Submits the granted pick or re-pick. */
39
+ onSelect?: (choice: SelectionChoice) => Promise<void>;
40
+ /** Locked copy for a resolved granted summary; "checkout" once checkout has started. */
41
+ selectionLockedReason?: "checkout" | "final";
42
+ /** Already-translated selection failure from the widget, rendered beside the acting control. */
43
+ selectError?: string | null;
44
+ /** Every local pick-surface transition, product-only drafts included; feeds the page-bridge event. */
45
+ onDraftChange?: (draft: SelectionDraft) => void;
46
+ /** The terminal was reached because the stock ran out, not because this entrant lost. */
47
+ stockDenied?: boolean;
18
48
  grant?: string;
19
49
  expiresAt?: number | Date;
20
50
  outcomeReason?: OutcomeReason;
@@ -24,7 +54,7 @@ export interface TimedReleaseModuleProps {
24
54
  isReentering?: boolean;
25
55
  className?: string;
26
56
  }
27
- export declare function TimedReleaseModule({ display$, sequencePhase, canEnter, canLeave, onEnter, onLeave, onComplete, isEntering, isLeaving, countdownTo, checkoutUrl, onCheckoutClick, grant: _grant, expiresAt, outcomeReason, outcomeAction, onReenter, isReentering, className, }: TimedReleaseModuleProps): import("react/jsx-runtime").JSX.Element | null;
57
+ export declare function TimedReleaseModule({ display$, sequencePhase, canEnter, canLeave, onEnter, onLeave, onComplete, isEntering, isLeaving, countdownTo, checkoutUrl, onCheckoutClick, grant: _grant, expiresAt, outcomeReason, outcomeAction, onReenter, isReentering, className, selectionRequired, loadSelectionOptions, recordedSelection, selectionAvailability, grantedSelection, settlement, onSelect, selectionLockedReason, selectError, stockDenied, onDraftChange, }: TimedReleaseModuleProps): import("react/jsx-runtime").JSX.Element | null;
28
58
  export declare namespace TimedReleaseModule {
29
59
  var displayName: string;
30
60
  }
@@ -0,0 +1,22 @@
1
+ import { SelectionOptions } from '@fanfare-io/fanfare-sdk-core/selections';
2
+ export interface UseSelectionOptionsResult {
3
+ options: SelectionOptions | null;
4
+ isLoading: boolean;
5
+ error: Error | null;
6
+ /** Re-fetch; used by the sold-out auto-refetch and the handle's refresh(). */
7
+ refresh(): Promise<void>;
8
+ }
9
+ /**
10
+ * Fetches a selection catalogue on demand, once per loader identity.
11
+ *
12
+ * Nothing is cached across mounts, persisted, or deduped between callers: a
13
+ * catalogue carries live availability, so a second consumer of a stale copy would
14
+ * be shown a pick that is already gone. The hook never polls.
15
+ *
16
+ * A refetch keeps the previously loaded catalogue in `options` so the caller can
17
+ * hold its rendered grid rather than flashing back to a skeleton, and a standing
18
+ * `error` survives until the retry settles so the failure view does not flash the
19
+ * stale grid on its way back. Resolutions and rejections from a superseded
20
+ * request, or from one still in flight after unmount, are dropped.
21
+ */
22
+ export declare function useSelectionOptions(load: (() => Promise<SelectionOptions>) | undefined): UseSelectionOptionsResult;