import { SvelteComponent } from "svelte"; /** * A button to subscribe or unsubscribe a user to Web Push Notifications. * * Uses the Push API to register or remove the user’s subscription. * The user stays on the page; no redirect is involved. Requires a configured service worker. * Supports custom labels, styling, and ref forwarding. * * To enable web push, your service worker must import MagicBell’s script: * ```js * importScripts('https://assets.magicbell.io/web-push-notifications/sw'); * ``` */ type Props = { /** * Path to your custom service worker file. Defaults to `/sw.js`. * The service worker must include MagicBell’s web push script via `importScripts(...)`. * @default /sw.js */ serviceWorkerPath?: string; /** * Called when the button is clicked. Return `false` to prevent the subscription flow. * @type {(event: Event) => void | false} */ onClick?: (event: any) => void | false; /** * Called when the subscription status changes. Useful for syncing state, * triggering analytics, or updating UI elsewhere. * * @example * onStatusChange={(status, prevStatus) => { * if (status === 'success') { * console.log('User subscribed to push notifications'); * } * }} */ onStatusChange?: (status: WebPushStatus, prevStatus: WebPushStatus | null) => void; /** * Custom render function for the button label. Receives the current install status * and any error message. * * @default * ({ status }) => status === 'success' ? 'discard' : 'enable' * @example * ({ status, error }) => status === 'subscribed' ? 'Unsubscribe' : 'Enable Push' */ renderLabel?: (props: { status: WebPushStatus; error: string | null; }) => any; /** * Label to show when the button is idle. * Optional alternative to renderLabel. */ idleLabel?: string; /** * Label to show while the current status is being fetched. * Optional alternative to renderLabel. */ loadingLabel?: string; /** * Label to show when the user is subscribed to this channel. * Optional alternative to renderLabel. */ successLabel?: string; /** * Label to show when an error occurred. * Optional alternative to renderLabel. */ errorLabel?: string; /** * Label to show when the app needs to be installed as a PWA (iOS requirement). * Optional alternative to renderLabel. */ requestInstallLabel?: string; /** * Label to show when web push is not supported by the browser. * Optional alternative to renderLabel. */ unsupportedLabel?: string; /** * Additional class names to apply to the button. */ className?: string; /** * When true, omit the default base class to fully control styling. */ unstyled?: boolean; /** * Ref to the underlying button element. * @internal */ buttonRef?: any; }; import type { WebPushStatus } from "./internal/components/internal/map-webpush-state"; declare const __propDef: { props: { renderLabel?: Props["renderLabel"]; requestInstallLabel?: Props["requestInstallLabel"]; unsupportedLabel?: Props["unsupportedLabel"]; unstyled?: Props["unstyled"]; className?: Props["className"]; serviceWorkerPath?: Props["serviceWorkerPath"]; onStatusChange?: Props["onStatusChange"]; idleLabel?: Props["idleLabel"]; loadingLabel?: Props["loadingLabel"]; successLabel?: Props["successLabel"]; errorLabel?: Props["errorLabel"]; buttonRef?: Props["buttonRef"]; }; events: { [evt: string]: CustomEvent; }; slots: {}; exports?: {} | undefined; bindings?: string | undefined; }; export type WebpushButtonProps = typeof __propDef.props; export type WebpushButtonEvents = typeof __propDef.events; export type WebpushButtonSlots = typeof __propDef.slots; export default class WebpushButton extends SvelteComponent { } export {};