@duffel/components 3.1.7 → 3.1.8--canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ import { DuffelCardFormProps } from "./lib/types";
3
+ export declare const DuffelCardForm: React.FC<DuffelCardFormProps>;
@@ -0,0 +1,13 @@
1
+ import { DuffelCardFormProps } from "./DuffelCardForm";
2
+ declare global {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ "duffel-card-form": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
6
+ }
7
+ }
8
+ }
9
+ type DuffelCardFormCustomElementRenderArguments = Pick<DuffelCardFormProps, "clientKey" | "styles" | "shouldUseLocalTokenProxy">;
10
+ export declare function renderDuffelCardFormCustomElement(props: DuffelCardFormCustomElementRenderArguments): void;
11
+ export declare function onDuffelCardFormCardIdCreated(onCardIdCreated: DuffelCardFormProps["onStoreForTemporaryUseSuccess"]): void;
12
+ export declare function onDuffelCardFormCardIdCreationError(onCardIdCreationError: DuffelCardFormProps["onStoreForTemporaryUseFailure"]): void;
13
+ export {};
@@ -0,0 +1,6 @@
1
+ import { DuffelCardFormProps } from "./types";
2
+ type Inputs = {
3
+ setIFrameHeight: (height: string) => void;
4
+ } & Pick<DuffelCardFormProps, "onValidateSuccess" | "onValidateFailure" | "onStoreForTemporaryUseSuccess" | "onStoreForTemporaryUseFailure">;
5
+ export declare function getIFrameEventListener(baseUrl: string, { setIFrameHeight, onStoreForTemporaryUseSuccess, onStoreForTemporaryUseFailure, }: Inputs): (event: MessageEvent) => void;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare function getTokenFromClientKey(clientKey: string): string;
@@ -0,0 +1,60 @@
1
+ import { CustomStyles } from "src/types";
2
+ export interface StoreForTemporaryUseData {
3
+ id: string;
4
+ live_mode: false;
5
+ }
6
+ export interface StoreForTemporaryUseError {
7
+ status: number;
8
+ message: string;
9
+ }
10
+ export type DuffelCardFormStyles = Pick<CustomStyles, "fontFamily"> & {
11
+ stylesheetUrl?: string;
12
+ };
13
+ export type DuffelCardFormActions = "validate" | "store-for-temporary-use";
14
+ export interface DuffelCardFormProps {
15
+ /**
16
+ * The client key present in the Quote object.
17
+ */
18
+ clientKey: string;
19
+ /**
20
+ * The styles to apply to the iframe input elements.
21
+ */
22
+ styles?: DuffelCardFormStyles;
23
+ /**
24
+ * If you want to develop with a local deployment of the token proxy on port 8000. Set this flag to true.
25
+ */
26
+ shouldUseLocalTokenProxy?: boolean;
27
+ /**
28
+ * The actions you'd like the component to perform.
29
+ *
30
+ * This prop is a dependecy of a useEffect hook in the component
31
+ * and so when it's changed it will perform the action you specify.
32
+ *
33
+ * The action `store-for-temporary-use` will only happen once `validate` has been successful.
34
+ *
35
+ */
36
+ actions: DuffelCardFormActions[];
37
+ /**
38
+ * This function will be called when the card form validation has been successful.
39
+ */
40
+ onValidateSuccess: () => void;
41
+ /**
42
+ * If the card form validation is successful but data is changed afterwards,
43
+ * making it invalid, this function will be called.
44
+ */
45
+ onValidateFailure: () => void;
46
+ /**
47
+ * This function will be called when the card has been stored for temporary use.
48
+ *
49
+ * This callback will only be triggered if the `store-for-temporary-use`
50
+ * action is present in the `actions` prop.
51
+ */
52
+ onStoreForTemporaryUseSuccess: (data: StoreForTemporaryUseData) => void;
53
+ /**
54
+ * This function will be called when the component has failed to store the card for temporary use.
55
+ *
56
+ * This callback will only be triggered if the `store-for-temporary-use`
57
+ * action is present in the `actions` prop.
58
+ */
59
+ onStoreForTemporaryUseFailure: (error: StoreForTemporaryUseError) => void;
60
+ }
@@ -4,3 +4,4 @@
4
4
  */
5
5
  export { onDuffelAncillariesPayloadReady, renderDuffelAncillariesCustomElement, } from "./components/DuffelAncillaries/DuffelAncillariesCustomElement";
6
6
  export { onDuffelPaymentsFailedPayment, onDuffelPaymentsSuccessfulPayment, renderDuffelPaymentsCustomElement, } from "./components/DuffelPayments/DuffelPaymentsCustomElement";
7
+ export { renderDuffelCardFormCustomElement, onDuffelCardFormCardIdCreated, onDuffelCardFormCardIdCreationError, } from "./components/DuffelCardForm/DuffelCardFormCustomElement";