import { Ref } from '../../node_modules/vue'; /** * The newsletter signup payload forwarded to {@link useSendEmail}. Mirrors the * Mailchimp-related props of the `FormSignUp` component. */ export interface UseSignUpFormOptions { /** * Mailchimp form action URL. */ action?: string; /** * Name of the Mailchimp merge field carrying the email. */ emailField?: string; /** * Mailchimp signup tracker value. */ tracker?: string; /** * Explicit referrer to record; falls back to the document referrer when omitted. */ referrer?: string | null; /** * Mailchimp interest groups to opt into. */ defaultGroups?: string | string[]; /** * Emits the form lifecycle events back to the host component. Receives the * same `('success' | 'error' | 'subscribed', payload?)` contract the * component exposes. */ emit: (event: 'success' | 'error' | 'subscribed', payload?: unknown) => void; } /** * Reactive API returned by {@link useSignUpForm}. */ export interface UseSignUpForm { /** * Two-way bound subscriber email. */ email: Ref; /** * Whether the form is locked while a submission is in flight. */ frozen: Ref; /** * The last error message to display, if any. */ errorMessage: Ref; /** * The last success message to display, if any. */ successMessage: Ref; /** * Submits the email, freezing the form while the request is in flight and * surfacing the outcome through the messages and the host `emit`. * * @returns A promise resolving once the submission settled. */ subscribe: () => Promise; } /** * Owns the newsletter submission flow for the `FormSignUp` component: the * subscriber email, the freeze/unfreeze lifecycle, the success/error messages, * and the `success`/`error`/`subscribed` events. Wraps {@link useSendEmail} to * perform the actual Mailchimp request. * * This composable is internal to the library and not exported from the public * entry point; consume it from a relative path. * * @param options - Submission payload and the host `emit` (see {@link UseSignUpFormOptions}). * @returns The {@link UseSignUpForm} API: the form state and the `subscribe` * action. * @example * import { useSignUpForm } from '@/composables/useSignUpForm' * * const emit = defineEmits(['error', 'success', 'subscribed']) * const { email, frozen, errorMessage, successMessage, subscribe } = useSignUpForm({ * action: props.action, * emailField: props.emailField, * tracker: props.tracker, * referrer: props.referrer, * defaultGroups: props.defaultGroups, * emit * }) */ export declare function useSignUpForm(options: UseSignUpFormOptions): UseSignUpForm; export default useSignUpForm;