@duffel/components 3.1.9 → 3.3.0
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.
- package/components/DuffelCardForm/DuffelCardForm.d.ts +3 -0
- package/components/DuffelCardForm/lib/getIFrameEventListener.d.ts +7 -0
- package/components/DuffelCardForm/lib/getTokenFromClientKey.d.ts +1 -0
- package/components/DuffelCardForm/lib/types.d.ts +79 -0
- package/custom-elements.js +2 -2
- package/custom-elements.js.map +2 -2
- package/index.d.ts +1 -0
- package/index.js +17 -17
- package/index.js.map +4 -4
- package/package.json +1 -1
- package/stories/DuffelCardForm.stories.d.ts +7 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/types/index.d.ts +1 -0
- /package/{types → tests/lib}/getSegmentDates.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DuffelCardFormProps } from "./types";
|
|
2
|
+
type Inputs = {
|
|
3
|
+
setIFrameHeight: (height: string) => void;
|
|
4
|
+
postMessageWithStyles: () => void;
|
|
5
|
+
} & Pick<DuffelCardFormProps, "onValidateSuccess" | "onValidateFailure" | "onCreateCardForTemporaryUseSuccess" | "onCreateCardForTemporaryUseFailure">;
|
|
6
|
+
export declare function getIFrameEventListener(baseUrl: string, { postMessageWithStyles, setIFrameHeight, onValidateSuccess, onValidateFailure, onCreateCardForTemporaryUseSuccess, onCreateCardForTemporaryUseFailure, }: Inputs): (event: MessageEvent) => void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTokenFromClientKey(clientKey: string): string;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface CreateCardForTemporaryUseData {
|
|
2
|
+
id: string;
|
|
3
|
+
live_mode: false;
|
|
4
|
+
}
|
|
5
|
+
export interface CreateCardForTemporaryUseError {
|
|
6
|
+
status: number;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* An object where each key value pair is a style to be applied.
|
|
11
|
+
* e.g. { 'background-image': 'red', 'color': '#000', 'margin-inline': '8px' }
|
|
12
|
+
*
|
|
13
|
+
* Note: If you rely on css variables these will not work as they are
|
|
14
|
+
* defined on a stylesheet the component does not have access to.
|
|
15
|
+
*/
|
|
16
|
+
type StylesMap = Record<string, string>;
|
|
17
|
+
export interface InteractiveElementStyles {
|
|
18
|
+
default?: StylesMap;
|
|
19
|
+
hover?: StylesMap;
|
|
20
|
+
active?: StylesMap;
|
|
21
|
+
focus?: StylesMap;
|
|
22
|
+
}
|
|
23
|
+
export interface DuffelCardFormStyles {
|
|
24
|
+
input?: InteractiveElementStyles;
|
|
25
|
+
select?: InteractiveElementStyles;
|
|
26
|
+
label?: StylesMap;
|
|
27
|
+
inputErrorMessage?: StylesMap;
|
|
28
|
+
sectionTitle?: StylesMap;
|
|
29
|
+
layoutGrid?: StylesMap;
|
|
30
|
+
}
|
|
31
|
+
export type DuffelCardFormActions = "validate" | "create-card-for-temporary-use";
|
|
32
|
+
export interface DuffelCardFormProps {
|
|
33
|
+
/**
|
|
34
|
+
* The client key present in the Quote object.
|
|
35
|
+
*/
|
|
36
|
+
clientKey: string;
|
|
37
|
+
/**
|
|
38
|
+
* The styles to apply to the iframe input elements.
|
|
39
|
+
*/
|
|
40
|
+
styles?: DuffelCardFormStyles;
|
|
41
|
+
/**
|
|
42
|
+
* If you want to develop with a local deployment of the token proxy on port 8000. Set this flag to true.
|
|
43
|
+
*/
|
|
44
|
+
shouldUseLocalTokenProxy?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The actions you'd like the component to perform.
|
|
47
|
+
*
|
|
48
|
+
* This prop is a dependecy of a useEffect hook in the component
|
|
49
|
+
* and so when it's changed it will perform the action you specify.
|
|
50
|
+
*
|
|
51
|
+
* The action `create-card-for-temporary-use` will only happen once `validate` has been successful.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
actions: DuffelCardFormActions[];
|
|
55
|
+
/**
|
|
56
|
+
* This function will be called when the card form validation has been successful.
|
|
57
|
+
*/
|
|
58
|
+
onValidateSuccess: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* If the card form validation is successful but data is changed afterwards,
|
|
61
|
+
* making it invalid, this function will be called.
|
|
62
|
+
*/
|
|
63
|
+
onValidateFailure: () => void;
|
|
64
|
+
/**
|
|
65
|
+
* This function will be called when the card has been created for temporary use.
|
|
66
|
+
*
|
|
67
|
+
* This callback will only be triggered if the `create-card-for-temporary-use`
|
|
68
|
+
* action is present in the `actions` prop.
|
|
69
|
+
*/
|
|
70
|
+
onCreateCardForTemporaryUseSuccess: (data: CreateCardForTemporaryUseData) => void;
|
|
71
|
+
/**
|
|
72
|
+
* This function will be called when the component has failed to create the card for temporary use.
|
|
73
|
+
*
|
|
74
|
+
* This callback will only be triggered if the `create-card-for-temporary-use`
|
|
75
|
+
* action is present in the `actions` prop.
|
|
76
|
+
*/
|
|
77
|
+
onCreateCardForTemporaryUseFailure: (error: CreateCardForTemporaryUseError) => void;
|
|
78
|
+
}
|
|
79
|
+
export {};
|