@justifi/webcomponents 0.0.12 → 0.0.14

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.
Files changed (30) hide show
  1. package/dist/cjs/{index-4f753ffd.js → index-e1b45289.js} +64 -1
  2. package/dist/cjs/justifi-bank-account-form_4.cjs.entry.js +58 -8
  3. package/dist/cjs/loader.cjs.js +3 -3
  4. package/dist/cjs/webcomponents.cjs.js +3 -3
  5. package/dist/collection/collection-manifest.json +1 -1
  6. package/dist/collection/components/bank-account-form/bank-account-form.js +38 -1
  7. package/dist/collection/components/card-form/card-form.js +38 -1
  8. package/dist/collection/components/payment-method-form/message-event-types.js +7 -3
  9. package/dist/collection/components/payment-method-form/payment-method-form.js +52 -2
  10. package/dist/collection/components/payment-method-form/theme.js +1 -0
  11. package/dist/components/justifi-bank-account-form.js +15 -1
  12. package/dist/components/justifi-card-form.js +15 -1
  13. package/dist/components/payment-method-form.js +33 -5
  14. package/dist/esm/{index-3d88d85c.js → index-c1f569bd.js} +64 -1
  15. package/dist/esm/justifi-bank-account-form_4.entry.js +58 -8
  16. package/dist/esm/loader.js +4 -4
  17. package/dist/esm/webcomponents.js +4 -4
  18. package/dist/types/components/bank-account-form/bank-account-form.d.ts +5 -0
  19. package/dist/types/components/card-form/card-form.d.ts +5 -0
  20. package/dist/types/components/payment-method-form/message-event-types.d.ts +4 -0
  21. package/dist/types/components/payment-method-form/payment-method-form.d.ts +6 -0
  22. package/dist/types/components/payment-method-form/theme.d.ts +43 -0
  23. package/dist/types/components.d.ts +7 -0
  24. package/dist/types/stencil-public-runtime.d.ts +11 -0
  25. package/dist/webcomponents/p-1de39730.js +2 -0
  26. package/dist/webcomponents/p-d6caba00.entry.js +1 -0
  27. package/dist/webcomponents/webcomponents.esm.js +1 -1
  28. package/package.json +2 -2
  29. package/dist/webcomponents/p-8ad58e9a.entry.js +0 -1
  30. 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 positive and then have to do needless re-rendering.
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-4f753ffd.js');
5
+ const index = require('./index-e1b45289.js');
6
6
 
