import { Ref } from '../../node_modules/vue'; /** * The recurrence of a donation. `onetime` reuses the yearly thresholds for its * level derivation. */ export type DonationPeriod = 'onetime' | 'monthly' | 'yearly'; /** * The membership tier a donation falls into, used to highlight the matching * benefit column. */ export type DonationCategory = 'conversation' | 'rules' | 'world'; /** * Suggested donation amounts indexed by category, then by period. */ export type SuggestedDonation = Record>; /** * Maps an amount threshold to the category it unlocks, per period. The yearly * thresholds double as the `onetime` thresholds. */ export interface DonationThresholds { monthly: Record; yearly: Record; onetime?: Record; } /** * Inputs driving the donation derivation. They carry the i18n- and * config-sourced data the component owns, so the composable stays free of * translation and configuration concerns. */ export interface UseDonateFormOptions { /** * Amount thresholds per period that unlock each category. */ thresholds: DonationThresholds; /** * Suggested amounts per category and period. */ suggestedAmount: SuggestedDonation; } /** * Reactive API returned by {@link useDonateForm}. */ export interface UseDonateForm { /** * The current donation amount; `undefined` while the user clears the field. */ amount: Ref; /** * The selected recurrence. */ installmentPeriod: Ref; /** * The currently highlighted membership tier. */ level: Ref; /** * Picks a level and resets the amount to its suggested value. Note that the * suggested value is `undefined` once the amount is no longer pristine, so * selecting a level after a manual edit blanks the amount (preserved legacy * behavior). * * @param levelSelected - The tier the user clicked. */ selectLevel: (levelSelected: DonationCategory) => void; /** * Flags the amount as user-edited, freezing the automatic suggestions. */ amountIsNotPristine: () => void; } /** * Owns the donation amount/period/level state machine for the `FormDonate` * component: derives the active membership tier from the amount, suggests an * amount when the user picks a tier or switches period, and stops suggesting * once the amount has been edited by hand. * * This composable is internal to the library and not exported from the public * entry point; consume it from a relative path. * * @param options - i18n/config-sourced donation data (see {@link UseDonateFormOptions}). * @returns The {@link UseDonateForm} API: the reactive state and the level/amount * actions. * @example * import { useDonateForm } from '@/composables/useDonateForm' * * const { amount, installmentPeriod, level, selectLevel, amountIsNotPristine } = * useDonateForm({ thresholds, suggestedAmount }) */ export declare function useDonateForm(options: UseDonateFormOptions): UseDonateForm; export default useDonateForm;