import { AuthPluginBase, AuthView } from '@better-auth-ui/core'; import { ComponentType, ReactNode } from 'react'; import { SettingsTab } from './settings-tab'; export type { AuthPluginViewPaths } from '@better-auth-ui/core'; /** Props for plugin-contributed auth buttons (e.g. passkey, magic link). */ export type AuthButtonProps = { className?: string; children?: ReactNode; /** Current auth view — lets buttons context-switch (e.g. show "back to sign-in"). */ view?: AuthView; }; /** Props for plugin-contributed cards under `/settings/security`. */ export type SecurityCardProps = { className?: string; children?: ReactNode; }; /** Props for plugin-contributed cards under `/settings/account`. */ export type AccountCardProps = { className?: string; children?: ReactNode; }; /** Props for plugin-contributed cards under `/organization/...` settings. */ export type OrganizationCardProps = { className?: string; children?: ReactNode; }; /** Props for plugin-contributed items in the `UserButton` dropdown. */ export type UserMenuItemProps = { className?: string; /** When true, the subtitle line (email when name/username is shown) is hidden. */ hideSubtitle?: boolean; }; /** Framework-agnostic slot component shapes. UI packages narrow these via `TComponents`. */ export type AuthPluginComponents = { /** Rendered below the submit button in auth forms. */ authButtons?: ComponentType[]; /** Captcha widget rendered above the submit button, below additionalFields. Singular — only one captcha can be active at a time. */ captchaComponent?: ReactNode; /** Rendered as cards inside security settings. */ securityCards?: ComponentType[]; /** Rendered as cards inside account settings. */ accountCards?: ComponentType[]; /** Rendered as cards inside the active organization's settings. */ organizationCards?: ComponentType[]; /** Rendered as items inside the `UserButton` dropdown. */ userMenuItems?: ComponentType[]; }; /** Plugin view overrides keyed by `AuthPluginViewPaths`. Always replaces the built-in view. */ export type AuthPluginViews = { auth?: Record>; settings?: Record>; }; /** Conditional view replacements — only used when the built-in flow isn't viable. */ export type AuthPluginFallbackViews = { auth?: { /** Rendered at `/auth/sign-in` when `emailAndPassword.enabled === false`. */ signIn?: ComponentType; }; }; /** * UI-aware plugin definition. UI packages bind the generics in their own * `AuthPlugin` re-export so plugin authors don't have to. * * @typeParam TComponents - Slot component shapes (e.g. heroui variant unions). * @typeParam TAuthViewProps - Props the `` router spreads onto plugin auth views. * @typeParam TSettingsViewProps - Props the `` router spreads onto plugin settings views. */ export type AuthPlugin = AuthPluginBase & TComponents & { views?: AuthPluginViews; fallbackViews?: AuthPluginFallbackViews; /** * Tabs the plugin contributes to the settings page. Each entry is a * {@link SettingsTab} (`view`, `label`, `component`). Read at runtime via * `useAuthPlugin(plugin).settingsTabs`. */ settingsTabs?: SettingsTab[]; };