@fanfare-io/fanfare-sdk-solid 0.23.0 → 0.24.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 +29 -0
- package/dist/components/auth/auth-form.d.ts +9 -1
- package/dist/components/compositions/journey-gate.d.ts +3 -1
- package/dist/components/internal/queue-module.d.ts +2 -0
- package/dist/components/primitives/checkbox.d.ts +6 -0
- package/dist/components/primitives/index.d.ts +1 -0
- package/dist/components/widgets/experience-widget.d.ts +8 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/use-experience-timing.d.ts +27 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3590 -3490
- package/dist/styles/base.css +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -52,6 +52,35 @@ card field is not a part either. A panel whose footer holds no attribution row k
|
|
|
52
52
|
as a part — `auction-module` is one; [`docs/STYLING.md`](./docs/STYLING.md#parts) lists every
|
|
53
53
|
part and every exception.
|
|
54
54
|
|
|
55
|
+
### Experience timing
|
|
56
|
+
|
|
57
|
+
`useExperienceTiming(() => experienceId)` takes the experience id as an accessor and reads that experience's public
|
|
58
|
+
timing once when it mounts, and again when the id changes or you call `refresh()`:
|
|
59
|
+
|
|
60
|
+
| `status()` | `timing()` |
|
|
61
|
+
| ----------- | ------------------------------------------------------------------------- |
|
|
62
|
+
| `"loading"` | `undefined` — the first read for this experience has not finished |
|
|
63
|
+
| `"error"` | `undefined` — the read failed; call `refresh()` to try again |
|
|
64
|
+
| `"ready"` | the `ExperienceTiming`, or `null` when the experience publishes no timing |
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { useExperienceTiming } from "@fanfare-io/fanfare-sdk-solid";
|
|
68
|
+
import { Show } from "solid-js";
|
|
69
|
+
|
|
70
|
+
function DropStatus(props: { experienceId: string }) {
|
|
71
|
+
const timing = useExperienceTiming(() => props.experienceId);
|
|
72
|
+
return <Show when={timing.status() === "ready" && timing.timing()}>{(t) => <span>{t().status}</span>}</Show>;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`ExperienceTiming` is a type exported from `@fanfare-io/fanfare-sdk-core/experiences`. Its `status` is `upcoming`,
|
|
77
|
+
`open` or `closed`, with `nextOpensAt` and `lastClosedAt` around it. `closesAt` is
|
|
78
|
+
present only while the experience is open, and is `null` when the open run has no end. The primitive never polls
|
|
79
|
+
or schedules a re-read at a boundary, and adds no retry of its own: once `ready`, the result stays as read until
|
|
80
|
+
you call `refresh()`.
|
|
81
|
+
During a refresh the previous result stays in place — a `ready` result keeps its timing and an `error` stays
|
|
82
|
+
`error` — until the new read settles. Primitives that read the same experience at the same time share one request.
|
|
83
|
+
|
|
55
84
|
## Selection
|
|
56
85
|
|
|
57
86
|
Some experiences capture which product and variant a consumer gets. `ExperienceWidget` renders that
|
|
@@ -2,7 +2,9 @@ import { JSX } from 'solid-js';
|
|
|
2
2
|
import { PanelHeadingVariant } from '../module';
|
|
3
3
|
import { AuthInputMode } from './auth-input';
|
|
4
4
|
export interface AuthFormProps {
|
|
5
|
-
onSubmit?: (credential: string, type: AuthInputMode
|
|
5
|
+
onSubmit?: (credential: string, type: AuthInputMode, options?: {
|
|
6
|
+
marketingSmsConsent: boolean;
|
|
7
|
+
}) => Promise<void>;
|
|
6
8
|
onVerify?: (otp: string) => Promise<void>;
|
|
7
9
|
onSkip?: () => void | Promise<void>;
|
|
8
10
|
onSuccess?: () => void;
|
|
@@ -19,6 +21,12 @@ export interface AuthFormProps {
|
|
|
19
21
|
allowSkip?: boolean;
|
|
20
22
|
skipLabel?: string;
|
|
21
23
|
showBranding?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Shows the marketing SMS consent checkbox, its disclosure and legal line on the credential step in
|
|
26
|
+
* phone mode. Off by default: set it only when `onSubmit` reads its third argument, since a tick
|
|
27
|
+
* the handler never reads is a consent silently dropped.
|
|
28
|
+
*/
|
|
29
|
+
showMarketingSmsConsent?: boolean;
|
|
22
30
|
/** Initial step when mounting. Useful for SSR-resume or storybook lanes that need the verify step. */
|
|
23
31
|
defaultStep?: "credential" | "verify";
|
|
24
32
|
/** Initial credential (email or E.164 phone) — pairs with `defaultStep="verify"`. */
|
|
@@ -3,7 +3,9 @@ import { AuthInputMode } from '../auth/auth-input';
|
|
|
3
3
|
export type JourneyGateStage = "auth" | "access_code" | "loading" | "none";
|
|
4
4
|
export interface JourneyGateProps {
|
|
5
5
|
stage: JourneyGateStage;
|
|
6
|
-
onAuthSubmit?: (credential: string, type: AuthInputMode
|
|
6
|
+
onAuthSubmit?: (credential: string, type: AuthInputMode, options?: {
|
|
7
|
+
marketingSmsConsent: boolean;
|
|
8
|
+
}) => Promise<void>;
|
|
7
9
|
onAuthVerify?: (otp: string) => Promise<void>;
|
|
8
10
|
onAuthSkip?: () => void | Promise<void>;
|
|
9
11
|
onAuthSuccess?: () => void;
|
|
@@ -8,6 +8,8 @@ import { OutcomeReason } from '../module';
|
|
|
8
8
|
export interface QueueModuleProps {
|
|
9
9
|
display$?: ReadableAtom<QueueDisplayState>;
|
|
10
10
|
sequencePhase: "enterable" | "participating" | "granted" | "ended";
|
|
11
|
+
/** Hide live rank-derived queue metrics while the canonical queue is still pre-open. */
|
|
12
|
+
hideQueueMetrics?: boolean;
|
|
11
13
|
canEnter: boolean;
|
|
12
14
|
canLeave: boolean;
|
|
13
15
|
onEnter: () => Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
export interface CheckboxProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "type"> {
|
|
3
|
+
/** Label rendered beside the control. */
|
|
4
|
+
label: JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
export declare function Checkbox(props: CheckboxProps): JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Badge, badgeVariants, type BadgeProps, type BadgeVariant } from './badge';
|
|
2
2
|
export { Button, buttonVariants, type ButtonProps } from './button';
|
|
3
3
|
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, cardVariants, type CardContentProps, type CardDescriptionProps, type CardFooterProps, type CardHeaderProps, type CardProps, type CardTitleProps, } from './card';
|
|
4
|
+
export { Checkbox, type CheckboxProps } from './checkbox';
|
|
4
5
|
export { Countdown, type CountdownProps, type CountdownSize, type CountdownTone } from './countdown';
|
|
5
6
|
export { FadePresence, type FadePresenceProps } from './fade-presence';
|
|
6
7
|
export { FanfareLogo, type FanfareLogoProps } from './fanfare-logo';
|
|
@@ -31,9 +31,16 @@ export interface StartSlotProps extends SlotProps {
|
|
|
31
31
|
isStarting: boolean;
|
|
32
32
|
}
|
|
33
33
|
export interface AuthSlotProps extends SlotProps {
|
|
34
|
-
onSubmit: (credential: string, type: AuthInputMode
|
|
34
|
+
onSubmit: (credential: string, type: AuthInputMode, options?: {
|
|
35
|
+
marketingSmsConsent: boolean;
|
|
36
|
+
}) => Promise<void>;
|
|
35
37
|
onVerify: (otp: string) => Promise<void>;
|
|
36
38
|
onSkip?: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the sign-in should offer the marketing SMS consent checkbox. The widget sets it because its
|
|
41
|
+
* `onSubmit` reads the consent from its third argument; pass it to `AuthForm` with `onSubmit`.
|
|
42
|
+
*/
|
|
43
|
+
showMarketingSmsConsent?: boolean;
|
|
37
44
|
}
|
|
38
45
|
export interface AccessCodeSlotProps extends SlotProps {
|
|
39
46
|
onSubmit: (code: string) => Promise<void>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export { useFanfareAuth } from './use-auth';
|
|
|
9
9
|
export { createBeaconTracker } from './use-beacon-tracker';
|
|
10
10
|
export { useExperienceJourney } from './use-experience-journey';
|
|
11
11
|
export type { ExperienceJourneyOptions, UseExperienceJourneyOptions, UseExperienceJourneyResult, } from './use-experience-journey';
|
|
12
|
+
export { useExperienceTiming } from './use-experience-timing';
|
|
13
|
+
export type { UseExperienceTimingResult } from './use-experience-timing';
|
|
12
14
|
export { useJourneySnapshot } from './use-journey-snapshot';
|
|
13
15
|
export { useNanostore } from './use-nanostore';
|
|
14
16
|
export { useSdkEvent } from './use-sdk-event';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ExperienceTiming } from '@fanfare-io/fanfare-sdk-core/experiences';
|
|
2
|
+
import { Accessor } from 'solid-js';
|
|
3
|
+
/**
|
|
4
|
+
* Result of {@link useExperienceTiming}.
|
|
5
|
+
*
|
|
6
|
+
* - `status() === "loading"`: the first read for this experience has not settled; `timing()` is `undefined`.
|
|
7
|
+
* - `status() === "error"`: the last read was rejected; `timing()` is `undefined` and `refresh()` reads again.
|
|
8
|
+
* - `status() === "ready"`: `timing()` is the experience's public timing, or `null` when it publishes none.
|
|
9
|
+
*/
|
|
10
|
+
export interface UseExperienceTimingResult {
|
|
11
|
+
status: Accessor<"loading" | "error" | "ready">;
|
|
12
|
+
timing: Accessor<ExperienceTiming | null | undefined>;
|
|
13
|
+
refresh(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads an experience's public timing once when it attaches, and again whenever
|
|
17
|
+
* `experienceId` changes or `refresh()` is called.
|
|
18
|
+
*
|
|
19
|
+
* The primitive never polls, retries or schedules work around the timing's
|
|
20
|
+
* boundaries; a caller that needs fresher timing calls `refresh()`. While a
|
|
21
|
+
* refresh is in flight the result is unchanged: a `ready` result keeps its last
|
|
22
|
+
* timing and an `error` result stays `error` until the read settles. Primitives
|
|
23
|
+
* that read the same experience at the same time on one SDK instance share a
|
|
24
|
+
* single request. Results from a superseded read, or from one still in flight
|
|
25
|
+
* after disposal, are dropped.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useExperienceTiming(experienceId: Accessor<string>): UseExperienceTimingResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { FanfareProvider, useFanfare } from './components/provider';
|
|
9
9
|
export type { FanfareProviderProps } from './components/provider';
|
|
10
|
-
export { createBeaconTracker, useExperienceJourney, useFanfareAuth, useJourneySnapshot, useNanostore, useSdkEvent, } from './hooks';
|
|
10
|
+
export { createBeaconTracker, useExperienceJourney, useExperienceTiming, useFanfareAuth, useJourneySnapshot, useNanostore, useSdkEvent, } from './hooks';
|
|
11
|
+
export type { UseExperienceTimingResult } from './hooks';
|
|
11
12
|
export { I18nProvider, RTL_LOCALES, isRTLLocale, useTranslations } from './i18n';
|
|
12
13
|
export type { I18nConfig, I18nProviderProps, Locale, PartialTranslationMessages, RTLLocale, TextDirection, TranslateFunction, TranslateOptions, TranslationKey, TranslationMessageKey, TranslationMessages, } from './i18n';
|
|
13
14
|
export { THEME_CSS_VARS, ThemeProvider, buildThemeCssVars } from './theme';
|