7
7
  const BankAccountForm = class {
8
8
  constructor(hostRef) {
@@ -11,6 +11,8 @@ const BankAccountForm = class {
11
11
  this.bankAccountFormTokenize = index.createEvent(this, "bankAccountFormTokenize", 7);
12
12
  this.bankAccountFormValidate = index.createEvent(this, "bankAccountFormValidate", 7);
13
13
  this.validationStrategy = undefined;
14
+ this.styleOverrides = undefined;
15
+ this.internalStyleOverrides = undefined;
14
16
  }
15
17
  readyHandler(event) {
16
18
  this.bankAccountFormReady.emit(event);
@@ -21,6 +23,13 @@ const BankAccountForm = class {
21
23
  validateHandler(event) {
22
24
  this.bankAccountFormValidate.emit(event);
23
25
  }
26
+ componentWillLoad() {
27
+ this.parseStyleOverrides();
28
+ }
29
+ parseStyleOverrides() {
30
+ const parsedStyleOverrides = JSON.parse(this.styleOverrides);
31
+ this.internalStyleOverrides = parsedStyleOverrides;
32
+ }
24
33
  async tokenize(...args) {
25
34
  if (!this.childRef) {
26
35
  throw new Error('Cannot call tokenize');
@@ -38,8 +47,11 @@ const BankAccountForm = class {
38
47
  if (el) {
39
48
  this.childRef = el;
40
49
  }
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' }));
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 }));
42
51
  }
52
+ static get watchers() { return {
53
+ "styleOverrides": ["parseStyleOverrides"]
54
+ }; }
43
55
  };
44
56
 
45
57
  const CardForm = class {
@@ -49,6 +61,8 @@ const CardForm = class {
49
61
  this.cardFormTokenize = index.createEvent(this, "cardFormTokenize", 7);
50
62
  this.cardFormValidate = index.createEvent(this, "cardFormValidate", 7);
51
63
  this.validationStrategy = undefined;
64
+ this.styleOverrides = undefined;
65
+ this.internalStyleOverrides = undefined;
52
66
  }
53
67
  readyHandler(event) {
54
68
  this.cardFormReady.emit(event);
@@ -59,6 +73,13 @@ const CardForm = class {
59
73
  validateHandler(event) {
60
74
  this.cardFormValidate.emit(event);
61
75
  }
76
+ componentWillLoad() {
77
+ this.parseStyleOverrides();
78
+ }
79
+ parseStyleOverrides() {
80
+ const parsedStyleOverrides = JSON.parse(this.styleOverrides);
81
+ this.internalStyleOverrides = parsedStyleOverrides;
82
+ }
62
83
  async tokenize(...args) {
63
84
  if (!this.childRef) {
64
85
  throw new Error('Cannot call tokenize');
@@ -76,8 +97,11 @@ const CardForm = class {
76
97
  if (el) {
77
98
  this.childRef = el;
78
99
  }
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' }));
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 }));
80
101
  }
102
+ static get watchers() { return {
103
+ "styleOverrides": ["parseStyleOverrides"]
104
+ }; }
81
105
  };
82
106
 
83
107
  const MessageEventType = {
@@ -85,11 +109,15 @@ const MessageEventType = {
85
109
  ready: 'justifi.card.ready',
86
110
  tokenize: 'justifi.card.tokenize',
87
111
  validate: 'justifi.card.validate',
112
+ resize: 'justifi.card.resize',
113
+ styleOverrides: 'justifi.card.styleOverrides',
88
114
  },
89
115
  bankAccount: {
90
- ready: 'justifi.bank_account.ready',
91
- tokenize: 'justifi.bank_account.tokenize',
92
- validate: 'justifi.bank_account.validate',
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',
93
121
  }
94
122
  };
95
123
 
@@ -102,6 +130,8 @@ const PaymentMethodForm = class {
102
130
  this.paymentMethodFormTokenize = index.createEvent(this, "paymentMethodFormTokenize", 7);
103
131
  this.paymentMethodFormType = undefined;
104
132
  this.paymentMethodFormValidationStrategy = undefined;
133
+ this.paymentMethodStyleOverrides = undefined;
134
+ this.height = 55;
105
135
  }
106
136
  connectedCallback() {
107
137
  window.addEventListener('message', this.dispatchMessageEvent.bind(this));
@@ -109,6 +139,14 @@ const PaymentMethodForm = class {
109
139
  disconnectedCallback() {
110
140
  window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
111
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
+ }
112
150
  dispatchMessageEvent(messageEvent) {
113
151
  const messagePayload = messageEvent.data;
114
152
  const messageType = messagePayload.eventType;
@@ -116,7 +154,16 @@ const PaymentMethodForm = class {
116
154
  if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
117
155
  this.paymentMethodFormReady.emit(messageData);
118
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
+ }
119
165
  }
166
+ ;
120
167
  async postMessageWithResponseListener(eventType, payload) {
121
168
  return new Promise((resolve) => {
122
169
  const responseListener = (event) => {
@@ -126,7 +173,7 @@ const PaymentMethodForm = class {
126
173
  resolve(event.data.data);
127
174
  };
128
175
  window.addEventListener('message', responseListener);
129
- this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
176
+ this.postMessage(eventType, payload);
130
177
  });
131
178
  }
132
179
  async tokenize(clientKey, paymentMethodMetadata, account) {
@@ -151,8 +198,11 @@ const PaymentMethodForm = class {
151
198
  return iframeSrc;
152
199
  }
153
200
  render() {
154
- return (index.h(index.Host, null, index.h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el })));
201
+ 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 })));
155
202
  }
203
+ static get watchers() { return {
204
+ "paymentMethodStyleOverrides": ["sendStyleOverrides"]
205
+ }; }
156
206
  };
157
207
  PaymentMethodForm.style = paymentMethodFormCss;
158
208
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-4f753ffd.js');
5
+ const index = require('./index-e1b45289.js');
6
6
 
