@parafin/react 6.2.1 → 6.2.2
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/out/index.d.ts +3 -0
- package/out/index.js +7 -2
- package/package.json +1 -1
package/out/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
declare const ParafinWidget: (props: WidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export { ParafinWidget };
|
|
3
|
+
export type WidgetEvent = 'opted_in' | 'opted_out';
|
|
3
4
|
export type WidgetProps = {
|
|
4
5
|
token: string;
|
|
5
6
|
product: 'capital' | 'spend_card' | 'cash_account';
|
|
6
7
|
externalBusinessId?: string;
|
|
8
|
+
onEvent?: (eventType: WidgetEvent) => Promise<void> | void;
|
|
7
9
|
onExit?: () => void;
|
|
10
|
+
/** @deprecated Use onEvent with 'opted_in' event type instead */
|
|
8
11
|
onOptIn?: () => Promise<OptInFields>;
|
|
9
12
|
openInNewTab?: boolean;
|
|
10
13
|
};
|
package/out/index.js
CHANGED
|
@@ -114,8 +114,13 @@ const initializeWidget = (iframe, props) => {
|
|
|
114
114
|
break;
|
|
115
115
|
case 'opt-in':
|
|
116
116
|
if (props.onOptIn) {
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
try {
|
|
118
|
+
const optInFields = await props.onOptIn();
|
|
119
|
+
sendMessage({ message: 'opt-in', optInFields });
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
sendMessage({ message: 'opt-in', optInFields: undefined });
|
|
123
|
+
}
|
|
119
124
|
}
|
|
120
125
|
else {
|
|
121
126
|
sendMessage({ message: 'opt-in', optInFields: undefined });
|