@fanfare-io/fanfare-sdk-react 0.15.0 → 0.16.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 +1 -0
- package/dist/components/compositions/granted-panel.d.ts +7 -1
- package/dist/components/widgets/internal/auction-ledger.d.ts +62 -0
- package/dist/components/widgets/internal/auction-module.d.ts +17 -11
- package/dist/components/widgets/internal/auction-pricing.d.ts +68 -0
- package/dist/hooks/use-fanfare-dom-bridge.d.ts +3 -4
- package/dist/index-ClkQNeuF.js +6533 -0
- package/dist/index.js +1 -1
- package/dist/lib/currency.d.ts +19 -6
- package/dist/{stripe-card-field-Q-8h4lM_.js → stripe-card-field-BJCuc3nV.js} +1 -1
- package/dist/styles/base.css +1 -1
- package/package.json +6 -6
- package/dist/index-CpSKWCNw.js +0 -6062
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ The displayed copy is **always SDK-owned i18n** (localized via your `FanfareProv
|
|
|
62
62
|
|
|
63
63
|
## Documentation
|
|
64
64
|
|
|
65
|
+
- [Core SDK page observation](https://www.npmjs.com/package/@fanfare-io/fanfare-sdk-core): use `useExperienceJourney` for React state and `useSdkEvent` for typed SDK events. `useFanfareDomBridge` is for surrounding CSS/non-framework scripts, not a replacement state hook; give it an already-mounted, stable target. It stamps without an initial event and disposes on unmount; remount it to change targets.
|
|
65
66
|
- [React components guide](https://docs.fanfare.io/sdk/components/react)
|
|
66
67
|
- [Theming](https://docs.fanfare.io/sdk/components/theming) · [Slots](https://docs.fanfare.io/sdk/components/slots)
|
|
67
68
|
- [Next.js / SSR integration](https://docs.fanfare.io/guides/integration-patterns/ssr-integration)
|
|
@@ -31,10 +31,16 @@ export interface GrantedPanelProps {
|
|
|
31
31
|
fallbackMessage: React.ReactNode;
|
|
32
32
|
ctaLabel?: React.ReactNode;
|
|
33
33
|
expiresAt?: Date;
|
|
34
|
+
/**
|
|
35
|
+
* A fact the grant settles at — a winning bid, a clearing price — rendered under the countdown
|
|
36
|
+
* and beside the fallback message. Omitted when the amount is not known: a figure beside a
|
|
37
|
+
* payment countdown states what the consumer owes, so a synthesised one is worse than none.
|
|
38
|
+
*/
|
|
39
|
+
detail?: React.ReactNode;
|
|
34
40
|
onCtaClick?: () => void;
|
|
35
41
|
className?: string;
|
|
36
42
|
}
|
|
37
|
-
export declare function GrantedPanel({ label, fallbackMessage, ctaLabel, expiresAt, onCtaClick, className, }: GrantedPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare function GrantedPanel({ label, fallbackMessage, ctaLabel, expiresAt, detail, onCtaClick, className, }: GrantedPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
38
44
|
export declare namespace GrantedPanel {
|
|
39
45
|
var displayName: string;
|
|
40
46
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The auction ledger: label/value rows whose value column holds one x-position across every state.
|
|
3
|
+
*
|
|
4
|
+
* The panel carries phase in row order and in a leading marker glyph rather than in a hero number,
|
|
5
|
+
* so an amount never moves between states and a consumer comparing two moments compares the same
|
|
6
|
+
* column. The marker is decorative — every row states its meaning in its label.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
export type LedgerTone = "default" | "muted" | "live" | "danger" | "success";
|
|
10
|
+
export interface LedgerRowProps {
|
|
11
|
+
/** Decorative leading glyph; the label carries the row's meaning for assistive technology. */
|
|
12
|
+
marker?: string;
|
|
13
|
+
label: React.ReactNode;
|
|
14
|
+
value: React.ReactNode;
|
|
15
|
+
tone?: LedgerTone;
|
|
16
|
+
/** Renders the value struck through — a bid that has been beaten, a price already passed. */
|
|
17
|
+
struck?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function LedgerRow({ marker, label, value, tone, struck, className }: LedgerRowProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare namespace LedgerRow {
|
|
22
|
+
var displayName: string;
|
|
23
|
+
}
|
|
24
|
+
/** A row whose value has not arrived yet: the label stands, the figure is a placeholder. */
|
|
25
|
+
export declare function LedgerSkeletonRow({ label }: {
|
|
26
|
+
label: React.ReactNode;
|
|
27
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare namespace LedgerSkeletonRow {
|
|
29
|
+
var displayName: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function Ledger({ children, className }: {
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
className?: string;
|
|
34
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare namespace Ledger {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Discrete unit pips for a Dutch remaining count, at the wide adaptation only.
|
|
40
|
+
*
|
|
41
|
+
* The pips are decorative; the grid states the count once in its own label so a screen reader
|
|
42
|
+
* hears "7 of 20 units remaining" rather than twenty unlabelled cells.
|
|
43
|
+
*/
|
|
44
|
+
export declare function UnitPips({ remaining, total, label }: {
|
|
45
|
+
remaining: number;
|
|
46
|
+
total: number;
|
|
47
|
+
label: string;
|
|
48
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
49
|
+
export declare namespace UnitPips {
|
|
50
|
+
var displayName: string;
|
|
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,26 +1,32 @@
|
|
|
1
|
+
import { AuctionBidInput } from '@fanfare-io/fanfare-sdk-core/auctions';
|
|
2
|
+
import { AuctionConsumerStatus } from '@fanfare-io/fanfare-sdk-core/experiences';
|
|
1
3
|
import { AuctionDisplayState } from '@fanfare-io/fanfare-sdk-core/internals';
|
|
2
4
|
import { ReadableAtom } from 'nanostores';
|
|
3
5
|
import { OutcomeAction } from '../../compositions/outcome-panel';
|
|
4
6
|
import { OutcomeReason } from '../../module';
|
|
5
7
|
export interface AuctionModuleProps {
|
|
6
8
|
display$?: ReadableAtom<AuctionDisplayState>;
|
|
7
|
-
fallbackState?: AuctionDisplayState;
|
|
8
9
|
sequencePhase: "enterable" | "participating" | "settling" | "granted" | "ended";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
isLeaving: boolean;
|
|
10
|
+
/** Place a bid. English sends `{ amount }`; Dutch clinches at the shown price and sends `{}`. */
|
|
11
|
+
onBid?: (input: AuctionBidInput) => Promise<void>;
|
|
12
|
+
/** This consumer's own bid, which the live display state does not carry. */
|
|
13
|
+
yourBid?: string;
|
|
14
|
+
/** This consumer's own standing, which the live display state carries only as a loose string. */
|
|
15
|
+
yourStatus?: AuctionConsumerStatus;
|
|
16
16
|
countdownTo?: Date;
|
|
17
|
-
|
|
18
|
-
/** Currency code for bid display (overridden by displayState.currencyCode if present) */
|
|
17
|
+
/** Currency code for money display; the live display state's own code wins when present. */
|
|
19
18
|
currencyCode?: string;
|
|
20
19
|
/** Locale for currency formatting */
|
|
21
20
|
locale?: string;
|
|
22
21
|
grant?: string;
|
|
23
22
|
expiresAt?: number | Date;
|
|
23
|
+
/** The amount this win settles at, shown beside the payment countdown. */
|
|
24
|
+
wonAmount?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Which mechanism settled. The granted frame has no display atom to read the pricing model
|
|
27
|
+
* from, and a Dutch consumer bought at a posted price rather than winning a contest.
|
|
28
|
+
*/
|
|
29
|
+
auctionType?: "english" | "dutch";
|
|
24
30
|
checkoutUrl?: string;
|
|
25
31
|
onCheckoutClick?: () => void;
|
|
26
32
|
outcomeReason?: OutcomeReason;
|
|
@@ -30,7 +36,7 @@ export interface AuctionModuleProps {
|
|
|
30
36
|
isReentering?: boolean;
|
|
31
37
|
className?: string;
|
|
32
38
|
}
|
|
33
|
-
export declare function AuctionModule(
|
|
39
|
+
export declare function AuctionModule(props: AuctionModuleProps): import("react/jsx-runtime").JSX.Element;
|
|
34
40
|
export declare namespace AuctionModule {
|
|
35
41
|
var displayName: string;
|
|
36
42
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AuctionDisplayState } from '@fanfare-io/fanfare-sdk-core/internals';
|
|
2
|
+
/** The live price model, reached through the display state rather than a separate core export. */
|
|
3
|
+
export type AuctionPricing = NonNullable<AuctionDisplayState["pricing"]>;
|
|
4
|
+
export type EnglishPricing = Extract<AuctionPricing, {
|
|
5
|
+
model: "english";
|
|
6
|
+
}>;
|
|
7
|
+
export type DutchPricing = Extract<AuctionPricing, {
|
|
8
|
+
model: "dutch";
|
|
9
|
+
}>;
|
|
10
|
+
/** True when a string is a money value the panel may compute with. */
|
|
11
|
+
export declare function isWireMoney(value: string | undefined): value is string;
|
|
12
|
+
/**
|
|
13
|
+
* Reads a typed amount as a wire money string, or `null` when it is not one.
|
|
14
|
+
*
|
|
15
|
+
* A consumer types the separators their keyboard and locale give them — `245,00` across most of
|
|
16
|
+
* Europe, `1,234.50` or `1 234,50` with grouping — and a bid that is refused as below the minimum
|
|
17
|
+
* because of a comma is a bid the auction lost for no reason. Grouping is dropped and the decimal
|
|
18
|
+
* separator is read from position. Exponent notation is refused rather than expanded: `1e5` is not
|
|
19
|
+
* an amount anyone means to bid.
|
|
20
|
+
*
|
|
21
|
+
* `digits` is the currency's fraction digits, which decide what a lone comma before exactly three
|
|
22
|
+
* digits means: grouping in a two-digit currency, the decimal in a three-digit one, where reading
|
|
23
|
+
* it as grouping would multiply the bid a thousandfold.
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeAmountInput(raw: string, digits?: number): string | null;
|
|
26
|
+
/** Orders two wire money strings exactly at the eight-digit wire scale. */
|
|
27
|
+
export declare function compareMoney(left: string, right: string, _digits: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Moves `base` by `steps` whole increments, never below `floor`.
|
|
30
|
+
*
|
|
31
|
+
* The stepper and the quick-pick chips are the same operation at different step counts, so they
|
|
32
|
+
* cannot disagree about what one increment is worth.
|
|
33
|
+
*/
|
|
34
|
+
export declare function stepAmount(base: string, increment: string, steps: number, digits: number, floor?: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* True when `amount` is more than ten increments above the minimum next bid. The comparison stays
|
|
37
|
+
* in minor units so a threshold past the wire money width cannot fail validation.
|
|
38
|
+
*/
|
|
39
|
+
export declare function exceedsObligationThreshold(amount: string, minNextBid: string, increment: string): boolean;
|
|
40
|
+
/** One rung of the Dutch descent, in the order it is rendered. */
|
|
41
|
+
export interface DutchLadder {
|
|
42
|
+
/** The price the ladder started from, when it is not also the live price. */
|
|
43
|
+
start?: string;
|
|
44
|
+
/** Prices the ladder has already passed, newest last. */
|
|
45
|
+
passed: string[];
|
|
46
|
+
/** The price a clinch would pay right now. */
|
|
47
|
+
current: string;
|
|
48
|
+
/** The price the next drop lands on, when another drop is still coming. */
|
|
49
|
+
next?: string;
|
|
50
|
+
/** The price the ladder never falls below, when one is configured. */
|
|
51
|
+
floor?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Derives the descent from the ladder configuration and the live price.
|
|
55
|
+
*
|
|
56
|
+
* No drop history crosses the wire, so the passed rungs are recomputed as `startPrice − k × drop`
|
|
57
|
+
* down to the live price. Returns `null` when the configuration needed to draw the ladder is
|
|
58
|
+
* absent: the rows that survive are the ones the server actually stated.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildDutchLadder(pricing: DutchPricing, digits: number): DutchLadder | null;
|
|
61
|
+
/**
|
|
62
|
+
* Whether a Dutch clinch may be offered at all.
|
|
63
|
+
*
|
|
64
|
+
* Three independent gates, each of which alone makes the buy button a lie: Dutch never enters
|
|
65
|
+
* `participating` or `settling`, so the phase must still be `enterable`; a sold-out auction has no
|
|
66
|
+
* unit to sell; and `ended` closes the mechanism whatever the price says.
|
|
67
|
+
*/
|
|
68
|
+
export declare function canClinch(pricing: DutchPricing, sequencePhase: string): boolean;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mirrors one journey into a stable DOM target.
|
|
3
3
|
*
|
|
4
|
-
* The bridge latches `data-fanfare-
|
|
5
|
-
* `data-fanfare-
|
|
6
|
-
* `data-fanfare-expires-at`, and `data-fanfare-outcome` on `opts.target`,
|
|
4
|
+
* The bridge latches `data-fanfare-experience-id`, `data-fanfare-stage`,
|
|
5
|
+
* `data-fanfare-phase`, `data-fanfare-mechanism`, and `data-fanfare-expires-at` on `opts.target`,
|
|
7
6
|
* defaulting to `document.documentElement`, and dispatches `fanfare:state-change`
|
|
8
|
-
* on that same element.
|
|
7
|
+
* on that same element. Version and queue position are event-only, and a terminal outcome
|
|
9
8
|
* crosses as its type alone — the free-text qualifier that may accompany one
|
|
10
9
|
* stays on the typed SDK surface.
|
|
11
10
|
* Installation happens in an effect, so the first paint can be unbridged;
|