7
7
  /*
8
- Stencil Client Patch Esm v2.22.1 | MIT Licensed | https://stenciljs.com
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-form_4.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1,"validation-strategy"],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[0,"justifi-card-form",{"validationStrategy":[1,"validation-strategy"],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}],[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1,"payment-method-form-validation-strategy"],"tokenize":[64],"validate":[64]}]]]], options);
17
+ return index.bootstrapLazy([["justifi-bank-account-form_4.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"]]],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}],[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-4f753ffd.js');
5
+ const index = require('./index-e1b45289.js');
6
6
 
7
7
  /*
8
- Stencil Client Patch Browser v2.22.1 | MIT Licensed | https://stenciljs.com
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-form_4.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1,"validation-strategy"],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[0,"justifi-card-form",{"validationStrategy":[1,"validation-strategy"],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}],[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1,"payment-method-form-validation-strategy"],"tokenize":[64],"validate":[64]}]]]], options);
20
+ return index.bootstrapLazy([["justifi-bank-account-form_4.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"]]],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}],[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;
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "compiler": {
9
9
  "name": "@stencil/core",
10
- "version": "2.22.1",
10
+ "version": "2.22.2",
11
11
  "typescriptVersion": "4.9.4"
12
12
  },
13
13
  "collections": [],
@@ -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,13 @@ export class BankAccountForm {
12
14
  validateHandler(event) {
13
15
  this.bankAccountFormValidate.emit(event);
14
16
  }
17
+ componentWillLoad() {
18
+ this.parseStyleOverrides();
19
+ }
20
+ parseStyleOverrides() {
21
+ const parsedStyleOverrides = JSON.parse(this.styleOverrides);
22
+ this.internalStyleOverrides = parsedStyleOverrides;
23
+ }
15
24
  async tokenize(...args) {
16
25
  if (!this.childRef) {
17
26
  throw new Error('Cannot call tokenize');
@@ -29,7 +38,7 @@ export class BankAccountForm {
29
38
  if (el) {
30
39
  this.childRef = el;
31
40
  }
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' }));
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', paymentMethodStyleOverrides: this.internalStyleOverrides }));
33
42
  }
34
43
  static get is() { return "justifi-bank-account-form"; }
35
44
  static get properties() {
@@ -50,9 +59,31 @@ export class BankAccountForm {
50
59
  },
51
60
  "attribute": "validation-strategy",
52
61
  "reflect": false
62
+ },
63
+ "styleOverrides": {
64
+ "type": "string",
65
+ "mutable": false,
66
+ "complexType": {
67
+ "original": "string",
68
+ "resolved": "string",
69
+ "references": {}
70
+ },
71
+ "required": false,
72
+ "optional": true,
73
+ "docs": {
74
+ "tags": [],
75
+ "text": ""
76
+ },
77
+ "attribute": "style-overrides",
78
+ "reflect": false
53
79
  }
54
80
  };
55
81
  }
82
+ static get states() {
83
+ return {
84
+ "internalStyleOverrides": {}
85
+ };
86
+ }
56
87
  static get events() {
57
88
  return [{
58
89
  "method": "bankAccountFormReady",
@@ -146,6 +177,12 @@ export class BankAccountForm {
146
177
  }
147
178
  };
148
179
  }
180
+ static get watchers() {
181
+ return [{
182
+ "propName": "styleOverrides",
183
+ "methodName": "parseStyleOverrides"
184
+ }];
185
+ }
149
186
  static get listeners() {
150
187
  return [{
151
188
  "name": "paymentMethodFormReady",
@@ -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,13 @@ export class CardForm {
12
14
  validateHandler(event) {
13
15
  this.cardFormValidate.emit(event);
14
16
  }
17
+ componentWillLoad() {
18
+ this.parseStyleOverrides();
19
+ }
20
+ parseStyleOverrides() {
21
+ const parsedStyleOverrides = JSON.parse(this.styleOverrides);
22
+ this.internalStyleOverrides = parsedStyleOverrides;
23
+ }
15
24
  async tokenize(...args) {
16
25
  if (!this.childRef) {
17
26
  throw new Error('Cannot call tokenize');
@@ -29,7 +38,7 @@ export class CardForm {
29
38
  if (el) {
30
39
  this.childRef = el;
31
40
  }
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' }));
41
+ }, "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
42
  }
34
43
  static get is() { return "justifi-card-form"; }
35
44
  static get properties() {
@@ -50,9 +59,31 @@ export class CardForm {
50
59
  },
51
60
  "attribute": "validation-strategy",
52
61
  "reflect": false
62
+ },
63
+ "styleOverrides": {
64
+ "type": "string",
65
+ "mutable": false,
66
+ "complexType": {
67
+ "original": "string",
68
+ "resolved": "string",
69
+ "references": {}
70
+ },
71
+ "required": false,
72
+ "optional": true,
73
+ "docs": {
74
+ "tags": [],
75
+ "text": ""
76
+ },
77
+ "attribute": "style-overrides",
78
+ "reflect": false
53
79
  }
54
80
  };
55
81
  }
82
+ static get states() {
83
+ return {
84
+ "internalStyleOverrides": {}
85
+ };
86
+ }
56
87
  static get events() {
57
88
  return [{
58
89
  "method": "cardFormReady",
@@ -146,6 +177,12 @@ export class CardForm {
146
177
  }
147
178
  };
148
179
  }
180
+ static get watchers() {
181
+ return [{
182
+ "propName": "styleOverrides",
183
+ "methodName": "parseStyleOverrides"
184
+ }];
185
+ }
149
186
  static get listeners() {
150
187
  return [{
151
188
  "name": "paymentMethodFormReady",
@@ -3,10 +3,14 @@ export const MessageEventType = {
3
3
  ready: 'justifi.card.ready',
4
4
  tokenize: 'justifi.card.tokenize',
5
5
  validate: 'justifi.card.validate',
6
+ resize: 'justifi.card.resize',
7
+ styleOverrides: 'justifi.card.styleOverrides',
6
8
  },
7
9
  bankAccount: {
8
- ready: 'justifi.bank_account.ready',
9
- tokenize: 'justifi.bank_account.tokenize',
10
- validate: 'justifi.bank_account.validate',
10
+ ready: 'justifi.bankAccount.ready',
11
+ tokenize: 'justifi.bankAccount.tokenize',
12
+ validate: 'justifi.bankAccount.validate',
13
+ resize: 'justifi.bankAccount.resize',
14
+ styleOverrides: 'justifi.bankAccount.styleOverrides',
11
15
  }
12
16
  };
@@ -4,6 +4,8 @@ export class PaymentMethodForm {
4
4
  constructor() {
5
5
  this.paymentMethodFormType = undefined;
6
6
  this.paymentMethodFormValidationStrategy = undefined;
7
+ this.paymentMethodStyleOverrides = undefined;
8
+ this.height = 55;
7
9
  }
8
10
  connectedCallback() {
9
11
  window.addEventListener('message', this.dispatchMessageEvent.bind(this));
@@ -11,6 +13,14 @@ export class PaymentMethodForm {
11
13
  disconnectedCallback() {
12
14
  window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
13
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
+ }
14
24
  dispatchMessageEvent(messageEvent) {
15
25
  const messagePayload = messageEvent.data;
16
26
  const messageType = messagePayload.eventType;
@@ -18,7 +28,16 @@ export class PaymentMethodForm {
18
28
  if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
19
29
  this.paymentMethodFormReady.emit(messageData);
20
30
  }
31
+ if (messageType === MessageEventType[this.paymentMethodFormType].resize) {
32
+ this.height = messageData.height;
33
+ }
34
+ }
35
+ postMessage(eventType, payload) {
36
+ if (this.iframeElement) {
37
+ this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
38
+ }
21
39
  }
40
+ ;
22
41
  async postMessageWithResponseListener(eventType, payload) {
23
42
  return new Promise((resolve) => {
24
43
  const responseListener = (event) => {
@@ -28,7 +47,7 @@ export class PaymentMethodForm {
28
47
  resolve(event.data.data);
29
48
  };
30
49
  window.addEventListener('message', responseListener);
31
- this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
50
+ this.postMessage(eventType, payload);
32
51
  });
33
52
  }
34
53
  async tokenize(clientKey, paymentMethodMetadata, account) {
@@ -53,7 +72,7 @@ export class PaymentMethodForm {
53
72
  return iframeSrc;
54
73
  }
55
74
  render() {
56
- return (h(Host, null, h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el })));
75
+ return (h(Host, null, h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el, height: this.height })));
57
76
  }
58
77
  static get is() { return "justifi-payment-method-form"; }
59
78
  static get originalStyleUrls() {
@@ -101,9 +120,34 @@ export class PaymentMethodForm {
101
120
  },
102
121
  "attribute": "payment-method-form-validation-strategy",
103
122
  "reflect": false
123
+ },
124
+ "paymentMethodStyleOverrides": {
125
+ "type": "unknown",
126
+ "mutable": false,
127
+ "complexType": {
128
+ "original": "Theme",
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
+ }
104
143
  }
105
144
  };
106
145
  }
146
+ static get states() {
147
+ return {
148
+ "height": {}
149
+ };
150
+ }
107
151
  static get events() {
108
152
  return [{
109
153
  "method": "paymentMethodFormReady",
@@ -182,4 +226,10 @@ export class PaymentMethodForm {
182
226
  }
183
227
  };
184
228
  }
229
+ static get watchers() {
230
+ return [{
231
+ "propName": "paymentMethodStyleOverrides",
232
+ "methodName": "sendStyleOverrides"
233
+ }];
234
+ }
185
235
  }
@@ -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,13 @@ 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
+ const parsedStyleOverrides = JSON.parse(this.styleOverrides);
29
+ this.internalStyleOverrides = parsedStyleOverrides;
30
+ }
22
31
  async tokenize(...args) {
23
32
  if (!this.childRef) {
24
33
  throw new Error('Cannot call tokenize');
@@ -36,10 +45,15 @@ const BankAccountForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
36
45
  if (el) {
37
46
  this.childRef = el;
38
47
  }
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' }));
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 }));
40
49
  }
50
+ static get watchers() { return {
51
+ "styleOverrides": ["parseStyleOverrides"]
52
+ }; }
41
53
  }, [0, "justifi-bank-account-form", {
42
54
  "validationStrategy": [1, "validation-strategy"],
55
+ "styleOverrides": [1, "style-overrides"],
56
+ "internalStyleOverrides": [32],
43
57
  "tokenize": [64],
44
58
  "validate": [64]
45
59
  }, [[0, "paymentMethodFormReady", "readyHandler"], [0, "paymentMethodFormTokenize", "tokenizeHandler"], [0, "paymentMethodFormValidate", "validateHandler"]]]);