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; /** * 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: Status; error: string | null; }) => any; /** * Label to show when the button is idle. * Optional alternative to renderLabel. * @internal */ idleLabel?: string; /** * Label to show while the current status is being fetched. * Optional alternative to renderLabel. * @internal */ loadingLabel?: string; /** * Label to show when the user is subscribed to this channel. * Optional alternative to renderLabel. * @internal */ successLabel?: string; /** * Label to show when an error occurred. * Optional alternative to renderLabel. * @internal */ errorLabel?: 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 { Status } from "./internal/components/internal/map-state"; declare const __propDef: { props: { unstyled?: Props["unstyled"]; className?: Props["className"]; serviceWorkerPath?: Props["serviceWorkerPath"]; renderLabel?: Props["renderLabel"]; 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 {};