index.ts
44 lines
| 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 | hooks: { |
| 20 | useFormContext: typeof useFormContext; |
| 21 | useWatch: typeof useWatch; |
| 22 | useFormState: typeof useFormState; |
| 23 | useCurrencyFormatter: typeof useCurrencyFormatter; |
| 24 | useDonationSummary: typeof useDonationSummary; |
| 25 | useDonationFormSettings: typeof useDonationFormSettings; |
| 26 | useFormSubmitButton: typeof useFormSubmitButton; |
| 27 | useFormData: typeof useFormData; |
| 28 | }; |
| 29 | }; |
| 30 | }; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | if (!window.givewp) { |
| 35 | // @ts-ignore |
| 36 | window.givewp = { |
| 37 | // @ts-ignore |
| 38 | form: {}, |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | window.givewp.gateways = new GatewayRegistrar(); |
| 43 | window.givewp.form.templates = Object.freeze(defaultFormTemplates); |
| 44 |