@fanfare-io/fanfare-sdk-react 0.1.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fanfare-io/fanfare-sdk-react",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "React adapter for Fanfare SDK",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",
@@ -17,7 +17,6 @@
17
17
  "type": "module",
18
18
  "files": [
19
19
  "dist/",
20
- "docs/",
21
20
  "README.md"
22
21
  ],
23
22
  "module": "./dist/index.js",
@@ -44,8 +43,8 @@
44
43
  "nanostores": "^1.1.0",
45
44
  "tailwind-merge": "^2.6.0",
46
45
  "valibot": "^1.1.0",
47
- "@fanfare-io/fanfare-sdk-core": "0.1.0",
48
- "@fanfare-io/fanfare-sdk-i18n": "0.1.0"
46
+ "@fanfare-io/fanfare-sdk-core": "0.3.0",
47
+ "@fanfare-io/fanfare-sdk-i18n": "0.3.0"
49
48
  },
50
49
  "devDependencies": {
51
50
  "@iconify-json/heroicons": "^1.2.3",
@@ -89,8 +88,8 @@
89
88
  "vite-plugin-dts": "^4.5.4",
90
89
  "vite-tsconfig-paths": "^5.1.4",
91
90
  "vitest": "^3.2.4",
92
- "@fanfare-io/fanfare-sdk-core": "0.1.0",
93
- "@fanfare-io/fanfare-sdk-solid": "0.1.0"
91
+ "@fanfare-io/fanfare-sdk-core": "0.3.0",
92
+ "@fanfare-io/fanfare-sdk-solid": "0.3.0"
94
93
  },
