@justifi/webcomponents 0.0.13 → 0.0.15
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/dist/cjs/{index-4f753ffd.js → index-e1b45289.js} +64 -1
- package/dist/cjs/justifi-bank-account-form_3.cjs.entry.js +215 -0
- package/dist/cjs/{justifi-bank-account-form_4.cjs.entry.js → justifi-payments-list.cjs.entry.js} +1 -162
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/webcomponents.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/bank-account-form/bank-account-form.js +40 -1
- package/dist/collection/components/card-form/card-form.js +40 -1
- package/dist/collection/components/payment-method-form/message-event-types.js +2 -0
- package/dist/collection/components/payment-method-form/payment-method-form.js +42 -1
- package/dist/collection/components/payment-method-form/theme.js +1 -0
- package/dist/components/justifi-bank-account-form.js +17 -1
- package/dist/components/justifi-card-form.js +17 -1
- package/dist/components/payment-method-form.js +22 -1
- package/dist/esm/{index-3d88d85c.js → index-c1f569bd.js} +64 -1
- package/dist/esm/justifi-bank-account-form_3.entry.js +209 -0
- package/dist/esm/{justifi-bank-account-form_4.entry.js → justifi-payments-list.entry.js} +2 -160
- package/dist/esm/loader.js +4 -4
- package/dist/esm/webcomponents.js +4 -4
- package/dist/types/components/bank-account-form/bank-account-form.d.ts +5 -0
- package/dist/types/components/card-form/card-form.d.ts +5 -0
- package/dist/types/components/payment-method-form/message-event-types.d.ts +2 -0
- package/dist/types/components/payment-method-form/payment-method-form.d.ts +5 -0
- package/dist/types/components/payment-method-form/theme.d.ts +43 -0
- package/dist/types/components.d.ts +7 -0
- package/dist/types/stencil-public-runtime.d.ts +11 -0
- package/dist/webcomponents/p-1de39730.js +2 -0
- package/dist/webcomponents/p-f0eb5ed0.entry.js +1 -0
- package/dist/webcomponents/p-f91b7b05.entry.js +1 -0
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +2 -2
- package/readme.md +11 -72
- package/dist/webcomponents/p-338453e1.entry.js +0 -1
- package/dist/webcomponents/p-de108437.js +0 -2
|
@@ -2,6 +2,8 @@ import { h } from '@stencil/core';
|
|
|
2
2
|
export class CardForm {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.validationStrategy = undefined;
|
|
5
|
+
this.styleOverrides = undefined;
|
|
6
|
+
this.internalStyleOverrides = undefined;
|
|
5
7
|
}
|
|
6
8
|
readyHandler(event) {
|
|
7
9
|
this.cardFormReady.emit(event);
|
|
@@ -12,6 +14,15 @@ export class CardForm {
|
|
|
12
14
|
validateHandler(event) {
|
|
13
15
|
this.cardFormValidate.emit(event);
|
|
14
16
|
}
|
|
17
|
+
componentWillLoad() {
|
|
18
|
+
this.parseStyleOverrides();
|
|
19
|
+
}
|
|
20
|
+
parseStyleOverrides() {
|
|
21
|
+
if (this.styleOverrides) {
|
|
22
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
23
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
15
26
|
async tokenize(...args) {
|
|
16
27
|
if (!this.childRef) {
|
|
17
28
|
throw new Error('Cannot call tokenize');
|
|
@@ -29,7 +40,7 @@ export class CardForm {
|
|
|
29
40
|
if (el) {
|
|
30
41
|
this.childRef = el;
|
|
31
42
|
}
|
|
32
|
-
}, "payment-method-form-type": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit' }));
|
|
43
|
+
}, "payment-method-form-type": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
|
|
33
44
|
}
|
|
34
45
|
static get is() { return "justifi-card-form"; }
|
|
35
46
|
static get properties() {
|
|
@@ -50,9 +61,31 @@ export class CardForm {
|
|
|
50
61
|
},
|
|
51
62
|
"attribute": "validation-strategy",
|
|
52
63
|
"reflect": false
|
|
64
|
+
},
|
|
65
|
+
"styleOverrides": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"mutable": false,
|
|
68
|
+
"complexType": {
|
|
69
|
+
"original": "string",
|
|
70
|
+
"resolved": "string",
|
|
71
|
+
"references": {}
|
|
72
|
+
},
|
|
73
|
+
"required": false,
|
|
74
|
+
"optional": true,
|
|
75
|
+
"docs": {
|
|
76
|
+
"tags": [],
|
|
77
|
+
"text": ""
|
|
78
|
+
},
|
|
79
|
+
"attribute": "style-overrides",
|
|
80
|
+
"reflect": false
|
|
53
81
|
}
|
|
54
82
|
};
|
|
55
83
|
}
|
|
84
|
+
static get states() {
|
|
85
|
+
return {
|
|
86
|
+
"internalStyleOverrides": {}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
56
89
|
static get events() {
|
|
57
90
|
return [{
|
|
58
91
|
"method": "cardFormReady",
|
|
@@ -146,6 +179,12 @@ export class CardForm {
|
|
|
146
179
|
}
|
|
147
180
|
};
|
|
148
181
|
}
|
|
182
|
+
static get watchers() {
|
|
183
|
+
return [{
|
|
184
|
+
"propName": "styleOverrides",
|
|
185
|
+
"methodName": "parseStyleOverrides"
|
|
186
|
+
}];
|
|
187
|
+
}
|
|
149
188
|
static get listeners() {
|
|
150
189
|
return [{
|
|
151
190
|
"name": "paymentMethodFormReady",
|
|
@@ -4,11 +4,13 @@ export const MessageEventType = {
|
|
|
4
4
|
tokenize: 'justifi.card.tokenize',
|
|
5
5
|
validate: 'justifi.card.validate',
|
|
6
6
|
resize: 'justifi.card.resize',
|
|
7
|
+
styleOverrides: 'justifi.card.styleOverrides',
|
|
7
8
|
},
|
|
8
9
|
bankAccount: {
|
|
9
10
|
ready: 'justifi.bankAccount.ready',
|
|
10
11
|
tokenize: 'justifi.bankAccount.tokenize',
|
|
11
12
|
validate: 'justifi.bankAccount.validate',
|
|
12
13
|
resize: 'justifi.bankAccount.resize',
|
|
14
|
+
styleOverrides: 'justifi.bankAccount.styleOverrides',
|
|
13
15
|
}
|
|
14
16
|
};
|
|
@@ -4,6 +4,7 @@ export class PaymentMethodForm {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
this.paymentMethodFormType = undefined;
|
|
6
6
|
this.paymentMethodFormValidationStrategy = undefined;
|
|
7
|
+
this.paymentMethodStyleOverrides = undefined;
|
|
7
8
|
this.height = 55;
|
|
8
9
|
}
|
|
9
10
|
connectedCallback() {
|
|
@@ -12,6 +13,14 @@ export class PaymentMethodForm {
|
|
|
12
13
|
disconnectedCallback() {
|
|
13
14
|
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
14
15
|
}
|
|
16
|
+
componentShouldUpdate() {
|
|
17
|
+
this.sendStyleOverrides();
|
|
18
|
+
}
|
|
19
|
+
sendStyleOverrides() {
|
|
20
|
+
if (this.paymentMethodStyleOverrides) {
|
|
21
|
+
this.postMessage(MessageEventType[this.paymentMethodFormType].styleOverrides, { styleOverrides: this.paymentMethodStyleOverrides });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
15
24
|
dispatchMessageEvent(messageEvent) {
|
|
16
25
|
const messagePayload = messageEvent.data;
|
|
17
26
|
const messageType = messagePayload.eventType;
|
|
@@ -23,6 +32,12 @@ export class PaymentMethodForm {
|
|
|
23
32
|
this.height = messageData.height;
|
|
24
33
|
}
|
|
25
34
|
}
|
|
35
|
+
postMessage(eventType, payload) {
|
|
36
|
+
if (this.iframeElement) {
|
|
37
|
+
this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
;
|
|
26
41
|
async postMessageWithResponseListener(eventType, payload) {
|
|
27
42
|
return new Promise((resolve) => {
|
|
28
43
|
const responseListener = (event) => {
|
|
@@ -32,7 +47,7 @@ export class PaymentMethodForm {
|
|
|
32
47
|
resolve(event.data.data);
|
|
33
48
|
};
|
|
34
49
|
window.addEventListener('message', responseListener);
|
|
35
|
-
this.
|
|
50
|
+
this.postMessage(eventType, payload);
|
|
36
51
|
});
|
|
37
52
|
}
|
|
38
53
|
async tokenize(clientKey, paymentMethodMetadata, account) {
|
|
@@ -105,6 +120,26 @@ export class PaymentMethodForm {
|
|
|
105
120
|
},
|
|
106
121
|
"attribute": "payment-method-form-validation-strategy",
|
|
107
122
|
"reflect": false
|
|
123
|
+
},
|
|
124
|
+
"paymentMethodStyleOverrides": {
|
|
125
|
+
"type": "unknown",
|
|
126
|
+
"mutable": false,
|
|
127
|
+
"complexType": {
|
|
128
|
+
"original": "Theme | undefined",
|
|
129
|
+
"resolved": "Theme",
|
|
130
|
+
"references": {
|
|
131
|
+
"Theme": {
|
|
132
|
+
"location": "import",
|
|
133
|
+
"path": "./theme"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"required": false,
|
|
138
|
+
"optional": false,
|
|
139
|
+
"docs": {
|
|
140
|
+
"tags": [],
|
|
141
|
+
"text": ""
|
|
142
|
+
}
|
|
108
143
|
}
|
|
109
144
|
};
|
|
110
145
|
}
|
|
@@ -191,4 +226,10 @@ export class PaymentMethodForm {
|
|
|
191
226
|
}
|
|
192
227
|
};
|
|
193
228
|
}
|
|
229
|
+
static get watchers() {
|
|
230
|
+
return [{
|
|
231
|
+
"propName": "paymentMethodStyleOverrides",
|
|
232
|
+
"methodName": "sendStyleOverrides"
|
|
233
|
+
}];
|
|
234
|
+
}
|
|
194
235
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,6 +9,8 @@ const BankAccountForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
9
9
|
this.bankAccountFormTokenize = createEvent(this, "bankAccountFormTokenize", 7);
|
|
10
10
|
this.bankAccountFormValidate = createEvent(this, "bankAccountFormValidate", 7);
|
|
11
11
|
this.validationStrategy = undefined;
|
|
12
|
+
this.styleOverrides = undefined;
|
|
13
|
+
this.internalStyleOverrides = undefined;
|
|
12
14
|
}
|
|
13
15
|
readyHandler(event) {
|
|
14
16
|
this.bankAccountFormReady.emit(event);
|
|
@@ -19,6 +21,15 @@ const BankAccountForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
19
21
|
validateHandler(event) {
|
|
20
22
|
this.bankAccountFormValidate.emit(event);
|
|
21
23
|
}
|
|
24
|
+
componentWillLoad() {
|
|
25
|
+
this.parseStyleOverrides();
|
|
26
|
+
}
|
|
27
|
+
parseStyleOverrides() {
|
|
28
|
+
if (this.styleOverrides) {
|
|
29
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
30
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
async tokenize(...args) {
|
|
23
34
|
if (!this.childRef) {
|
|
24
35
|
throw new Error('Cannot call tokenize');
|
|
@@ -36,10 +47,15 @@ const BankAccountForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
36
47
|
if (el) {
|
|
37
48
|
this.childRef = el;
|
|
38
49
|
}
|
|
39
|
-
}, "payment-method-form-type": "bankAccount", "payment-method-form-ready": this.bankAccountFormReady, "payment-method-form-tokenize": this.bankAccountFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit' }));
|
|
50
|
+
}, "payment-method-form-type": "bankAccount", "payment-method-form-ready": this.bankAccountFormReady, "payment-method-form-tokenize": this.bankAccountFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
|
|
40
51
|
}
|
|
52
|
+
static get watchers() { return {
|
|
53
|
+
"styleOverrides": ["parseStyleOverrides"]
|
|
54
|
+
}; }
|
|
41
55
|
}, [0, "justifi-bank-account-form", {
|
|
42
56
|
"validationStrategy": [1, "validation-strategy"],
|
|
57
|
+
"styleOverrides": [1, "style-overrides"],
|
|
58
|
+
"internalStyleOverrides": [32],
|
|
43
59
|
"tokenize": [64],
|
|
44
60
|
"validate": [64]
|
|
45
61
|
}, [[0, "paymentMethodFormReady", "readyHandler"], [0, "paymentMethodFormTokenize", "tokenizeHandler"], [0, "paymentMethodFormValidate", "validateHandler"]]]);
|
|
@@ -9,6 +9,8 @@ const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
9
9
|
this.cardFormTokenize = createEvent(this, "cardFormTokenize", 7);
|
|
10
10
|
this.cardFormValidate = createEvent(this, "cardFormValidate", 7);
|
|
11
11
|
this.validationStrategy = undefined;
|
|
12
|
+
this.styleOverrides = undefined;
|
|
13
|
+
this.internalStyleOverrides = undefined;
|
|
12
14
|
}
|
|
13
15
|
readyHandler(event) {
|
|
14
16
|
this.cardFormReady.emit(event);
|
|
@@ -19,6 +21,15 @@ const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
19
21
|
validateHandler(event) {
|
|
20
22
|
this.cardFormValidate.emit(event);
|
|
21
23
|
}
|
|
24
|
+
componentWillLoad() {
|
|
25
|
+
this.parseStyleOverrides();
|
|
26
|
+
}
|
|
27
|
+
parseStyleOverrides() {
|
|
28
|
+
if (this.styleOverrides) {
|
|
29
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
30
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
async tokenize(...args) {
|
|
23
34
|
if (!this.childRef) {
|
|
24
35
|
throw new Error('Cannot call tokenize');
|
|
@@ -36,10 +47,15 @@ const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
36
47
|
if (el) {
|
|
37
48
|
this.childRef = el;
|
|
38
49
|
}
|
|
39
|
-
}, "payment-method-form-type": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit' }));
|
|
50
|
+
}, "payment-method-form-type": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
|
|
40
51
|
}
|
|
52
|
+
static get watchers() { return {
|
|
53
|
+
"styleOverrides": ["parseStyleOverrides"]
|
|
54
|
+
}; }
|
|
41
55
|
}, [0, "justifi-card-form", {
|
|
42
56
|
"validationStrategy": [1, "validation-strategy"],
|
|
57
|
+
"styleOverrides": [1, "style-overrides"],
|
|
58
|
+
"internalStyleOverrides": [32],
|
|
43
59
|
"tokenize": [64],
|
|
44
60
|
"validate": [64]
|
|
45
61
|
}, [[0, "paymentMethodFormReady", "readyHandler"], [0, "paymentMethodFormTokenize", "tokenizeHandler"], [0, "paymentMethodFormValidate", "validateHandler"]]]);
|
|
@@ -6,12 +6,14 @@ const MessageEventType = {
|
|
|
6
6
|
tokenize: 'justifi.card.tokenize',
|
|
7
7
|
validate: 'justifi.card.validate',
|
|
8
8
|
resize: 'justifi.card.resize',
|
|
9
|
+
styleOverrides: 'justifi.card.styleOverrides',
|
|
9
10
|
},
|
|
10
11
|
bankAccount: {
|
|
11
12
|
ready: 'justifi.bankAccount.ready',
|
|
12
13
|
tokenize: 'justifi.bankAccount.tokenize',
|
|
13
14
|
validate: 'justifi.bankAccount.validate',
|
|
14
15
|
resize: 'justifi.bankAccount.resize',
|
|
16
|
+
styleOverrides: 'justifi.bankAccount.styleOverrides',
|
|
15
17
|
}
|
|
16
18
|
};
|
|
17
19
|
|
|
@@ -25,6 +27,7 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
25
27
|
this.paymentMethodFormTokenize = createEvent(this, "paymentMethodFormTokenize", 7);
|
|
26
28
|
this.paymentMethodFormType = undefined;
|
|
27
29
|
this.paymentMethodFormValidationStrategy = undefined;
|
|
30
|
+
this.paymentMethodStyleOverrides = undefined;
|
|
28
31
|
this.height = 55;
|
|
29
32
|
}
|
|
30
33
|
connectedCallback() {
|
|
@@ -33,6 +36,14 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
33
36
|
disconnectedCallback() {
|
|
34
37
|
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
35
38
|
}
|
|
39
|
+
componentShouldUpdate() {
|
|
40
|
+
this.sendStyleOverrides();
|
|
41
|
+
}
|
|
42
|
+
sendStyleOverrides() {
|
|
43
|
+
if (this.paymentMethodStyleOverrides) {
|
|
44
|
+
this.postMessage(MessageEventType[this.paymentMethodFormType].styleOverrides, { styleOverrides: this.paymentMethodStyleOverrides });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
36
47
|
dispatchMessageEvent(messageEvent) {
|
|
37
48
|
const messagePayload = messageEvent.data;
|
|
38
49
|
const messageType = messagePayload.eventType;
|
|
@@ -44,6 +55,12 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
44
55
|
this.height = messageData.height;
|
|
45
56
|
}
|
|
46
57
|
}
|
|
58
|
+
postMessage(eventType, payload) {
|
|
59
|
+
if (this.iframeElement) {
|
|
60
|
+
this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
;
|
|
47
64
|
async postMessageWithResponseListener(eventType, payload) {
|
|
48
65
|
return new Promise((resolve) => {
|
|
49
66
|
const responseListener = (event) => {
|
|
@@ -53,7 +70,7 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
53
70
|
resolve(event.data.data);
|
|
54
71
|
};
|
|
55
72
|
window.addEventListener('message', responseListener);
|
|
56
|
-
this.
|
|
73
|
+
this.postMessage(eventType, payload);
|
|
57
74
|
});
|
|
58
75
|
}
|
|
59
76
|
async tokenize(clientKey, paymentMethodMetadata, account) {
|
|
@@ -80,10 +97,14 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
80
97
|
render() {
|
|
81
98
|
return (h(Host, null, h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el, height: this.height })));
|
|
82
99
|
}
|
|
100
|
+
static get watchers() { return {
|
|
101
|
+
"paymentMethodStyleOverrides": ["sendStyleOverrides"]
|
|
102
|
+
}; }
|
|
83
103
|
static get style() { return paymentMethodFormCss; }
|
|
84
104
|
}, [0, "justifi-payment-method-form", {
|
|
85
105
|
"paymentMethodFormType": [1, "payment-method-form-type"],
|
|
86
106
|
"paymentMethodFormValidationStrategy": [1, "payment-method-form-validation-strategy"],
|
|
107
|
+
"paymentMethodStyleOverrides": [16],
|
|
87
108
|
"height": [32],
|
|
88
109
|
"tokenize": [64],
|
|
89
110
|
"validate": [64]
|
|
@@ -111,6 +111,14 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
111
111
|
}
|
|
112
112
|
return vnode;
|
|
113
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
116
|
+
* possible text content.
|
|
117
|
+
*
|
|
118
|
+
* @param tag the tag for this element
|
|
119
|
+
* @param text possible text content for the node
|
|
120
|
+
* @returns a newly-minted virtual DOM node
|
|
121
|
+
*/
|
|
114
122
|
const newVNode = (tag, text) => {
|
|
115
123
|
const vnode = {
|
|
116
124
|
$flags$: 0,
|
|
@@ -125,6 +133,12 @@ const newVNode = (tag, text) => {
|
|
|
125
133
|
return vnode;
|
|
126
134
|
};
|
|
127
135
|
const Host = {};
|
|
136
|
+
/**
|
|
137
|
+
* Check whether a given node is a Host node or not
|
|
138
|
+
*
|
|
139
|
+
* @param node the virtual DOM node to check
|
|
140
|
+
* @returns whether it's a Host node or not
|
|
141
|
+
*/
|
|
128
142
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
129
143
|
/**
|
|
130
144
|
* Parse a new property value for a given property type.
|
|
@@ -398,6 +412,21 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
398
412
|
}
|
|
399
413
|
return elm;
|
|
400
414
|
};
|
|
415
|
+
/**
|
|
416
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
417
|
+
* add them to the DOM in the appropriate place.
|
|
418
|
+
*
|
|
419
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
420
|
+
* DOM nodes
|
|
421
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
422
|
+
* inserted before (optional)
|
|
423
|
+
* @param parentVNode the parent virtual DOM node
|
|
424
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
425
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
426
|
+
* creating DOM nodes (inclusive)
|
|
427
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
428
|
+
* creating DOM nodes (inclusive)
|
|
429
|
+
*/
|
|
401
430
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
402
431
|
let containerElm = (parentElm);
|
|
403
432
|
let childNode;
|
|
@@ -414,6 +443,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
414
443
|
}
|
|
415
444
|
}
|
|
416
445
|
};
|
|
446
|
+
/**
|
|
447
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
448
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
449
|
+
* should no longer be shown.
|
|
450
|
+
*
|
|
451
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
452
|
+
*
|
|
453
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
454
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
455
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
456
|
+
* @param vnode a VNode
|
|
457
|
+
* @param elm an element
|
|
458
|
+
*/
|
|
417
459
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
418
460
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
419
461
|
if ((vnode = vnodes[startIdx])) {
|
|
@@ -606,7 +648,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
606
648
|
*
|
|
607
649
|
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
608
650
|
* changing order within a `children` array or something along those lines then
|
|
609
|
-
* we could obtain a false
|
|
651
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
652
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
610
653
|
*
|
|
611
654
|
* @param leftVNode the first VNode to check
|
|
612
655
|
* @param rightVNode the second VNode to check
|
|
@@ -673,6 +716,18 @@ const callNodeRefs = (vNode) => {
|
|
|
673
716
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
674
717
|
}
|
|
675
718
|
};
|
|
719
|
+
/**
|
|
720
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
721
|
+
*
|
|
722
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
723
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
724
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
725
|
+
* relocation, and reflecting attributes.
|
|
726
|
+
*
|
|
727
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
728
|
+
* the DOM node into which it should be rendered.
|
|
729
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
730
|
+
*/
|
|
676
731
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
677
732
|
const hostElm = hostRef.$hostElement$;
|
|
678
733
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
@@ -720,6 +775,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
720
775
|
hostRef.$queuedListeners$ = null;
|
|
721
776
|
}
|
|
722
777
|
}
|
|
778
|
+
{
|
|
779
|
+
promise = safeCall(instance, 'componentWillLoad');
|
|
780
|
+
}
|
|
723
781
|
}
|
|
724
782
|
endSchedule();
|
|
725
783
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
@@ -883,6 +941,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
883
941
|
}
|
|
884
942
|
}
|
|
885
943
|
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
944
|
+
if (instance.componentShouldUpdate) {
|
|
945
|
+
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
886
949
|
// looks like this value actually changed, so we've got work to do!
|
|
887
950
|
// but only if we've already rendered, otherwise just chill out
|
|
888
951
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, H as Host } from './index-c1f569bd.js';
|
|
2
|
+
|
|
3
|
+
const BankAccountForm = class {
|
|
4
|
+
constructor(hostRef) {
|
|
5
|
+
registerInstance(this, hostRef);
|
|
6
|
+
this.bankAccountFormReady = createEvent(this, "bankAccountFormReady", 7);
|
|
7
|
+
this.bankAccountFormTokenize = createEvent(this, "bankAccountFormTokenize", 7);
|
|
8
|
+
this.bankAccountFormValidate = createEvent(this, "bankAccountFormValidate", 7);
|
|
9
|
+
this.validationStrategy = undefined;
|
|
10
|
+
this.styleOverrides = undefined;
|
|
11
|
+
this.internalStyleOverrides = undefined;
|
|
12
|
+
}
|
|
13
|
+
readyHandler(event) {
|
|
14
|
+
this.bankAccountFormReady.emit(event);
|
|
15
|
+
}
|
|
16
|
+
tokenizeHandler(event) {
|
|
17
|
+
this.bankAccountFormTokenize.emit(event);
|
|
18
|
+
}
|
|
19
|
+
validateHandler(event) {
|
|
20
|
+
this.bankAccountFormValidate.emit(event);
|
|
21
|
+
}
|
|
22
|
+
componentWillLoad() {
|
|
23
|
+
this.parseStyleOverrides();
|
|
24
|
+
}
|
|
25
|
+
parseStyleOverrides() {
|
|
26
|
+
if (this.styleOverrides) {
|
|
27
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
28
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async tokenize(...args) {
|
|
32
|
+
if (!this.childRef) {
|
|
33
|
+
throw new Error('Cannot call tokenize');
|
|
34
|
+
}
|
|
35
|
+
return this.childRef.tokenize(...args);
|
|
36
|
+
}
|
|
37
|
+
async validate() {
|
|
38
|
+
if (!this.childRef) {
|
|
39
|
+
throw new Error('Cannot call validate');
|
|
40
|
+
}
|
|
41
|
+
return this.childRef.validate();
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
return (h("justifi-payment-method-form", { ref: el => {
|
|
45
|
+
if (el) {
|
|
46
|
+
this.childRef = el;
|
|
47
|
+
}
|
|
48
|
+
}, "payment-method-form-type": "bankAccount", "payment-method-form-ready": this.bankAccountFormReady, "payment-method-form-tokenize": this.bankAccountFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
|
|
49
|
+
}
|
|
50
|
+
static get watchers() { return {
|
|
51
|
+
"styleOverrides": ["parseStyleOverrides"]
|
|
52
|
+
}; }
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const CardForm = class {
|
|
56
|
+
constructor(hostRef) {
|
|
57
|
+
registerInstance(this, hostRef);
|
|
58
|
+
this.cardFormReady = createEvent(this, "cardFormReady", 7);
|
|
59
|
+
this.cardFormTokenize = createEvent(this, "cardFormTokenize", 7);
|
|
60
|
+
this.cardFormValidate = createEvent(this, "cardFormValidate", 7);
|
|
61
|
+
this.validationStrategy = undefined;
|
|
62
|
+
this.styleOverrides = undefined;
|
|
63
|
+
this.internalStyleOverrides = undefined;
|
|
64
|
+
}
|
|
65
|
+
readyHandler(event) {
|
|
66
|
+
this.cardFormReady.emit(event);
|
|
67
|
+
}
|
|
68
|
+
tokenizeHandler(event) {
|
|
69
|
+
this.cardFormTokenize.emit(event);
|
|
70
|
+
}
|
|
71
|
+
validateHandler(event) {
|
|
72
|
+
this.cardFormValidate.emit(event);
|
|
73
|
+
}
|
|
74
|
+
componentWillLoad() {
|
|
75
|
+
this.parseStyleOverrides();
|
|
76
|
+
}
|
|
77
|
+
parseStyleOverrides() {
|
|
78
|
+
if (this.styleOverrides) {
|
|
79
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
80
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async tokenize(...args) {
|
|
84
|
+
if (!this.childRef) {
|
|
85
|
+
throw new Error('Cannot call tokenize');
|
|
86
|
+
}
|
|
87
|
+
return this.childRef.tokenize(...args);
|
|
88
|
+
}
|
|
89
|
+
async validate() {
|
|
90
|
+
if (!this.childRef) {
|
|
91
|
+
throw new Error('Cannot call validate');
|
|
92
|
+
}
|
|
93
|
+
return this.childRef.validate();
|
|
94
|
+
}
|
|
95
|
+
render() {
|
|
96
|
+
return (h("justifi-payment-method-form", { ref: el => {
|
|
97
|
+
if (el) {
|
|
98
|
+
this.childRef = el;
|
|
99
|
+
}
|
|
100
|
+
}, "payment-method-form-type": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
|
|
101
|
+
}
|
|
102
|
+
static get watchers() { return {
|
|
103
|
+
"styleOverrides": ["parseStyleOverrides"]
|
|
104
|
+
}; }
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const MessageEventType = {
|
|
108
|
+
card: {
|
|
109
|
+
ready: 'justifi.card.ready',
|
|
110
|
+
tokenize: 'justifi.card.tokenize',
|
|
111
|
+
validate: 'justifi.card.validate',
|
|
112
|
+
resize: 'justifi.card.resize',
|
|
113
|
+
styleOverrides: 'justifi.card.styleOverrides',
|
|
114
|
+
},
|
|
115
|
+
bankAccount: {
|
|
116
|
+
ready: 'justifi.bankAccount.ready',
|
|
117
|
+
tokenize: 'justifi.bankAccount.tokenize',
|
|
118
|
+
validate: 'justifi.bankAccount.validate',
|
|
119
|
+
resize: 'justifi.bankAccount.resize',
|
|
120
|
+
styleOverrides: 'justifi.bankAccount.styleOverrides',
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const paymentMethodFormCss = ":host{display:block}justifi-payment-method-form iframe{border:none;width:100%}";
|
|
125
|
+
|
|
126
|
+
const PaymentMethodForm = class {
|
|
127
|
+
constructor(hostRef) {
|
|
128
|
+
registerInstance(this, hostRef);
|
|
129
|
+
this.paymentMethodFormReady = createEvent(this, "paymentMethodFormReady", 7);
|
|
130
|
+
this.paymentMethodFormTokenize = createEvent(this, "paymentMethodFormTokenize", 7);
|
|
131
|
+
this.paymentMethodFormType = undefined;
|
|
132
|
+
this.paymentMethodFormValidationStrategy = undefined;
|
|
133
|
+
this.paymentMethodStyleOverrides = undefined;
|
|
134
|
+
this.height = 55;
|
|
135
|
+
}
|
|
136
|
+
connectedCallback() {
|
|
137
|
+
window.addEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
138
|
+
}
|
|
139
|
+
disconnectedCallback() {
|
|
140
|
+
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
141
|
+
}
|
|
142
|
+
componentShouldUpdate() {
|
|
143
|
+
this.sendStyleOverrides();
|
|
144
|
+
}
|
|
145
|
+
sendStyleOverrides() {
|
|
146
|
+
if (this.paymentMethodStyleOverrides) {
|
|
147
|
+
this.postMessage(MessageEventType[this.paymentMethodFormType].styleOverrides, { styleOverrides: this.paymentMethodStyleOverrides });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
dispatchMessageEvent(messageEvent) {
|
|
151
|
+
const messagePayload = messageEvent.data;
|
|
152
|
+
const messageType = messagePayload.eventType;
|
|
153
|
+
const messageData = messagePayload.data;
|
|
154
|
+
if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
|
|
155
|
+
this.paymentMethodFormReady.emit(messageData);
|
|
156
|
+
}
|
|
157
|
+
if (messageType === MessageEventType[this.paymentMethodFormType].resize) {
|
|
158
|
+
this.height = messageData.height;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
postMessage(eventType, payload) {
|
|
162
|
+
if (this.iframeElement) {
|
|
163
|
+
this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
;
|
|
167
|
+
async postMessageWithResponseListener(eventType, payload) {
|
|
168
|
+
return new Promise((resolve) => {
|
|
169
|
+
const responseListener = (event) => {
|
|
170
|
+
if (event.data.eventType !== eventType)
|
|
171
|
+
return;
|
|
172
|
+
window.removeEventListener('message', responseListener);
|
|
173
|
+
resolve(event.data.data);
|
|
174
|
+
};
|
|
175
|
+
window.addEventListener('message', responseListener);
|
|
176
|
+
this.postMessage(eventType, payload);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
async tokenize(clientKey, paymentMethodMetadata, account) {
|
|
180
|
+
const eventType = MessageEventType[this.paymentMethodFormType].tokenize;
|
|
181
|
+
const payload = {
|
|
182
|
+
clientKey: clientKey,
|
|
183
|
+
paymentMethodMetadata: paymentMethodMetadata,
|
|
184
|
+
account: account
|
|
185
|
+
};
|
|
186
|
+
return this.postMessageWithResponseListener(eventType, payload);
|
|
187
|
+
}
|
|
188
|
+
;
|
|
189
|
+
async validate() {
|
|
190
|
+
return this.postMessageWithResponseListener(MessageEventType[this.paymentMethodFormType].validate);
|
|
191
|
+
}
|
|
192
|
+
;
|
|
193
|
+
getIframeSrc() {
|
|
194
|
+
let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
|
|
195
|
+
if (this.paymentMethodFormValidationStrategy) {
|
|
196
|
+
iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
|
|
197
|
+
}
|
|
198
|
+
return iframeSrc;
|
|
199
|
+
}
|
|
200
|
+
render() {
|
|
201
|
+
return (h(Host, null, h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el, height: this.height })));
|
|
202
|
+
}
|
|
203
|
+
static get watchers() { return {
|
|
204
|
+
"paymentMethodStyleOverrides": ["sendStyleOverrides"]
|
|
205
|
+
}; }
|
|
206
|
+
};
|
|
207
|
+
PaymentMethodForm.style = paymentMethodFormCss;
|
|
208
|
+
|
|
209
|
+
export { BankAccountForm as justifi_bank_account_form, CardForm as justifi_card_form, PaymentMethodForm as justifi_payment_method_form };
|