@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
|
@@ -133,6 +133,14 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
133
133
|
}
|
|
134
134
|
return vnode;
|
|
135
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
138
|
+
* possible text content.
|
|
139
|
+
*
|
|
140
|
+
* @param tag the tag for this element
|
|
141
|
+
* @param text possible text content for the node
|
|
142
|
+
* @returns a newly-minted virtual DOM node
|
|
143
|
+
*/
|
|
136
144
|
const newVNode = (tag, text) => {
|
|
137
145
|
const vnode = {
|
|
138
146
|
$flags$: 0,
|
|
@@ -147,6 +155,12 @@ const newVNode = (tag, text) => {
|
|
|
147
155
|
return vnode;
|
|
148
156
|
};
|
|
149
157
|
const Host = {};
|
|
158
|
+
/**
|
|
159
|
+
* Check whether a given node is a Host node or not
|
|
160
|
+
*
|
|
161
|
+
* @param node the virtual DOM node to check
|
|
162
|
+
* @returns whether it's a Host node or not
|
|
163
|
+
*/
|
|
150
164
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
151
165
|
/**
|
|
152
166
|
* Parse a new property value for a given property type.
|
|
@@ -420,6 +434,21 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
420
434
|
}
|
|
421
435
|
return elm;
|
|
422
436
|
};
|
|
437
|
+
/**
|
|
438
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
439
|
+
* add them to the DOM in the appropriate place.
|
|
440
|
+
*
|
|
441
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
442
|
+
* DOM nodes
|
|
443
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
444
|
+
* inserted before (optional)
|
|
445
|
+
* @param parentVNode the parent virtual DOM node
|
|
446
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
447
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
448
|
+
* creating DOM nodes (inclusive)
|
|
449
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
450
|
+
* creating DOM nodes (inclusive)
|
|
451
|
+
*/
|
|
423
452
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
424
453
|
let containerElm = (parentElm);
|
|
425
454
|
let childNode;
|
|
@@ -436,6 +465,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
436
465
|
}
|
|
437
466
|
}
|
|
438
467
|
};
|
|
468
|
+
/**
|
|
469
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
470
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
471
|
+
* should no longer be shown.
|
|
472
|
+
*
|
|
473
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
474
|
+
*
|
|
475
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
476
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
477
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
478
|
+
* @param vnode a VNode
|
|
479
|
+
* @param elm an element
|
|
480
|
+
*/
|
|
439
481
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
440
482
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
441
483
|
if ((vnode = vnodes[startIdx])) {
|
|
@@ -628,7 +670,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
628
670
|
*
|
|
629
671
|
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
630
672
|
* changing order within a `children` array or something along those lines then
|
|
631
|
-
* we could obtain a false
|
|
673
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
674
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
632
675
|
*
|
|
633
676
|
* @param leftVNode the first VNode to check
|
|
634
677
|
* @param rightVNode the second VNode to check
|
|
@@ -695,6 +738,18 @@ const callNodeRefs = (vNode) => {
|
|
|
695
738
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
696
739
|
}
|
|
697
740
|
};
|
|
741
|
+
/**
|
|
742
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
743
|
+
*
|
|
744
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
745
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
746
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
747
|
+
* relocation, and reflecting attributes.
|
|
748
|
+
*
|
|
749
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
750
|
+
* the DOM node into which it should be rendered.
|
|
751
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
752
|
+
*/
|
|
698
753
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
699
754
|
const hostElm = hostRef.$hostElement$;
|
|
700
755
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
@@ -742,6 +797,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
742
797
|
hostRef.$queuedListeners$ = null;
|
|
743
798
|
}
|
|
744
799
|
}
|
|
800
|
+
{
|
|
801
|
+
promise = safeCall(instance, 'componentWillLoad');
|
|
802
|
+
}
|
|
745
803
|
}
|
|
746
804
|
endSchedule();
|
|
747
805
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
@@ -905,6 +963,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
905
963
|
}
|
|
906
964
|
}
|
|
907
965
|
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
966
|
+
if (instance.componentShouldUpdate) {
|
|
967
|
+
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
908
971
|
// looks like this value actually changed, so we've got work to do!
|
|
909
972
|
// but only if we've already rendered, otherwise just chill out
|
|
910
973
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-e1b45289.js');
|
|
6
|
+
|
|
7
|
+
const BankAccountForm = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
index.registerInstance(this, hostRef);
|
|
10
|
+
this.bankAccountFormReady = index.createEvent(this, "bankAccountFormReady", 7);
|
|
11
|
+
this.bankAccountFormTokenize = index.createEvent(this, "bankAccountFormTokenize", 7);
|
|
12
|
+
this.bankAccountFormValidate = index.createEvent(this, "bankAccountFormValidate", 7);
|
|
13
|
+
this.validationStrategy = undefined;
|
|
14
|
+
this.styleOverrides = undefined;
|
|
15
|
+
this.internalStyleOverrides = undefined;
|
|
16
|
+
}
|
|
17
|
+
readyHandler(event) {
|
|
18
|
+
this.bankAccountFormReady.emit(event);
|
|
19
|
+
}
|
|
20
|
+
tokenizeHandler(event) {
|
|
21
|
+
this.bankAccountFormTokenize.emit(event);
|
|
22
|
+
}
|
|
23
|
+
validateHandler(event) {
|
|
24
|
+
this.bankAccountFormValidate.emit(event);
|
|
25
|
+
}
|
|
26
|
+
componentWillLoad() {
|
|
27
|
+
this.parseStyleOverrides();
|
|
28
|
+
}
|
|
29
|
+
parseStyleOverrides() {
|
|
30
|
+
if (this.styleOverrides) {
|
|
31
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
32
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async tokenize(...args) {
|
|
36
|
+
if (!this.childRef) {
|
|
37
|
+
throw new Error('Cannot call tokenize');
|
|
38
|
+
}
|
|
39
|
+
return this.childRef.tokenize(...args);
|
|
40
|
+
}
|
|
41
|
+
async validate() {
|
|
42
|
+
if (!this.childRef) {
|
|
43
|
+
throw new Error('Cannot call validate');
|
|
44
|
+
}
|
|
45
|
+
return this.childRef.validate();
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
return (index.h("justifi-payment-method-form", { ref: el => {
|
|
49
|
+
if (el) {
|
|
50
|
+
this.childRef = el;
|
|
51
|
+
}
|
|
52
|
+
}, "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 }));
|
|
53
|
+
}
|
|
54
|
+
static get watchers() { return {
|
|
55
|
+
"styleOverrides": ["parseStyleOverrides"]
|
|
56
|
+
}; }
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const CardForm = class {
|
|
60
|
+
constructor(hostRef) {
|
|
61
|
+
index.registerInstance(this, hostRef);
|
|
62
|
+
this.cardFormReady = index.createEvent(this, "cardFormReady", 7);
|
|
63
|
+
this.cardFormTokenize = index.createEvent(this, "cardFormTokenize", 7);
|
|
64
|
+
this.cardFormValidate = index.createEvent(this, "cardFormValidate", 7);
|
|
65
|
+
this.validationStrategy = undefined;
|
|
66
|
+
this.styleOverrides = undefined;
|
|
67
|
+
this.internalStyleOverrides = undefined;
|
|
68
|
+
}
|
|
69
|
+
readyHandler(event) {
|
|
70
|
+
this.cardFormReady.emit(event);
|
|
71
|
+
}
|
|
72
|
+
tokenizeHandler(event) {
|
|
73
|
+
this.cardFormTokenize.emit(event);
|
|
74
|
+
}
|
|
75
|
+
validateHandler(event) {
|
|
76
|
+
this.cardFormValidate.emit(event);
|
|
77
|
+
}
|
|
78
|
+
componentWillLoad() {
|
|
79
|
+
this.parseStyleOverrides();
|
|
80
|
+
}
|
|
81
|
+
parseStyleOverrides() {
|
|
82
|
+
if (this.styleOverrides) {
|
|
83
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
84
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async tokenize(...args) {
|
|
88
|
+
if (!this.childRef) {
|
|
89
|
+
throw new Error('Cannot call tokenize');
|
|
90
|
+
}
|
|
91
|
+
return this.childRef.tokenize(...args);
|
|
92
|
+
}
|
|
93
|
+
async validate() {
|
|
94
|
+
if (!this.childRef) {
|
|
95
|
+
throw new Error('Cannot call validate');
|
|
96
|
+
}
|
|
97
|
+
return this.childRef.validate();
|
|
98
|
+
}
|
|
99
|
+
render() {
|
|
100
|
+
return (index.h("justifi-payment-method-form", { ref: el => {
|
|
101
|
+
if (el) {
|
|
102
|
+
this.childRef = el;
|
|
103
|
+
}
|
|
104
|
+
}, "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 }));
|
|
105
|
+
}
|
|
106
|
+
static get watchers() { return {
|
|
107
|
+
"styleOverrides": ["parseStyleOverrides"]
|
|
108
|
+
}; }
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const MessageEventType = {
|
|
112
|
+
card: {
|
|
113
|
+
ready: 'justifi.card.ready',
|
|
114
|
+
tokenize: 'justifi.card.tokenize',
|
|
115
|
+
validate: 'justifi.card.validate',
|
|
116
|
+
resize: 'justifi.card.resize',
|
|
117
|
+
styleOverrides: 'justifi.card.styleOverrides',
|
|
118
|
+
},
|
|
119
|
+
bankAccount: {
|
|
120
|
+
ready: 'justifi.bankAccount.ready',
|
|
121
|
+
tokenize: 'justifi.bankAccount.tokenize',
|
|
122
|
+
validate: 'justifi.bankAccount.validate',
|
|
123
|
+
resize: 'justifi.bankAccount.resize',
|
|
124
|
+
styleOverrides: 'justifi.bankAccount.styleOverrides',
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const paymentMethodFormCss = ":host{display:block}justifi-payment-method-form iframe{border:none;width:100%}";
|
|
129
|
+
|
|
130
|
+
const PaymentMethodForm = class {
|
|
131
|
+
constructor(hostRef) {
|
|
132
|
+
index.registerInstance(this, hostRef);
|
|
133
|
+
this.paymentMethodFormReady = index.createEvent(this, "paymentMethodFormReady", 7);
|
|
134
|
+
this.paymentMethodFormTokenize = index.createEvent(this, "paymentMethodFormTokenize", 7);
|
|
135
|
+
this.paymentMethodFormType = undefined;
|
|
136
|
+
this.paymentMethodFormValidationStrategy = undefined;
|
|
137
|
+
this.paymentMethodStyleOverrides = undefined;
|
|
138
|
+
this.height = 55;
|
|
139
|
+
}
|
|
140
|
+
connectedCallback() {
|
|
141
|
+
window.addEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
142
|
+
}
|
|
143
|
+
disconnectedCallback() {
|
|
144
|
+
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
145
|
+
}
|
|
146
|
+
componentShouldUpdate() {
|
|
147
|
+
this.sendStyleOverrides();
|
|
148
|
+
}
|
|
149
|
+
sendStyleOverrides() {
|
|
150
|
+
if (this.paymentMethodStyleOverrides) {
|
|
151
|
+
this.postMessage(MessageEventType[this.paymentMethodFormType].styleOverrides, { styleOverrides: this.paymentMethodStyleOverrides });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
dispatchMessageEvent(messageEvent) {
|
|
155
|
+
const messagePayload = messageEvent.data;
|
|
156
|
+
const messageType = messagePayload.eventType;
|
|
157
|
+
const messageData = messagePayload.data;
|
|
158
|
+
if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
|
|
159
|
+
this.paymentMethodFormReady.emit(messageData);
|
|
160
|
+
}
|
|
161
|
+
if (messageType === MessageEventType[this.paymentMethodFormType].resize) {
|
|
162
|
+
this.height = messageData.height;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
postMessage(eventType, payload) {
|
|
166
|
+
if (this.iframeElement) {
|
|
167
|
+
this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
;
|
|
171
|
+
async postMessageWithResponseListener(eventType, payload) {
|
|
172
|
+
return new Promise((resolve) => {
|
|
173
|
+
const responseListener = (event) => {
|
|
174
|
+
if (event.data.eventType !== eventType)
|
|
175
|
+
return;
|
|
176
|
+
window.removeEventListener('message', responseListener);
|
|
177
|
+
resolve(event.data.data);
|
|
178
|
+
};
|
|
179
|
+
window.addEventListener('message', responseListener);
|
|
180
|
+
this.postMessage(eventType, payload);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
async tokenize(clientKey, paymentMethodMetadata, account) {
|
|
184
|
+
const eventType = MessageEventType[this.paymentMethodFormType].tokenize;
|
|
185
|
+
const payload = {
|
|
186
|
+
clientKey: clientKey,
|
|
187
|
+
paymentMethodMetadata: paymentMethodMetadata,
|
|
188
|
+
account: account
|
|
189
|
+
};
|
|
190
|
+
return this.postMessageWithResponseListener(eventType, payload);
|
|
191
|
+
}
|
|
192
|
+
;
|
|
193
|
+
async validate() {
|
|
194
|
+
return this.postMessageWithResponseListener(MessageEventType[this.paymentMethodFormType].validate);
|
|
195
|
+
}
|
|
196
|
+
;
|
|
197
|
+
getIframeSrc() {
|
|
198
|
+
let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
|
|
199
|
+
if (this.paymentMethodFormValidationStrategy) {
|
|
200
|
+
iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
|
|
201
|
+
}
|
|
202
|
+
return iframeSrc;
|
|
203
|
+
}
|
|
204
|
+
render() {
|
|
205
|
+
return (index.h(index.Host, null, index.h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el, height: this.height })));
|
|
206
|
+
}
|
|
207
|
+
static get watchers() { return {
|
|
208
|
+
"paymentMethodStyleOverrides": ["sendStyleOverrides"]
|
|
209
|
+
}; }
|
|
210
|
+
};
|
|
211
|
+
PaymentMethodForm.style = paymentMethodFormCss;
|
|
212
|
+
|
|
213
|
+
exports.justifi_bank_account_form = BankAccountForm;
|
|
214
|
+
exports.justifi_card_form = CardForm;
|
|
215
|
+
exports.justifi_payment_method_form = PaymentMethodForm;
|
package/dist/cjs/{justifi-bank-account-form_4.cjs.entry.js → justifi-payments-list.cjs.entry.js}
RENAMED
|
@@ -2,165 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
6
|
-
|
|
7
|
-
const BankAccountForm = class {
|
|
8
|
-
constructor(hostRef) {
|
|
9
|
-
index.registerInstance(this, hostRef);
|
|
10
|
-
this.bankAccountFormReady = index.createEvent(this, "bankAccountFormReady", 7);
|
|
11
|
-
this.bankAccountFormTokenize = index.createEvent(this, "bankAccountFormTokenize", 7);
|
|
12
|
-
this.bankAccountFormValidate = index.createEvent(this, "bankAccountFormValidate", 7);
|
|
13
|
-
this.validationStrategy = undefined;
|
|
14
|
-
}
|
|
15
|
-
readyHandler(event) {
|
|
16
|
-
this.bankAccountFormReady.emit(event);
|
|
17
|
-
}
|
|
18
|
-
tokenizeHandler(event) {
|
|
19
|
-
this.bankAccountFormTokenize.emit(event);
|
|
20
|
-
}
|
|
21
|
-
validateHandler(event) {
|
|
22
|
-
this.bankAccountFormValidate.emit(event);
|
|
23
|
-
}
|
|
24
|
-
async tokenize(...args) {
|
|
25
|
-
if (!this.childRef) {
|
|
26
|
-
throw new Error('Cannot call tokenize');
|
|
27
|
-
}
|
|
28
|
-
return this.childRef.tokenize(...args);
|
|
29
|
-
}
|
|
30
|
-
async validate() {
|
|
31
|
-
if (!this.childRef) {
|
|
32
|
-
throw new Error('Cannot call validate');
|
|
33
|
-
}
|
|
34
|
-
return this.childRef.validate();
|
|
35
|
-
}
|
|
36
|
-
render() {
|
|
37
|
-
return (index.h("justifi-payment-method-form", { ref: el => {
|
|
38
|
-
if (el) {
|
|
39
|
-
this.childRef = el;
|
|
40
|
-
}
|
|
41
|
-
}, "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' }));
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const CardForm = class {
|
|
46
|
-
constructor(hostRef) {
|
|
47
|
-
index.registerInstance(this, hostRef);
|
|
48
|
-
this.cardFormReady = index.createEvent(this, "cardFormReady", 7);
|
|
49
|
-
this.cardFormTokenize = index.createEvent(this, "cardFormTokenize", 7);
|
|
50
|
-
this.cardFormValidate = index.createEvent(this, "cardFormValidate", 7);
|
|
51
|
-
this.validationStrategy = undefined;
|
|
52
|
-
}
|
|
53
|
-
readyHandler(event) {
|
|
54
|
-
this.cardFormReady.emit(event);
|
|
55
|
-
}
|
|
56
|
-
tokenizeHandler(event) {
|
|
57
|
-
this.cardFormTokenize.emit(event);
|
|
58
|
-
}
|
|
59
|
-
validateHandler(event) {
|
|
60
|
-
this.cardFormValidate.emit(event);
|
|
61
|
-
}
|
|
62
|
-
async tokenize(...args) {
|
|
63
|
-
if (!this.childRef) {
|
|
64
|
-
throw new Error('Cannot call tokenize');
|
|
65
|
-
}
|
|
66
|
-
return this.childRef.tokenize(...args);
|
|
67
|
-
}
|
|
68
|
-
async validate() {
|
|
69
|
-
if (!this.childRef) {
|
|
70
|
-
throw new Error('Cannot call validate');
|
|
71
|
-
}
|
|
72
|
-
return this.childRef.validate();
|
|
73
|
-
}
|
|
74
|
-
render() {
|
|
75
|
-
return (index.h("justifi-payment-method-form", { ref: el => {
|
|
76
|
-
if (el) {
|
|
77
|
-
this.childRef = el;
|
|
78
|
-
}
|
|
79
|
-
}, "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' }));
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const MessageEventType = {
|
|
84
|
-
card: {
|
|
85
|
-
ready: 'justifi.card.ready',
|
|
86
|
-
tokenize: 'justifi.card.tokenize',
|
|
87
|
-
validate: 'justifi.card.validate',
|
|
88
|
-
resize: 'justifi.card.resize',
|
|
89
|
-
},
|
|
90
|
-
bankAccount: {
|
|
91
|
-
ready: 'justifi.bankAccount.ready',
|
|
92
|
-
tokenize: 'justifi.bankAccount.tokenize',
|
|
93
|
-
validate: 'justifi.bankAccount.validate',
|
|
94
|
-
resize: 'justifi.bankAccount.resize',
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const paymentMethodFormCss = ":host{display:block}justifi-payment-method-form iframe{border:none;width:100%}";
|
|
99
|
-
|
|
100
|
-
const PaymentMethodForm = class {
|
|
101
|
-
constructor(hostRef) {
|
|
102
|
-
index.registerInstance(this, hostRef);
|
|
103
|
-
this.paymentMethodFormReady = index.createEvent(this, "paymentMethodFormReady", 7);
|
|
104
|
-
this.paymentMethodFormTokenize = index.createEvent(this, "paymentMethodFormTokenize", 7);
|
|
105
|
-
this.paymentMethodFormType = undefined;
|
|
106
|
-
this.paymentMethodFormValidationStrategy = undefined;
|
|
107
|
-
this.height = 55;
|
|
108
|
-
}
|
|
109
|
-
connectedCallback() {
|
|
110
|
-
window.addEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
111
|
-
}
|
|
112
|
-
disconnectedCallback() {
|
|
113
|
-
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
114
|
-
}
|
|
115
|
-
dispatchMessageEvent(messageEvent) {
|
|
116
|
-
const messagePayload = messageEvent.data;
|
|
117
|
-
const messageType = messagePayload.eventType;
|
|
118
|
-
const messageData = messagePayload.data;
|
|
119
|
-
if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
|
|
120
|
-
this.paymentMethodFormReady.emit(messageData);
|
|
121
|
-
}
|
|
122
|
-
if (messageType === MessageEventType[this.paymentMethodFormType].resize) {
|
|
123
|
-
this.height = messageData.height;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async postMessageWithResponseListener(eventType, payload) {
|
|
127
|
-
return new Promise((resolve) => {
|
|
128
|
-
const responseListener = (event) => {
|
|
129
|
-
if (event.data.eventType !== eventType)
|
|
130
|
-
return;
|
|
131
|
-
window.removeEventListener('message', responseListener);
|
|
132
|
-
resolve(event.data.data);
|
|
133
|
-
};
|
|
134
|
-
window.addEventListener('message', responseListener);
|
|
135
|
-
this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
async tokenize(clientKey, paymentMethodMetadata, account) {
|
|
139
|
-
const eventType = MessageEventType[this.paymentMethodFormType].tokenize;
|
|
140
|
-
const payload = {
|
|
141
|
-
clientKey: clientKey,
|
|
142
|
-
paymentMethodMetadata: paymentMethodMetadata,
|
|
143
|
-
account: account
|
|
144
|
-
};
|
|
145
|
-
return this.postMessageWithResponseListener(eventType, payload);
|
|
146
|
-
}
|
|
147
|
-
;
|
|
148
|
-
async validate() {
|
|
149
|
-
return this.postMessageWithResponseListener(MessageEventType[this.paymentMethodFormType].validate);
|
|
150
|
-
}
|
|
151
|
-
;
|
|
152
|
-
getIframeSrc() {
|
|
153
|
-
let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
|
|
154
|
-
if (this.paymentMethodFormValidationStrategy) {
|
|
155
|
-
iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
|
|
156
|
-
}
|
|
157
|
-
return iframeSrc;
|
|
158
|
-
}
|
|
159
|
-
render() {
|
|
160
|
-
return (index.h(index.Host, null, index.h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el, height: this.height })));
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
PaymentMethodForm.style = paymentMethodFormCss;
|
|
5
|
+
const index = require('./index-e1b45289.js');
|
|
164
6
|
|
|
165
7
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
166
8
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
@@ -4390,7 +4232,4 @@ const PaymentsList = class {
|
|
|
4390
4232
|
};
|
|
4391
4233
|
PaymentsList.style = paymentsListCss;
|
|
4392
4234
|
|
|
4393
|
-
exports.justifi_bank_account_form = BankAccountForm;
|
|
4394
|
-
exports.justifi_card_form = CardForm;
|
|
4395
|
-
exports.justifi_payment_method_form = PaymentMethodForm;
|
|
4396
4235
|
exports.justifi_payments_list = PaymentsList;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-e1b45289.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
Stencil Client Patch Esm v2.22.
|
|
8
|
+
Stencil Client Patch Esm v2.22.2 | MIT Licensed | https://stenciljs.com
|
|
9
9
|
*/
|
|
10
10
|
const patchEsm = () => {
|
|
11
11
|
return index.promiseResolve();
|
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["justifi-bank-account-
|
|
17
|
+
return index.bootstrapLazy([["justifi-payments-list.cjs",[[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}]]],["justifi-bank-account-form_3.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1,"validation-strategy"],"styleOverrides":[1,"style-overrides"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[0,"justifi-card-form",{"validationStrategy":[1,"validation-strategy"],"styleOverrides":[1,"style-overrides"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1,"payment-method-form-validation-strategy"],"paymentMethodStyleOverrides":[16],"height":[32],"tokenize":[64],"validate":[64]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-e1b45289.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
Stencil Client Patch Browser v2.22.
|
|
8
|
+
Stencil Client Patch Browser v2.22.2 | MIT Licensed | https://stenciljs.com
|
|
9
9
|
*/
|
|
10
10
|
const patchBrowser = () => {
|
|
11
11
|
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('webcomponents.cjs.js', document.baseURI).href));
|
|
@@ -17,7 +17,7 @@ const patchBrowser = () => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(options => {
|
|
20
|
-
return index.bootstrapLazy([["justifi-bank-account-
|
|
20
|
+
return index.bootstrapLazy([["justifi-payments-list.cjs",[[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}]]],["justifi-bank-account-form_3.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1,"validation-strategy"],"styleOverrides":[1,"style-overrides"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[0,"justifi-card-form",{"validationStrategy":[1,"validation-strategy"],"styleOverrides":[1,"style-overrides"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1,"payment-method-form-validation-strategy"],"paymentMethodStyleOverrides":[16],"height":[32],"tokenize":[64],"validate":[64]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
exports.setNonce = index.setNonce;
|
|
@@ -2,6 +2,8 @@ import { h } from '@stencil/core';
|
|
|
2
2
|
export class BankAccountForm {
|
|
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.bankAccountFormReady.emit(event);
|
|
@@ -12,6 +14,15 @@ export class BankAccountForm {
|
|
|
12
14
|
validateHandler(event) {
|
|
13
15
|
this.bankAccountFormValidate.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 BankAccountForm {
|
|
|
29
40
|
if (el) {
|
|
30
41
|
this.childRef = el;
|
|
31
42
|
}
|
|
32
|
-
}, "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' }));
|
|
43
|
+
}, "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 }));
|
|
33
44
|
}
|
|
34
45
|
static get is() { return "justifi-bank-account-form"; }
|
|
35
46
|
static get properties() {
|
|
@@ -50,9 +61,31 @@ export class BankAccountForm {
|
|
|
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": "bankAccountFormReady",
|
|
@@ -146,6 +179,12 @@ export class BankAccountForm {
|
|
|
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",
|