95
94
  "sideEffects": [
96
95
  "**/*.css"
@@ -125,7 +124,7 @@
125
124
  "scripts": {
126
125
  "prebuild": "rimraf dist && pnpm -F @fanfare-io/fanfare-sdk-i18n build:deps && pnpm -F @fanfare-io/fanfare-sdk-core build:deps",
127
126
  "pretest": "pnpm -F @fanfare-io/fanfare-sdk-i18n build:deps && pnpm -F @fanfare-io/fanfare-sdk-core build:deps && pnpm -F @fanfare-io/fanfare-sdk-solid build:incremental",
128
- "build": "vite build && tailwindcss -i src/styles/base.css -o dist/styles/base.css && pnpm size",
127
+ "build": "vite build && tailwindcss -i src/styles/base.css -o dist/styles/base.css --minify && pnpm size",
129
128
  "build:incremental": "vite build --emptyOutDir false",
130
129
  "build:strict": "pnpm typecheck && pnpm build",
131
130
  "build-storybook": "storybook build",
@@ -1,38 +0,0 @@
1
- /**
2
- * AuctionActions Component
3
- *
4
- * Bid form and action buttons for auction operations.
5
- */
6
- export type AuctionStatus = "open" | "bidding" | "winning" | "outbid" | "won" | "lost" | "ended";
7
- export interface AuctionActionsProps {
8
- /** Current auction status */
9
- status: AuctionStatus;
10
- /** Current highest bid */
11
- currentBid: number;
12
- /** Minimum next bid */
13
- minNextBid: number;
14
- /** Bid increment */
15
- bidIncrement: number;
16
- /** Place bid handler */
17
- onBid?: (amount: number) => void;
18
- /** Proceed to checkout handler (for won status) */
19
- onProceed?: () => void;
20
- /** Whether bid is in progress */
21
- isBidding?: boolean;
22
- /** Bid button label */
23
- bidLabel?: string;
24
- /** Proceed button label */
25
- proceedLabel?: string;
26
- /** Currency code (ISO 4217). */
27
- currencyCode?: string;
28
- /** Locale used for formatting */
29
- locale?: string;
30
- /** Show quick bid buttons */
31
- showQuickBids?: boolean;
32
- /** Additional class name */
33
- className?: string;
34
- }
35
- export declare function AuctionActions({ status, currentBid, minNextBid, bidIncrement, onBid, onProceed, isBidding, bidLabel, proceedLabel, currencyCode, locale, showQuickBids, className, }: AuctionActionsProps): import("react/jsx-runtime").JSX.Element;
36
- export declare namespace AuctionActions {
37
- var displayName: string;
38
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * AuctionBidDisplay Component
3
- *
4
- * Displays the current bid amount and auction status.
5
- */
6
- export interface AuctionBidDisplayProps {
7
- /** Current highest bid */
8
- currentBid: number;
9
- /** User's bid (if any) */
10
- myBid?: number | null;
11
- /** Minimum next bid */
12
- minNextBid: number;
13
- /** Bid increment */
14
- bidIncrement: number;
15
- /** Reserve price */
16
- reservePrice?: number;
17
- /** Whether reserve is met */
18
- reserveMet?: boolean;
19
- /** Total number of bids */
20
- bidCount?: number;
21
- /** Whether the user is winning */
22
- isWinning?: boolean;
23
- /** Currency code (ISO 4217). */
24
- currencyCode?: string;
25
- /** Locale used for formatting */
26
- locale?: string;
27
- /** Visual size */
28
- size?: "sm" | "md" | "lg";
29
- /** Additional class name */
30
- className?: string;
31
- }
32
- export declare function AuctionBidDisplay({ currentBid, myBid, minNextBid, bidIncrement, reservePrice, reserveMet, bidCount, isWinning, currencyCode, locale, size, className, }: AuctionBidDisplayProps): import("react/jsx-runtime").JSX.Element;
33
- export declare namespace AuctionBidDisplay {
34
- var displayName: string;
35
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Auction Widget Internal Components
3
- *
4
- * Building blocks for the AuctionWidget.
5
- */
6
- export { AuctionActions, type AuctionActionsProps, type AuctionStatus } from './auction-actions';
7
- export { AuctionBidDisplay, type AuctionBidDisplayProps } from './auction-bid-display';
@@ -1,40 +0,0 @@
1
- /**
2
- * WaitlistActions Component
3
- *
4
- * Action buttons for waitlist operations (enter, leave, share).
5
- */
6
- export type WaitlistStatus = "available" | "entered" | "opening" | "opened";
7
- export interface WaitlistActionsProps {
8
- /** Current waitlist status */
9
- status: WaitlistStatus;
10
- /** Enter waitlist handler */
11
- onEnter?: () => void;
12
- /** Leave waitlist handler */
13
- onLeave?: () => void;
14
- /** Share position handler */
15
- onShare?: () => void;
16
- /** Proceed handler (when opened) */
17
- onProceed?: () => void;
18
- /** Whether enter is in progress */
19
- isEntering?: boolean;
20
- /** Whether leave is in progress */
21
- isLeaving?: boolean;
22
- /** Enter button label */
23
- enterLabel?: string;
24
- /** Leave button label */
25
- leaveLabel?: string;
26
- /** Share button label */
27
- shareLabel?: string;
28
- /** Proceed button label */
29
- proceedLabel?: string;
30
- /** Show share button */
31
- showShare?: boolean;
32
- /** Layout direction */
33
- layout?: "horizontal" | "vertical";
34
- /** Additional class name */
35
- className?: string;
36
- }
37
- export declare function WaitlistActions({ status, onEnter, onLeave, onShare, onProceed, isEntering, isLeaving, enterLabel, leaveLabel, shareLabel, proceedLabel, showShare, layout, className, }: WaitlistActionsProps): import("react/jsx-runtime").JSX.Element;
38
- export declare namespace WaitlistActions {
39
- var displayName: string;
40
- }
package/docs/SLOTS.md DELETED
@@ -1,89 +0,0 @@
1
- # ExperienceWidget Slots
2
-
3
- `ExperienceWidget` slots are render props for targeted UI overrides. Each slot is called only when the matching journey or sequence state is active; all other states keep the default Fanfare UI.
4
-
5
- The slot surface is derived from the same model as `JourneyView`: `journeyStage` -> `sequence.phase` -> `sequence.mechanism`. Actions are not serialized as a separate source of truth, and the server stays authoritative over what is permitted.
6
-
7
- Use `children` or `useExperienceJourney` when you need to replace the full widget. Use `slots` when the default flow is correct and a specific state needs custom UI.
8
-
9
- ## Shared Props
10
-
11
- Every slot receives:
12
-
13
- - `snapshot`: the current `JourneySnapshot | null`.
14
- - `view`: the current `JourneyView | null`.
15
- - `error`: the current widget error string, or `null`.
16
-
17
- ## Journey Slots
18
-
19
- | Slot | Meaningful state | Extra props |
20
- | ------------ | ------------------------------------------------------------- | --------------------------------------------------------- |
21
- | `start` | `journeyStage: "ready"` | `onStart`, `isStarting` |
22
- | `loading` | `journeyStage: "routing"`, gated loading, or fallback loading | `message?` |
23
- | `auth` | `journeyStage: "gated"` with an auth gate | `onSubmit`, `onVerify`, `onSkip?` |
24
- | `accessCode` | `journeyStage: "gated"` with an access-code gate | `onSubmit`, `onSkip?` |
25
- | `challenge` | `journeyStage: "gated"` with a bot-check gate | `challenge`, `botMitigation?`, `onVerifyToken`, `onRetry` |
26
- | `error` | Widget action or loading error | `error`, `onRetry` |
27
-
28
- ## Routed Sequence Slots
29
-
30
- | Slot | Meaningful state | Mechanisms | Extra props |
31
- | --------------- | ----------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------ |
32
- | `upcoming` | `phase: "scheduled"` | `queue`, `draw`, `auction`, `timed_release`, `appointment` | `startsAt?`, `canEnter`, `onEnter`, `isEntering` |
33
- | `upcoming` | `phase: "enterable"` | `waitlist` | `startsAt?`, `canEnter`, `onEnter`, `isEntering` |
34
- | `waitlist` | `phase: "participating"` | `waitlist` | `startsAt?`, `onLeave`, `isLeaving` |
35
- | `enterable` | `phase: "enterable"` | `queue`, `draw`, `auction`, `timed_release`, `appointment` | `sequence`, `participationType` |
36
- | `participating` | `phase: "participating"` | `queue`, `draw`, `auction`, `timed_release`, `appointment` | `sequence`, `participationType`, `position?` |
37
- | `granted` | `phase: "granted"` | `queue`, `draw`, `auction`, `timed_release` | `sequence`, `grant?`, `expiresAt?` |
38
- | `expired` | `phase: "ended"` with `outcome.type: "expired"` | any ended mechanism | `reason`, `endedAt?` |
39
- | `ended` | `phase: "unavailable"` or `phase: "ended"` | any ended mechanism | `reason`, `endedAt?` |
40
-
41
- There is no slot for `phase: "settling"`; `draw` and `auction` render their default settling modules. There is no `granted` state for `appointment` or `waitlist`. The `ended` slot also renders `phase: "unavailable"` for convenience; `unavailable` is not a terminal phase.
42
-
43
- ## `slots.enterable`
44
-
45
- `slots.enterable` receives the typed `sequence` view. Call the method exposed for that exact `phase` and `mechanism`.
46
-
47
- ```tsx
48
- <ExperienceWidget
49
- experienceId="exp_123"
50
- slots={{
51
- enterable: ({ sequence, participationType }) => {
52
- if (sequence.mechanism === "auction") {
53
- return <button onClick={() => void sequence.bid("125.00")}>Bid</button>;
54
- }
55
- if (sequence.mechanism === "appointment") {
56
- return <button onClick={() => void sequence.book("slot_123")}>Book</button>;
57
- }
58
- return <button onClick={() => void sequence.enter()}>Enter {participationType}</button>;
59
- },
60
- }}
61
- />
62
- ```
63
-
64
- `participationType` is the slot prop carrying `sequence.mechanism` for the five non-waitlist mechanisms: `queue`, `draw`, `auction`, `timed_release`, or `appointment`. See the Mechanisms section of the core SDK `JOURNEY_MODEL.md`.
65
-
66
- ## `slots.participating`
67
-
68
- `slots.participating` receives the typed `sequence` view for `queue`, `draw`, `auction`, `timed_release`, and `appointment`.
69
-
70
- - `queue`, `draw`: `state$`, `leave()`.
71
- - `auction`: `state$`, `bid(amount)`, `leave()`.
72
- - `timed_release`: `state$`, `leave()`, `complete()`.
73
- - `appointment`: `state$`, `cancel(reason?)`, `reschedule(newSlotId, newLocationId?)`.
74
-
75
- `position` is populated when queue display state includes a queue position.
76
-
77
- ## Default Rendering
78
-
79
- Without a slot:
80
-
81
- - `ready` uses `StartView`.
82
- - `routing` and loading fallbacks use `LoadingView`.
83
- - `gated` uses `JourneyGate` or `ChallengeGate`.
84
- - `scheduled` and enterable `waitlist` use `UpcomingModule`.
85
- - participating `waitlist` uses `WaitlistView`.
86
- - `queue`, `draw`, `auction`, `timed_release`, and `appointment` use their default modules for supported phases.
87
- - `granted` uses the distribution module's granted panel.
88
- - `ended` uses the distribution module's outcome UI for `queue`, `draw`, `auction`, `timed_release`, and `appointment`; `unavailable` uses `EndedModule`.
89
- - ended `waitlist` can be handled with `slots.ended` or full custom rendering.
package/docs/STYLING.md DELETED
@@ -1,61 +0,0 @@
1
- # Styling Reference
2
-
3
- `@fanfare-io/fanfare-sdk-react` ships dressed components — `ExperienceWidget`, the
4
- sequence modules, and slot helpers — that read from a single theme context.
5
- Most customers should rely on the defaults, then override at four levels of
6
- increasing specificity:
7
-
8
- 1. `theme` for brand colors, typography, and imagery
9
- 2. `variant` for packaged presentation styles
10
- 3. `slots` for swapping specific journey or sequence states
11
- 4. `children` or `useExperienceJourney` for full custom rendering
12
-
13
- The rendered surface follows the SDK model: `journeyStage`, then
14
- `sequence.phase`, then `sequence.mechanism`. Styling changes presentation only;
15
- the server stays authoritative over which actions are permitted.
16
-
17
- ## Theme
18
-
19
- Pass a `BrandTheme` to `ThemeProvider` or directly to `ExperienceWidget`.
20
-
21
- ```tsx
22
- <ThemeProvider theme={{ primary: "#0f766e", fontHeading: "Instrument Serif, serif" }}>
23
- <ExperienceWidget experienceId="exp_123" />
24
- </ThemeProvider>
25
- ```
26
-
27
- Per-widget overrides are shallow-merged over the current theme.
28
-
29
- ## Variant
30
-
31
- `ExperienceWidget` supports packaged variants:
32
-
33
- - `default`
34
- - `retro`
35
- - `rounded`
36
- - `clean`
37
-
38
- Use variants for presentation differences, not for business logic.
39
-
40
- ## Slots
41
-
42
- Replace specific sections with slots — the slot's render prop is called when
43
- that state is active. All other states keep their default rendering.
44
-
45
- ```tsx
46
- <ExperienceWidget
47
- experienceId="exp_123"
48
- slots={{
49
- upcoming: ({ startsAt, onEnter }) => <YourUpcomingCard startsAt={startsAt} onCta={onEnter} />,
50
- }}
51
- />
52
- ```
53
-
54
- See [`docs/SLOTS.md`](./SLOTS.md) for the full slot inventory.
55
-
56
- ## Custom rendering
57
-
58
- For full control, pass `children` to `ExperienceWidget` (a render prop
59
- receiving `{ journey, view, snapshot, error, start, isStarting }`) or assemble
60
- your own UI from `useExperienceJourney`. This is the lowest-level integration
61
- and bypasses slots entirely.