|
| 1 | +import {FunctionComponent} from 'react'; |
| 2 | +import * as stripeJs from '@stripe/stripe-js'; |
| 3 | +import {StripeError} from '@stripe/stripe-js'; |
| 4 | +import { |
| 5 | + ElementProps, |
| 6 | + PaymentElementProps as RootPaymentElementProps, |
| 7 | + ExpressCheckoutElementProps as RootExpressCheckoutElementProps, |
| 8 | +} from '../../types'; |
| 9 | + |
| 10 | +export interface CurrencySelectorElementProps extends ElementProps { |
| 11 | + /** |
| 12 | + * Triggered when the Element is fully rendered and can accept imperative `element.focus()` calls. |
| 13 | + * Called with a reference to the underlying [Element instance](https://stripe.com/docs/js/element). |
| 14 | + */ |
| 15 | + onReady?: (element: stripeJs.StripeCurrencySelectorElement) => any; |
| 16 | + |
| 17 | + /** |
| 18 | + * Triggered when the escape key is pressed within the Element. |
| 19 | + */ |
| 20 | + onEscape?: () => any; |
| 21 | + |
| 22 | + /** |
| 23 | + * Triggered when the Element fails to load. |
| 24 | + */ |
| 25 | + onLoadError?: (event: { |
| 26 | + elementType: 'currencySelector'; |
| 27 | + error: StripeError; |
| 28 | + }) => any; |
| 29 | + |
| 30 | + /** |
| 31 | + * Triggered when the [loader](https://stripe.com/docs/js/elements_object/create#stripe_elements-options-loader) UI is mounted to the DOM and ready to be displayed. |
| 32 | + */ |
| 33 | + onLoaderStart?: (event: {elementType: 'currencySelector'}) => any; |
| 34 | +} |
| 35 | + |
| 36 | +export type CurrencySelectorElementComponent = FunctionComponent< |
| 37 | + CurrencySelectorElementProps |
| 38 | +>; |
| 39 | + |
| 40 | +export interface BillingAddressElementProps extends ElementProps { |
| 41 | + options?: stripeJs.StripeCheckoutAddressElementOptions; |
| 42 | + onReady?: (element: stripeJs.StripeAddressElement) => any; |
| 43 | + onEscape?: () => any; |
| 44 | + onLoadError?: (event: {elementType: 'address'; error: StripeError}) => any; |
| 45 | + onLoaderStart?: (event: {elementType: 'address'}) => any; |
| 46 | +} |
| 47 | + |
| 48 | +export type BillingAddressElementComponent = FunctionComponent< |
| 49 | + BillingAddressElementProps |
| 50 | +>; |
| 51 | + |
| 52 | +export interface ShippingAddressElementProps extends ElementProps { |
| 53 | + options?: stripeJs.StripeCheckoutAddressElementOptions; |
| 54 | + onReady?: (element: stripeJs.StripeAddressElement) => any; |
| 55 | + onEscape?: () => any; |
| 56 | + onLoadError?: (event: {elementType: 'address'; error: StripeError}) => any; |
| 57 | + onLoaderStart?: (event: {elementType: 'address'}) => any; |
| 58 | +} |
| 59 | + |
| 60 | +export type ShippingAddressElementComponent = FunctionComponent< |
| 61 | + ShippingAddressElementProps |
| 62 | +>; |
| 63 | + |
| 64 | +export type PaymentElementProps = Omit<RootPaymentElementProps, 'options'> & { |
| 65 | + options?: stripeJs.StripeCheckoutPaymentElementOptions; |
| 66 | +}; |
| 67 | + |
| 68 | +export type PaymentElementComponent = FunctionComponent<PaymentElementProps>; |
| 69 | + |
| 70 | +export type ExpressCheckoutElementProps = Omit< |
| 71 | + RootExpressCheckoutElementProps, |
| 72 | + | 'options' |
| 73 | + | 'onClick' |
| 74 | + | 'onCancel' |
| 75 | + | 'onShippingAddressChange' |
| 76 | + | 'onShippingRateChange' |
| 77 | +> & {options?: stripeJs.StripeCheckoutExpressCheckoutElementOptions}; |
| 78 | + |
| 79 | +export type ExpressCheckoutElementComponent = FunctionComponent< |
| 80 | + ExpressCheckoutElementProps |
| 81 | +>; |
| 82 | + |
| 83 | +export interface TaxIdElementProps extends ElementProps { |
| 84 | + options: stripeJs.StripeTaxIdElementOptions; |
| 85 | + onChange?: (event: stripeJs.StripeTaxIdElementChangeEvent) => any; |
| 86 | + onReady?: (element: stripeJs.StripeTaxIdElement) => any; |
| 87 | + onEscape?: () => any; |
| 88 | + onLoadError?: (event: {elementType: 'taxId'; error: StripeError}) => any; |
| 89 | + onLoaderStart?: (event: {elementType: 'taxId'}) => any; |
| 90 | +} |
| 91 | + |
| 92 | +export type TaxIdElementComponent = FunctionComponent<TaxIdElementProps>; |
0 commit comments