import { ReactNode, ReactElement } from 'react'; import { FeaturebaseSettings, ChangelogWidgetConfigInput, FeaturebaseEmbedWidgetConfigInput, FeaturebaseEmbedCallback, show, hide, showSpace, showMessages, showArticle, showChangelog, showNews, showConversation, showNewMessage, setTheme, setLanguage, update, shutdown, FeedbackWidgetConfigInput, SurveyWidgetConfigInput } from './index.cjs'; /** * `featurebase-js/react` — React-specific ergonomics for the messenger * and the standalone widgets (changelog / feedback / surveys). * * Mirrors `posthog-js/react`'s shape: a Provider that handles the messenger * lifecycle, plus per-widget hooks that inherit identity from the Provider's * context so you don't have to repeat `featurebaseJwt` everywhere. The * workspace slug is resolved from `appId` and injected internally. */ interface FeaturebaseProviderProps extends FeaturebaseSettings { /** * Pre-minted JWT for widget identity verification (advanced). Most * apps should use {@link FeaturebaseProviderProps.featurebaseJwt} on * the Provider or pass `featurebaseJwt` per call instead. Widget * hooks inherit this from context. */ jwtToken?: string; children: ReactNode; } /** * Boots the Featurebase Messenger and standalone widgets on mount and * tears them down on unmount. Re-identifies (without re-booting) whenever * the identity props (`featurebaseJwt`, etc.) change. Exposes the live * unread-count and the identity to descendants via * {@link useFeaturebase} and the widget hooks. * * The Provider drives both surfaces from a single `appId`: * - It resolves `appId → { slug, modules }` once per browser per hour * (cached). * - It boots the messenger automatically when **General → Manage * modules** has Support enabled. Set `messenger={false}` to opt out. * - It populates widget defaults so descendant `useChangelogWidget` / * `useFeedbackWidget` / `useSurveyWidget` calls work without * repeating the slug or identity. * * @example * ```tsx * * * * ``` */ declare function FeaturebaseProvider(props: FeaturebaseProviderProps): ReactElement; /** * Imperative + reactive access to the messenger from any component beneath * a {@link FeaturebaseProvider}. Methods are stable identities; only * `unreadCount` causes re-renders. * * @example * ```tsx * const { show, unreadCount } = useFeaturebase(); * return ; * ``` */ declare function useFeaturebase(): { show: typeof show; hide: typeof hide; showSpace: typeof showSpace; showMessages: typeof showMessages; showArticle: typeof showArticle; showChangelog: typeof showChangelog; showNews: typeof showNews; showConversation: typeof showConversation; showNewMessage: typeof showNewMessage; setTheme: typeof setTheme; setLanguage: typeof setLanguage; update: typeof update; shutdown: typeof shutdown; unreadCount: number; }; interface UseChangelogWidgetReturn { /** Open the popup imperatively. */ openPopup: (data?: unknown) => void; /** Mark every entry as read for the current visitor. */ markAllAsViewed: () => void; /** Synchronous read of the unread count (undefined before init). */ getUnviewedCount: () => number | undefined; } /** * Boots the standalone changelog widget on mount, tears it down on * unmount, and re-inits whenever the resolved config changes. * * Identity (`featurebaseJwt`, etc.) is inherited from * {@link FeaturebaseProvider} when present — pass it explicitly to * override per-widget. The workspace slug is taken from the Provider's * `appId` (resolved internally) and is never a per-widget input. * * @example * ```tsx * // Inside * const { openPopup } = useChangelogWidget({ * theme: 'light', * dropdown: { enabled: true }, * }); * ``` */ declare function useChangelogWidget(config: ChangelogWidgetConfigInput): UseChangelogWidgetReturn; /** * Boots the floating feedback widget on mount, tears it down on unmount, * and re-inits whenever the resolved config changes. Inherits identity * from {@link FeaturebaseProvider}. * * @example * ```tsx * useFeedbackWidget({ theme: 'light', placement: 'bottom-right' }); * ``` */ declare function useFeedbackWidget(config: FeedbackWidgetConfigInput): void; /** * Boots the survey runtime on mount. The runtime polls for surveys whose * targeting matches the current page and auto-displays them. Inherits * identity from {@link FeaturebaseProvider}. * * Note: the runtime does not currently expose a teardown for surveys, so * this hook intentionally has no cleanup. Mount it once at the app root. */ declare function useSurveyWidget(config?: SurveyWidgetConfigInput): void; /** * Mounts the modern embeddable board into a `[data-featurebase-embed]` * element on the page. Re-inits whenever the resolved config changes — * the runtime treats subsequent calls as in-place updates of the * existing iframe, so flipping themes / paths doesn't remount. * * Identity (`featurebaseJwt`, etc.) is inherited from * {@link FeaturebaseProvider} when present. The runtime owns iframe * teardown via the host element's lifecycle (the iframe lives inside the * `[data-featurebase-embed]` element in your React tree), so this hook * intentionally has no destroy step. * * @example * ```tsx * function Roadmap() { * useEmbedWidget( * { * embedOptions: { path: '/roadmap' }, * // hideMenu hides the top nav (Boards / Roadmap / Changelog) — * // useful when you're only embedding one surface. * stylingOptions: { theme: 'light', hideMenu: true }, * }, * (err, evt) => { if (evt?.action === 'widgetReady') console.log('ready'); }, * ); * return
; * } * ``` */ declare function useEmbedWidget(config: FeaturebaseEmbedWidgetConfigInput, callback?: FeaturebaseEmbedCallback): void; export { FeaturebaseProvider, type FeaturebaseProviderProps, type UseChangelogWidgetReturn, useChangelogWidget, useEmbedWidget, useFeaturebase, useFeedbackWidget, useSurveyWidget };