@fanfare-io/fanfare-sdk-react 0.1.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.
Files changed (102) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +58 -0
  3. package/dist/components/auth/access-code-input.d.ts +24 -0
  4. package/dist/components/auth/auth-form.d.ts +39 -0
  5. package/dist/components/auth/auth-input.d.ts +28 -0
  6. package/dist/components/auth/email-input.d.ts +21 -0
  7. package/dist/components/auth/index.d.ts +19 -0
  8. package/dist/components/auth/otp-input.d.ts +32 -0
  9. package/dist/components/auth/phone-input.d.ts +22 -0
  10. package/dist/components/compositions/access-code-form.d.ts +29 -0
  11. package/dist/components/compositions/challenge-gate.d.ts +23 -0
  12. package/dist/components/compositions/ended-module.d.ts +26 -0
  13. package/dist/components/compositions/error-view.d.ts +58 -0
  14. package/dist/components/compositions/granted-panel.d.ts +35 -0
  15. package/dist/components/compositions/index.d.ts +15 -0
  16. package/dist/components/compositions/journey-gate.d.ts +48 -0
  17. package/dist/components/compositions/outcome-panel.d.ts +11 -0
  18. package/dist/components/index.d.ts +15 -0
  19. package/dist/components/journey/experience-journey-controller.d.ts +14 -0
  20. package/dist/components/journey/experience-journey-skeleton.d.ts +21 -0
  21. package/dist/components/module/alert-panel.d.ts +13 -0
  22. package/dist/components/module/index.d.ts +19 -0
  23. package/dist/components/module/info-panel.d.ts +9 -0
  24. package/dist/components/module/outcome-reason.d.ts +27 -0
  25. package/dist/components/module/panel-heading.d.ts +34 -0
  26. package/dist/components/module/panel-layout.d.ts +28 -0
  27. package/dist/components/primitives/badge.d.ts +18 -0
  28. package/dist/components/primitives/button.d.ts +23 -0
  29. package/dist/components/primitives/card.d.ts +20 -0
  30. package/dist/components/primitives/countdown.d.ts +42 -0
  31. package/dist/components/primitives/fade-presence.d.ts +28 -0
  32. package/dist/components/primitives/fanfare-logo.d.ts +12 -0
  33. package/dist/components/primitives/index.d.ts +30 -0
  34. package/dist/components/primitives/input.d.ts +46 -0
  35. package/dist/components/primitives/progress.d.ts +16 -0
  36. package/dist/components/primitives/skeleton.d.ts +9 -0
  37. package/dist/components/primitives/spinner.d.ts +10 -0
  38. package/dist/components/primitives/transition.d.ts +34 -0
  39. package/dist/components/shadow-dom-preview.d.ts +43 -0
  40. package/dist/components/widgets/appointment/appointment-booking-details.d.ts +18 -0
  41. package/dist/components/widgets/appointment/appointment-checked-in-view.d.ts +12 -0
  42. package/dist/components/widgets/appointment/appointment-day-tabs.d.ts +21 -0
  43. package/dist/components/widgets/appointment/appointment-slot-grid.d.ts +12 -0
  44. package/dist/components/widgets/appointment/appointment-slot-item.d.ts +12 -0
  45. package/dist/components/widgets/appointment/appointment-slot-picker.d.ts +16 -0
  46. package/dist/components/widgets/auction/auction-actions.d.ts +38 -0
  47. package/dist/components/widgets/auction/auction-bid-display.d.ts +35 -0
  48. package/dist/components/widgets/auction/index.d.ts +7 -0
  49. package/dist/components/widgets/draw/draw-actions.d.ts +40 -0
  50. package/dist/components/widgets/draw/index.d.ts +6 -0
  51. package/dist/components/widgets/experience-widget.d.ts +141 -0
  52. package/dist/components/widgets/index.d.ts +11 -0
  53. package/dist/components/widgets/internal/appointment-module.d.ts +28 -0
  54. package/dist/components/widgets/internal/auction-module.d.ts +33 -0
  55. package/dist/components/widgets/internal/draw-module.d.ts +43 -0
  56. package/dist/components/widgets/internal/index.d.ts +15 -0
  57. package/dist/components/widgets/internal/loading-view.d.ts +17 -0
  58. package/dist/components/widgets/internal/queue-module.d.ts +27 -0
  59. package/dist/components/widgets/internal/start-view.d.ts +25 -0
  60. package/dist/components/widgets/internal/timed-release-module.d.ts +27 -0
  61. package/dist/components/widgets/internal/upcoming-module.d.ts +29 -0
  62. package/dist/components/widgets/internal/waitlist-view.d.ts +18 -0
  63. package/dist/components/widgets/queue/index.d.ts +6 -0
  64. package/dist/components/widgets/queue/queue-actions.d.ts +36 -0
  65. package/dist/components/widgets/timed-release/index.d.ts +6 -0
  66. package/dist/components/widgets/timed-release/timed-release-actions.d.ts +38 -0
  67. package/dist/components/widgets/waitlist/index.d.ts +6 -0
  68. package/dist/components/widgets/waitlist/waitlist-actions.d.ts +40 -0
  69. package/dist/context.d.ts +5 -0
  70. package/dist/hooks/use-appointment-slots.d.ts +13 -0
  71. package/dist/hooks/use-auth.d.ts +22 -0
  72. package/dist/hooks/use-experience-journey.d.ts +20 -0
  73. package/dist/hooks/use-fanfare.d.ts +11 -0
  74. package/dist/hooks/use-journey-snapshot.d.ts +8 -0
  75. package/dist/hooks/use-nanostore.d.ts +6 -0
  76. package/dist/i18n/i18n-context.d.ts +73 -0
  77. package/dist/i18n/i18n-provider.d.ts +67 -0
  78. package/dist/i18n/index.d.ts +13 -0
  79. package/dist/index.d.ts +53 -0
  80. package/dist/index.js +4918 -0
  81. package/dist/internal-sdk.d.ts +2 -0
  82. package/dist/lib/animations.d.ts +94 -0
  83. package/dist/lib/appointment-format.d.ts +35 -0
  84. package/dist/lib/confetti.d.ts +17 -0
  85. package/dist/lib/currency.d.ts +9 -0
  86. package/dist/lib/index.d.ts +5 -0
  87. package/dist/lib/phone-formatter-lite.d.ts +26 -0
  88. package/dist/lib/use-grant-celebration.d.ts +12 -0
  89. package/dist/lib/utils.d.ts +13 -0
  90. package/dist/provider.d.ts +99 -0
  91. package/dist/styles/base.css +2254 -0
  92. package/dist/styles/index.d.ts +2 -0
  93. package/dist/styles/theme.css +143 -0
  94. package/dist/theme/index.d.ts +16 -0
  95. package/dist/theme/theme-context.d.ts +20 -0
  96. package/dist/theme/theme-provider.d.ts +20 -0
  97. package/dist/theme/theme-utils.d.ts +18 -0
  98. package/dist/theme/theme.types.d.ts +47 -0
  99. package/dist/theme/use-theme.d.ts +44 -0
  100. package/docs/SLOTS.md +89 -0
  101. package/docs/STYLING.md +61 -0
  102. package/package.json +145 -0
