@fanfare-io/fanfare-sdk-solid 0.14.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/auth/auth-form.d.ts +2 -1
- package/dist/components/compositions/granted-panel.d.ts +6 -0
- package/dist/components/compositions/journey-gate.d.ts +2 -1
- package/dist/components/internal/appointment-module.d.ts +1 -1
- package/dist/components/internal/auction-ledger.d.ts +51 -0
- package/dist/components/internal/auction-module.d.ts +16 -9
- package/dist/components/internal/auction-pricing.d.ts +68 -0
- package/dist/components/module/outcome-reason.d.ts +1 -2
- package/dist/index.js +4029 -3229
- package/dist/lib/currency.d.ts +19 -6
- package/dist/styles/base.css +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ Solid applications can use `FanfareProvider`, `ExperienceWidget`, and `useExperi
|
|
|
42
42
|
|
|
43
43
|
## Documentation
|
|
44
44
|
|
|
45
|
+
- [Core SDK page observation](https://www.npmjs.com/package/@fanfare-io/fanfare-sdk-core): use `useExperienceJourney` for Solid state and `useSdkEvent` for typed SDK events. For surrounding CSS/non-framework scripts, install core's `createDomBridge` on a stable mounted target and dispose it before destroying the journey or SDK; Solid has no `useFanfareDomBridge` hook.
|
|
45
46
|
- [Web components guide](https://docs.fanfare.io/sdk/components/web-components)
|
|
46
47
|
- [Theming](https://docs.fanfare.io/sdk/components/theming) · [Slots](https://docs.fanfare.io/sdk/components/slots)
|
|
47
48
|
- [SDK overview](https://docs.fanfare.io/sdk/overview)
|
|
@@ -4,7 +4,7 @@ import { AuthInputMode } from './auth-input';
|
|
|
4
4
|
export interface AuthFormProps {
|
|
5
5
|
onSubmit?: (credential: string, type: AuthInputMode) => Promise<void>;
|
|
6
6
|
onVerify?: (otp: string) => Promise<void>;
|
|
7
|
-
onSkip?: () => void
|
|
7
|
+
onSkip?: () => void | Promise<void>;
|
|
8
8
|
onSuccess?: () => void;
|
|
9
9
|
/** Badge color/intent in the panel heading. */
|
|
10
10
|
variant?: PanelHeadingVariant;
|
|
@@ -17,6 +17,7 @@ export interface AuthFormProps {
|
|
|
17
17
|
submitLabel?: string;
|
|
18
18
|
verifyLabel?: string;
|
|
19
19
|
allowSkip?: boolean;
|
|
20
|
+
skipLabel?: string;
|
|
20
21
|
showBranding?: boolean;
|
|
21
22
|
/** Initial step when mounting. Useful for SSR-resume or storybook lanes that need the verify step. */
|
|
22
23
|
defaultStep?: "credential" | "verify";
|
|
@@ -4,6 +4,12 @@ export interface GrantedPanelProps {
|
|
|
4
4
|
fallbackMessage: JSX.Element;
|
|
5
5
|
ctaLabel?: JSX.Element;
|
|
6
6
|
expiresAt?: Date;
|
|
7
|
+
/**
|
|
8
|
+
* A fact the grant settles at — a winning bid, a clearing price — rendered under the countdown
|
|
9
|
+
* and beside the fallback message. Omitted when the amount is not known: a figure beside a
|
|
10
|
+
* payment countdown states what the consumer owes, so a synthesised one is worse than none.
|
|
11
|
+
*/
|
|
12
|
+
detail?: JSX.Element;
|
|
7
13
|
onCtaClick?: () => void;
|
|
8
14
|
class?: string;
|
|
9
15
|
className?: string;
|
|
@@ -5,11 +5,12 @@ export interface JourneyGateProps {
|
|
|
5
5
|
stage: JourneyGateStage;
|
|
6
6
|
onAuthSubmit?: (credential: string, type: AuthInputMode) => Promise<void>;
|
|
7
7
|
onAuthVerify?: (otp: string) => Promise<void>;
|
|
8
|
-
onAuthSkip?: () => void
|
|
8
|
+
onAuthSkip?: () => void | Promise<void>;
|
|
9
9
|
onAuthSuccess?: () => void;
|
|
10
10
|
onAccessCodeSubmit?: (code: string) => Promise<void>;
|
|
11
11
|
onAccessCodeSkip?: () => void;
|
|
12
12
|
allowAuthSkip?: boolean;
|
|
13
|
+
authSkipLabel?: string;
|
|
13
14
|
allowAccessCodeSkip?: boolean;
|
|
14
15
|
authTitle?: string;
|
|
15
16
|
authDescription?: string;
|
|
@@ -10,7 +10,7 @@ export interface AppointmentModuleProps {
|
|
|
10
10
|
timezone?: string;
|
|
11
11
|
defaultLocationId?: string;
|
|
12
12
|
onBook: (slotId: string, locationId?: string) => Promise<void>;
|
|
13
|
-
onCancel: (
|
|
13
|
+
onCancel: () => Promise<void>;
|
|
14
14
|
onReschedule: (newSlotId: string, newLocationId?: string) => Promise<void>;
|
|
15
15
|
isBooking: boolean;
|
|
16
16
|
isCancelling: boolean;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Accessor, JSX } from 'solid-js';
|
|
2
|
+
export type LedgerTone = "default" | "muted" | "live" | "danger" | "success";
|
|
3
|
+
export interface LedgerRowProps {
|
|
4
|
+
/** Decorative leading glyph; the label carries the row's meaning for assistive technology. */
|
|
5
|
+
marker?: string;
|
|
6
|
+
label: JSX.Element;
|
|
7
|
+
value: JSX.Element;
|
|
8
|
+
tone?: LedgerTone;
|
|
9
|
+
/** Renders the value struck through — a bid that has been beaten, a price already passed. */
|
|
10
|
+
struck?: boolean;
|
|
11
|
+
class?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function LedgerRow(props: LedgerRowProps): JSX.Element;
|
|
14
|
+
export declare namespace LedgerRow {
|
|
15
|
+
var displayName: string;
|
|
16
|
+
}
|
|
17
|
+
/** A row whose value has not arrived yet: the label stands, the figure is a placeholder. */
|
|
18
|
+
export declare function LedgerSkeletonRow(props: {
|
|
19
|
+
label: JSX.Element;
|
|
20
|
+
}): JSX.Element;
|
|
21
|
+
export declare namespace LedgerSkeletonRow {
|
|
22
|
+
var displayName: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function Ledger(props: {
|
|
25
|
+
children: JSX.Element;
|
|
26
|
+
class?: string;
|
|
27
|
+
}): JSX.Element;
|
|
28
|
+
export declare namespace Ledger {
|
|
29
|
+
var displayName: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Discrete unit pips for a Dutch remaining count, at the wide adaptation only.
|
|
33
|
+
*
|
|
34
|
+
* The pips are decorative; the grid states the count once in its own label so a screen reader
|
|
35
|
+
* hears "7 of 20 units remaining" rather than twenty unlabelled cells.
|
|
36
|
+
*/
|
|
37
|
+
export declare function UnitPips(props: {
|
|
38
|
+
remaining: number;
|
|
39
|
+
total: number;
|
|
40
|
+
label: string;
|
|
41
|
+
}): JSX.Element;
|
|
42
|
+
export declare namespace UnitPips {
|
|
43
|
+
var displayName: string;
|
|
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,24 +1,31 @@
|
|
|
1
|
+
import { AuctionBidInput, AuctionConsumerStatus } from '@fanfare-io/fanfare-sdk-core/auctions';
|
|
1
2
|
import { AuctionDisplayState } from '@fanfare-io/fanfare-sdk-core/internals';
|
|
2
3
|
import { ReadableAtom } from 'nanostores';
|
|
3
4
|
import { OutcomeAction } from '../compositions/outcome-panel';
|
|
4
5
|
import { OutcomeReason } from '../module';
|
|
5
6
|
export interface AuctionModuleProps {
|
|
6
7
|
display$?: ReadableAtom<AuctionDisplayState>;
|
|
7
|
-
fallbackState?: AuctionDisplayState;
|
|
8
8
|
sequencePhase: "enterable" | "participating" | "settling" | "granted" | "ended";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
isLeaving: boolean;
|
|
9
|
+
/** Place a bid. English sends `{ amount }`; Dutch clinches at the shown price and sends `{}`. */
|
|
10
|
+
onBid?: (input: AuctionBidInput) => Promise<void>;
|
|
11
|
+
/** This consumer's own bid, which the live display state does not carry. */
|
|
12
|
+
yourBid?: string;
|
|
13
|
+
/** This consumer's own standing, which the live display state carries only as a loose string. */
|
|
14
|
+
yourStatus?: AuctionConsumerStatus;
|
|
16
15
|
countdownTo?: Date;
|
|
17
|
-
|
|
16
|
+
/** Currency code for money display; the live display state's own code wins when present. */
|
|
18
17
|
currencyCode?: string;
|
|
18
|
+
/** Locale for currency formatting */
|
|
19
19
|
locale?: string;
|
|
20
20
|
grant?: string;
|
|
21
21
|
expiresAt?: number | Date;
|
|
22
|
+
/** The amount this win settles at, shown beside the payment countdown. */
|
|
23
|
+
wonAmount?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Which mechanism settled. The granted frame has no display atom to read the pricing model
|
|
26
|
+
* from, and a Dutch consumer bought at a posted price rather than winning a contest.
|
|
27
|
+
*/
|
|
28
|
+
auctionType?: "english" | "dutch";
|
|
22
29
|
checkoutUrl?: string;
|
|
23
30
|
onCheckoutClick?: () => void;
|
|
24
31
|
outcomeReason?: OutcomeReason;
|
|
@@ -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;
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
* completed / already_completed -> completed (a success terminal, not a loss)
|
|
22
22
|
* won -> won
|
|
23
23
|
* cancelled -> cancelled
|
|
24
|
-
* no_show -> no_show
|
|
25
24
|
* left -> left (voluntary exit: leave/withdraw)
|
|
26
25
|
* closed / unknown / other -> ended
|
|
27
26
|
*
|
|
@@ -32,7 +31,7 @@
|
|
|
32
31
|
* Static story lanes pass UI values directly (e.g. `"outbid"`); those
|
|
33
32
|
* pass through unchanged.
|
|
34
33
|
*/
|
|
35
|
-
export type OutcomeReason = "expired" | "not_selected" | "sold_out" | "outbid" | "floor_unsold" | "reserve_not_met" | "completed" | "won" | "cancelled" | "
|
|
34
|
+
export type OutcomeReason = "expired" | "not_selected" | "sold_out" | "outbid" | "floor_unsold" | "reserve_not_met" | "completed" | "won" | "cancelled" | "left" | "ended";
|
|
36
35
|
export declare function normalizeOutcomeReason(reason: string | undefined): OutcomeReason;
|
|
37
36
|
export declare function normalizeSequenceOutcomeReason(outcome: {
|
|
38
37
|
type: string;
|