| 1 |
import GatewayRegistrar from './gateways'; |
| 2 |
import type {DonationConfirmationReceiptServerExports, FormServerExports} from '@givewp/forms/types'; |
| 3 |
import type {useFormContext, useFormState, useWatch} from 'react-hook-form'; |
| 4 |
import defaultFormTemplates from './templates'; |
| 5 |
import useCurrencyFormatter from '@givewp/forms/app/hooks/useCurrencyFormatter'; |
| 6 |
import useDonationSummary from '@givewp/forms/app/hooks/useDonationSummary'; |
| 7 |
import {useDonationFormSettings} from '@givewp/forms/app/store/form-settings'; |
| 8 |
import useFormSubmitButton from '@givewp/forms/app/hooks/useFormSubmitButton'; |
| 9 |
import useFormData from '@givewp/forms/app/hooks/useFormData'; |
| 10 |
|
| 11 |
declare global { |
| 12 |
interface Window { |
| 13 |
givewpDonationFormExports: FormServerExports; |
| 14 |
givewpDonationConfirmationReceiptExports: DonationConfirmationReceiptServerExports; |
| 15 |
givewp: { |
| 16 |
gateways: GatewayRegistrar; |
| 17 |
form: { |
| 18 |
templates: typeof defaultFormTemplates; |
| 19 |
authToken?: string; |
| 20 |
hooks: { |
| 21 |
useFormContext: typeof useFormContext; |
| 22 |
useWatch: typeof useWatch; |
| 23 |
useFormState: typeof useFormState; |
| 24 |
useCurrencyFormatter: typeof useCurrencyFormatter; |
| 25 |
useDonationSummary: typeof useDonationSummary; |
| 26 |
useDonationFormSettings: typeof useDonationFormSettings; |
| 27 |
useFormSubmitButton: typeof useFormSubmitButton; |
| 28 |
useFormData: typeof useFormData; |
| 29 |
}; |
| 30 |
}; |
| 31 |
}; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
if (!window.givewp) { |
| 36 |
// @ts-ignore |
| 37 |
window.givewp = { |
| 38 |
// @ts-ignore |
| 39 |
form: {}, |
| 40 |
}; |
| 41 |
} |
| 42 |
|
| 43 |
window.givewp.gateways = new GatewayRegistrar(); |
| 44 |
window.givewp.form.templates = Object.freeze(defaultFormTemplates); |
| 45 |
|