@@ -0,0 +1,2 @@
1
+ import { FanfareSDK } from '@fanfare-io/fanfare-sdk-core';
2
+ export type AdapterRuntimeSDK = FanfareSDK;
@@ -0,0 +1,94 @@
1
+ export type AnimationConfig = {
2
+ duration?: number;
3
+ delay?: number;
4
+ easing?: string;
5
+ respectMotionPreference?: boolean;
6
+ };
7
+ export declare const defaultAnimationConfig: AnimationConfig;
8
+ export declare const prefersReducedMotion: () => boolean;
9
+ export declare const getAnimationDuration: (config?: AnimationConfig) => number;
10
+ export declare const getAnimationDelay: (config?: AnimationConfig) => number;
11
+ export declare const animationClasses: {
12
+ readonly fadeIn: "ff:animate-fade-in";
13
+ readonly fadeOut: "ff:animate-fade-out";
14
+ readonly slideIn: "ff:animate-slide-in";
15
+ readonly slideOut: "ff:animate-slide-out";
16
+ readonly scaleIn: "ff:animate-scale-in";
17
+ readonly scaleOut: "ff:animate-scale-out";
18
+ readonly accordionDown: "ff:animate-accordion-down";
19
+ readonly accordionUp: "ff:animate-accordion-up";
20
+ readonly celebration: "ff:animate-celebration";
21
+ readonly shake: "ff:animate-shake";
22
+ readonly pulseSuccess: "ff:animate-pulse-success";
23
+ };
24
+ export type AnimationType = keyof typeof animationClasses;
25
+ export declare const getAnimationClass: (animation: AnimationType, config?: AnimationConfig) => string;
26
+ export declare const createTransition: (properties?: string[], config?: AnimationConfig) => string;
27
+ export declare const withAnimation: <T extends Record<string, unknown>>(baseProps: T, animation: AnimationType, config?: AnimationConfig) => T & {
28
+ className?: string;
29
+ };
30
+ export declare const fadeInOut: {
31
+ initial: {
32
+ opacity: number;
33
+ };
34
+ animate: {
35
+ opacity: number;
36
+ };
37
+ exit: {
38
+ opacity: number;
39
+ };
40
+ transition: {
41
+ duration: number;
42
+ };
43
+ };
44
+ /**
45
+ * Shared motion-prop pair for panel-level fade-in. Panels (distribution
46
+ * modules, OutcomePanel, GrantedPanel, etc.) all use the same fade in
47
+ * profile. `getPanelMotionProps()` picks the appropriate one based on
48
+ * `prefers-reduced-motion`.
49
+ */
50
+ export declare const PANEL_FADE_IN_MOTION: {
51
+ readonly initial: {
52
+ readonly opacity: 0;
53
+ };
54
+ readonly animate: {
55
+ readonly opacity: 1;
56
+ };
57
+ readonly transition: {
58
+ readonly duration: 0.25;
59
+ readonly ease: "easeOut";
60
+ };
61
+ };
62
+ export declare const INSTANT_MOTION: {
63
+ readonly initial: {
64
+ readonly opacity: 1;
65
+ };
66
+ readonly animate: {
67
+ readonly opacity: 1;
68
+ };
69
+ readonly transition: {
70
+ readonly duration: 0;
71
+ };
72
+ };
73
+ export declare const getPanelMotionProps: () => {
74
+ readonly initial: {
75
+ readonly opacity: 0;
76
+ };
77
+ readonly animate: {
78
+ readonly opacity: 1;
79
+ };
80
+ readonly transition: {
81
+ readonly duration: 0.25;
82
+ readonly ease: "easeOut";
83
+ };
84
+ } | {
85
+ readonly initial: {
86
+ readonly opacity: 1;
87
+ };
88
+ readonly animate: {
89
+ readonly opacity: 1;
90
+ };
91
+ readonly transition: {
92
+ readonly duration: 0;
93
+ };
94
+ };
@@ -0,0 +1,35 @@
1
+ import { AppointmentSlot } from '@fanfare-io/fanfare-sdk-core/appointments';
2
+ /**
3
+ * Date / time formatting helpers shared across the appointment components.
4
+ * All helpers gracefully fall back to the input string when given an
5
+ * unparseable value or when `Intl.DateTimeFormat` throws on a bad
6
+ * `timeZone` (it raises `RangeError: Invalid time zone specified`).
7
+ */
8
+ export declare function formatWeekday(value: string, timezone?: string): string;
9
+ export declare function formatMonthDay(value: string, timezone?: string): string;
10
+ export declare function formatTime(value: string, timezone?: string): string;
11
+ export declare function formatDurationMinutes(start: string, end: string): number | null;
12
+ /** Format the start time of an appointment slot, falling back to its id string. */
13
+ export declare function formatSlotTime(slot: AppointmentSlot): string;
14
+ /**
15
+ * Return the YYYY-MM-DD calendar date of `date` as seen in `timezone`.
16
+ *
17
+ * Used by the slot picker to bucket slots by day and to render the day strip.
18
+ * Falls back to UTC when no `timezone` is provided. `sv-SE` locale produces
19
+ * ISO-format output (YYYY-MM-DD), so we can use it as a TZ-shifted date key
20
+ * without parsing locale-specific separators.
21
+ */
22
+ export declare function isoDateInTimezone(date: Date, timezone?: string): string;
23
+ /**
24
+ * Add `days` calendar days to a YYYY-MM-DD ISO date string, returning the
25
+ * shifted YYYY-MM-DD. TZ-agnostic — calendar-day arithmetic only.
26
+ */
27
+ export declare function addCalendarDays(isoDate: string, days: number): string;
28
+ /**
29
+ * Format the weekday label (e.g. "Mon") for a YYYY-MM-DD calendar date.
30
+ * Uses noon UTC under the hood so a TZ offset can't push the formatter to
31
+ * the wrong weekday.
32
+ */
33
+ export declare function weekdayLabel(isoDate: string): string;
34
+ /** Day-of-month from a YYYY-MM-DD calendar date. */
35
+ export declare function dayOfMonth(isoDate: string): number;
@@ -0,0 +1,17 @@
1
+ import { WidgetVariant } from '../theme';
2
+ /**
3
+ * Trigger a celebration confetti effect.
4
+ * Respects reduced motion preferences and variant-specific styling.
5
+ *
6
+ * @param variant - The current theme variant
7
+ * @returns void
8
+ */
9
+ export declare function triggerCelebration(variant: WidgetVariant): void;
10
+ /**
11
+ * Trigger a burst of confetti from a specific element.
12
+ * Useful for button clicks or specific UI interactions.
13
+ *
14
+ * @param element - The element to burst from
15
+ * @param variant - The current theme variant
16
+ */
17
+ export declare function triggerCelebrationFromElement(element: HTMLElement, variant: WidgetVariant): void;
@@ -0,0 +1,9 @@
1
+ export type CurrencyFormatOptions = {
2
+ currencyCode?: string;
3
+ currencySymbol?: string;
4
+ locale?: string;
5
+ minimumFractionDigits?: number;
6
+ maximumFractionDigits?: number;
7
+ };
8
+ export declare function getCurrencySymbol(currencyCode: string, locale?: string): string;
9
+ export declare function formatMoney(amount: number, options?: CurrencyFormatOptions): string;
@@ -0,0 +1,5 @@
1
+ export { animationClasses, createTransition, defaultAnimationConfig, getAnimationClass, getAnimationDelay, getAnimationDuration, prefersReducedMotion, withAnimation, } from './animations';
2
+ export type { AnimationConfig, AnimationType } from './animations';
3
+ export { formatMoney, getCurrencySymbol } from './currency';
4
+ export type { CurrencyFormatOptions } from './currency';
5
+ export { cn, extractAriaProps, extractDataProps, fanfareClass } from './utils';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Minimal phone number utilities
3
+ * Shared by auth-input and phone-input components.
4
+ */
5
+ /**
6
+ * Extract phone input characters while preserving the plus sign
7
+ * Keeps: digits, plus (at start only)
8
+ * Removes: all other characters
9
+ */
10
+ export declare function extractPhoneInput(value: string): string;
11
+ /**
12
+ * Format phone number as user types
13
+ * US numbers: (415) 407-9619
14
+ * US with country code: +1 (415) 407-9619
15
+ * International: +44 207 123 4567 (grouped by 3s)
16
+ */
17
+ export declare function formatPhoneAsYouType(value: string): string;
18
+ /**
19
+ * Convert phone input to E.164 format (+[country code][number])
20
+ * Returns null if the input cannot be converted to valid E.164
21
+ */
22
+ export declare function toE164(value: string): string | null;
23
+ /**
24
+ * Basic phone validation
25
+ */
26
+ export declare function validatePhone(value: string): boolean;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * useGrantCelebration
3
+ *
4
+ * One-shot mount-time confetti for the "won" / granted lifecycle state of
5
+ * a distribution module. Each module's `won` branch wires this up against
6
+ * a ref to its hero element.
7
+ *
8
+ * Internally respects `prefersReducedMotion` (via triggerCelebrationFromElement)
9
+ * and the active theme variant (clean variant intentionally fires no confetti).
10
+ */
11
+ import * as React from "react";
12
+ export declare function useGrantCelebration<T extends HTMLElement>(ref: React.RefObject<T | null>): void;
@@ -0,0 +1,13 @@
1
+ import { ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
3
+ export declare function fanfareClass(...inputs: ClassValue[]): string;
4
+ export declare const extractAriaProps: (props: {
5
+ [key: string]: unknown;
6
+ }) => {
7
+ [key: string]: unknown;
8
+ };
9
+ export declare const extractDataProps: (props: {
10
+ [key: string]: unknown;
11
+ }) => {
12
+ [key: string]: unknown;
13
+ };
@@ -0,0 +1,99 @@
1
+ import { FanfareConfig } from '@fanfare-io/fanfare-sdk-core';
2
+ import { default as React } from 'react';
3
+ import { Locale, PartialTranslationMessages, TranslationMessageKey } from './i18n';
4
+ interface RequiredFanfareConfig {
5
+ organizationId: string;
6
+ publishableKey: string;
7
+ }
8
+ export interface FanfareProviderProps extends FanfareConfig, RequiredFanfareConfig {
9
+ children: React.ReactNode;
10
+ /**
11
+ * Whether to automatically restore session on mount
12
+ * @default true
13
+ */
14
+ autoRestore?: boolean;
15
+ /**
16
+ * Whether to automatically resume operations after restore
17
+ * @default true
18
+ */
19
+ autoResume?: boolean;
20
+ /**
21
+ * Loading component to show while initializing
22
+ */
23
+ loadingComponent?: React.ReactNode;
24
+ /**
25
+ * Locale for translations
26
+ * @default "en"
27
+ */
28
+ locale?: Locale;
29
+ /**
30
+ * Custom translations to merge with or override defaults.
31
+ * Use this to customize button labels, messages, and other text.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * <FanfareProvider
36
+ * organizationId="org_123"
37
+ * publishableKey="pk_live_xyz789"
38
+ * translations={{
39
+ * "queue.enter": "Join the Line",
40
+ * "granted.cta": "Go to Checkout",
41
+ * }}
42
+ * >
43
+ * <App />
44
+ * </FanfareProvider>
45
+ * ```
46
+ */
47
+ translations?: PartialTranslationMessages<TranslationMessageKey>;
48
+ }
49
+ /**
50
+ * FanfareProvider - Provider component for the Fanfare SDK
51
+ *
52
+ * Initializes the Fanfare SDK and makes it available to all child components
53
+ * via React Context. Handles session restoration and automatic resumption of
54
+ * queue operations.
55
+ *
56
+ * This component must wrap your entire application or the parts that need
57
+ * access to Fanfare functionality.
58
+ *
59
+ * @param props - Provider configuration
60
+ * @returns A provider component that initializes and distributes the SDK
61
+ *
62
+ * @example
63
+ * Basic usage:
64
+ * ```tsx
65
+ * <FanfareProvider
66
+ * organizationId="org_123"
67
+ * publishableKey="pk_live_xyz789"
68
+ * >
69
+ * <App />
70
+ * </FanfareProvider>
71
+ * ```
72
+ *
73
+ * @example
74
+ * With custom loading component:
75
+ * ```tsx
76
+ * <FanfareProvider
77
+ * organizationId="org_123"
78
+ * publishableKey="pk_live_xyz789"
79
+ * loadingComponent={<Spinner />}
80
+ * >
81
+ * <App />
82
+ * </FanfareProvider>
83
+ * ```
84
+ *
85
+ * @example
86
+ * Disable auto-restore and auto-resume:
87
+ * ```tsx
88
+ * <FanfareProvider
89
+ * organizationId="org_123"
90
+ * publishableKey="pk_live_xyz789"
91
+ * autoRestore={false}
92
+ * autoResume={false}
93
+ * >
94
+ * <App />
95
+ * </FanfareProvider>
96
+ * ```
97
+ */
98
+ export declare function FanfareProvider({ children, autoRestore, autoResume, loadingComponent, locale, translations, organizationId, publishableKey, environment, apiUrl, credentials, debug, auth, logging, sync, features, beacon, }: FanfareProviderProps): import("react/jsx-runtime").JSX.Element | null;
99
+ export {};