Skip to content

Commit 4f3b1fe

Browse files
committed
match filename convention
1 parent 66c64bf commit 4f3b1fe

6 files changed

Lines changed: 65 additions & 3 deletions

File tree

packages/scripts/dist/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export * from "./digital-wallets";
6363
export * from "./mobile-cta";
6464
export * from "./live-frequency";
6565
export * from "./universal-opt-in";
66-
export * from "./stripeFinancialConnections";
66+
export * from "./stripe-financial-connections";
6767
export * from "./give-by-select";
6868
export * from "./url-params-to-body-attrs";
6969
export * from "./exit-intent-lightbox";

packages/scripts/dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export * from "./digital-wallets";
6363
export * from "./mobile-cta";
6464
export * from "./live-frequency";
6565
export * from "./universal-opt-in";
66-
export * from "./stripeFinancialConnections";
66+
export * from "./stripe-financial-connections";
6767
export * from "./give-by-select";
6868
export * from "./url-params-to-body-attrs";
6969
export * from "./exit-intent-lightbox";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* This component improves EN's implementation of Stripe Financial Connections.
3+
* Enhancements:
4+
* - When the modal is closed, it re-enables the submit button.
5+
*/
6+
export declare class StripeFinancialConnections {
7+
private stripeModalOpen;
8+
private logger;
9+
constructor();
10+
isStripeModalNode(node: Node): boolean;
11+
isStripeModalNodeWIthIframe(node: Node): boolean;
12+
onStripeModalOpen(): void;
13+
onStripeModalClose(): void;
14+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* This component improves EN's implementation of Stripe Financial Connections.
3+
* Enhancements:
4+
* - When the modal is closed, it re-enables the submit button.
5+
*/
6+
import { ENGrid, EngridLogger } from ".";
7+
export class StripeFinancialConnections {
8+
constructor() {
9+
this.stripeModalOpen = false;
10+
this.logger = new EngridLogger("Stripe Financial Connections", "black", "pink", "🏛️");
11+
const observer = new MutationObserver((mutations) => {
12+
mutations.forEach((mutation) => {
13+
mutation.addedNodes.forEach((node) => {
14+
if (!this.stripeModalOpen && this.isStripeModalNodeWIthIframe(node)) {
15+
this.logger.log("Stripe Financial Connections modal opened.");
16+
this.onStripeModalOpen();
17+
}
18+
});
19+
mutation.removedNodes.forEach((node) => {
20+
if (this.stripeModalOpen && this.isStripeModalNode(node)) {
21+
this.logger.log("Stripe Financial Connections modal closed.");
22+
this.onStripeModalClose();
23+
}
24+
});
25+
});
26+
});
27+
observer.observe(document.body, {
28+
childList: true,
29+
subtree: true,
30+
});
31+
}
32+
isStripeModalNode(node) {
33+
return (node instanceof HTMLElement &&
34+
node.hasAttribute("data-react-aria-top-layer"));
35+
}
36+
isStripeModalNodeWIthIframe(node) {
37+
return !!(this.isStripeModalNode(node) &&
38+
node instanceof HTMLElement &&
39+
node.querySelector('iframe[src*="js.stripe.com"]'));
40+
}
41+
onStripeModalOpen() {
42+
this.stripeModalOpen = true;
43+
}
44+
onStripeModalClose() {
45+
this.stripeModalOpen = false;
46+
ENGrid.enableSubmit();
47+
}
48+
}

packages/scripts/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export * from "./digital-wallets";
7979
export * from "./mobile-cta";
8080
export * from "./live-frequency";
8181
export * from "./universal-opt-in";
82-
export * from "./stripeFinancialConnections";
82+
export * from "./stripe-financial-connections";
8383
export * from "./give-by-select";
8484
export * from "./url-params-to-body-attrs";
8585
export * from "./exit-intent-lightbox";
File renamed without changes.

0 commit comments

Comments
 (0)