@justifi/webcomponents 0.0.15 → 0.2.0

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 (64) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/changelog-template.hbs +41 -0
  3. package/dist/cjs/{index-e1b45289.js → index-3947d225.js} +65 -1
  4. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +59 -0
  5. package/dist/cjs/justifi-billing-form.cjs.entry.js +2150 -0
  6. package/dist/cjs/justifi-card-form.cjs.entry.js +59 -0
  7. package/dist/cjs/{justifi-bank-account-form_3.cjs.entry.js → justifi-payment-method-form.cjs.entry.js} +3 -109
  8. package/dist/cjs/justifi-payments-list.cjs.entry.js +1 -1
  9. package/dist/cjs/loader.cjs.js +3 -3
  10. package/dist/cjs/select-input_2.cjs.entry.js +59 -0
  11. package/dist/cjs/webcomponents.cjs.js +3 -3
  12. package/dist/collection/collection-manifest.json +5 -2
  13. package/dist/collection/components/bank-account-form/bank-account-form.js +1 -1
  14. package/dist/collection/components/billing-form/billing-form-schema.js +14 -0
  15. package/dist/collection/components/billing-form/billing-form.css +11 -0
  16. package/dist/collection/components/billing-form/billing-form.js +92 -0
  17. package/dist/collection/components/billing-form/state-options.js +243 -0
  18. package/dist/collection/components/card-form/card-form.js +1 -1
  19. package/dist/collection/components/payment-method-form/payment-method-form.js +3 -3
  20. package/dist/collection/components/select-input/select-input.css +7 -0
  21. package/dist/collection/components/select-input/select-input.js +144 -0
  22. package/dist/collection/components/text-input/text-input.css +7 -0
  23. package/dist/collection/components/text-input/text-input.js +126 -0
  24. package/dist/components/index.d.ts +3 -0
  25. package/dist/components/index.js +3 -0
  26. package/dist/components/justifi-billing-form.d.ts +11 -0
  27. package/dist/components/justifi-billing-form.js +2180 -0
  28. package/dist/components/payment-method-form.js +2 -2
  29. package/dist/components/select-input.d.ts +11 -0
  30. package/dist/components/select-input.js +6 -0
  31. package/dist/components/select-input2.js +52 -0
  32. package/dist/components/text-input.d.ts +11 -0
  33. package/dist/components/text-input.js +6 -0
  34. package/dist/components/text-input2.js +48 -0
  35. package/dist/esm/{index-c1f569bd.js → index-0bcf33c4.js} +65 -1
  36. package/dist/esm/justifi-bank-account-form.entry.js +55 -0
  37. package/dist/esm/justifi-billing-form.entry.js +2146 -0
  38. package/dist/esm/justifi-card-form.entry.js +55 -0
  39. package/dist/esm/justifi-payment-method-form.entry.js +105 -0
  40. package/dist/esm/justifi-payments-list.entry.js +1 -1
  41. package/dist/esm/loader.js +4 -4
  42. package/dist/esm/select-input_2.entry.js +54 -0
  43. package/dist/esm/webcomponents.js +4 -4
  44. package/dist/types/components/billing-form/billing-form-schema.d.ts +15 -0
  45. package/dist/types/components/billing-form/billing-form.d.ts +17 -0
  46. package/dist/types/components/billing-form/state-options.d.ts +5 -0
  47. package/dist/types/components/payment-method-form/payment-method-form.d.ts +1 -1
  48. package/dist/types/components/payment-method-form/theme.d.ts +3 -1
  49. package/dist/types/components/select-input/select-input.d.ts +18 -0
  50. package/dist/types/components/text-input/text-input.d.ts +14 -0
  51. package/dist/types/components.d.ts +72 -3
  52. package/dist/webcomponents/p-0cddfd4f.entry.js +1 -0
  53. package/dist/webcomponents/p-17badb93.entry.js +1 -0
  54. package/dist/webcomponents/p-7fd07095.entry.js +1 -0
  55. package/dist/webcomponents/p-864e32fd.entry.js +1 -0
  56. package/dist/webcomponents/{p-f91b7b05.entry.js → p-cecf0fe8.entry.js} +1 -1
  57. package/dist/webcomponents/p-d3dc4e0a.entry.js +1 -0
  58. package/dist/webcomponents/p-e82c9746.js +2 -0
  59. package/dist/webcomponents/webcomponents.esm.js +1 -1
  60. package/package.json +8 -3
  61. package/LICENSE +0 -21
  62. package/dist/esm/justifi-bank-account-form_3.entry.js +0 -209
  63. package/dist/webcomponents/p-1de39730.js +0 -2
  64. package/dist/webcomponents/p-f0eb5ed0.entry.js +0 -1
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-3947d225.js');
6
+
7
+ const CardForm = class {
8
+ constructor(hostRef) {
9
+ index.registerInstance(this, hostRef);
10
+ this.cardFormReady = index.createEvent(this, "cardFormReady", 7);
11
+ this.cardFormTokenize = index.createEvent(this, "cardFormTokenize", 7);
12
+ this.cardFormValidate = index.createEvent(this, "cardFormValidate", 7);
13
+ this.validationStrategy = undefined;
14
+ this.styleOverrides = undefined;
15
+ this.internalStyleOverrides = undefined;
16
+ }
17
+ readyHandler(event) {
18
+ this.cardFormReady.emit(event);
19
+ }
20
+ tokenizeHandler(event) {
21
+ this.cardFormTokenize.emit(event);
22
+ }
23
+ validateHandler(event) {
24
+ this.cardFormValidate.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": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
53
+ }
54
+ static get watchers() { return {
55
+ "styleOverrides": ["parseStyleOverrides"]
56
+ }; }
57
+ };
58
+
59
+ exports.justifi_card_form = CardForm;
@@ -2,111 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
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
- };
5
+ const index = require('./index-3947d225.js');
110
6
 
111
7
  const MessageEventType = {
112
8
  card: {
@@ -180,10 +76,10 @@ const PaymentMethodForm = class {
180
76
  this.postMessage(eventType, payload);
181
77
  });
182
78
  }
183
- async tokenize(clientKey, paymentMethodMetadata, account) {
79
+ async tokenize(clientId, paymentMethodMetadata, account) {
184
80
  const eventType = MessageEventType[this.paymentMethodFormType].tokenize;
185
81
  const payload = {
186
- clientKey: clientKey,
82
+ clientId: clientId,
187
83
  paymentMethodMetadata: paymentMethodMetadata,
188
84
  account: account
189
85
  };
@@ -210,6 +106,4 @@ const PaymentMethodForm = class {
210
106
  };
211
107
  PaymentMethodForm.style = paymentMethodFormCss;
212
108
 
213
- exports.justifi_bank_account_form = BankAccountForm;
214
- exports.justifi_card_form = CardForm;
215
109
  exports.justifi_payment_method_form = PaymentMethodForm;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-e1b45289.js');
5
+ const index = require('./index-3947d225.js');
6
6
 
7
7
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
8
8
  // require the crypto API and do not support built-in fallback to lower quality random number
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-e1b45289.js');
5
+ const index = require('./index-3947d225.js');
6
6
 
7
7
  /*
8
- Stencil Client Patch Esm v2.22.2 | MIT Licensed | https://stenciljs.com
8
+ Stencil Client Patch Esm v2.22.3 | 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-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);
17
+ return index.bootstrapLazy([["justifi-billing-form.cjs",[[1,"justifi-billing-form",{"billingFields":[32],"billingFieldsErrors":[32],"validate":[64]},[[0,"fieldReceivedInput","setFormValue"]]]]],["justifi-payment-method-form.cjs",[[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]}]]],["justifi-bank-account-form.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"]]]]],["justifi-card-form.cjs",[[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"]]]]],["justifi-payments-list.cjs",[[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}]]],["select-input_2.cjs",[[1,"select-input",{"name":[1],"label":[1],"defaultValue":[1,"default-value"],"error":[1],"options":[16],"internalValue":[32]}],[1,"text-input",{"name":[1],"label":[1],"defaultValue":[1,"default-value"],"error":[1],"internalValue":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-3947d225.js');
6
+
7
+ const selectInputCss = ":host{display:block}label{display:block}";
8
+
9
+ const SelectInput = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.fieldReceivedInput = index.createEvent(this, "fieldReceivedInput", 7);
13
+ this.name = undefined;
14
+ this.label = undefined;
15
+ this.defaultValue = undefined;
16
+ this.error = undefined;
17
+ this.options = undefined;
18
+ this.internalValue = '';
19
+ }
20
+ onInput(event) {
21
+ const target = event.target;
22
+ const name = target.getAttribute('name');
23
+ this.fieldReceivedInput.emit({ name: name, value: target.value });
24
+ }
25
+ ;
26
+ render() {
27
+ return (index.h(index.Host, null, index.h("label", null, this.label), index.h("select", { name: this.name, onInput: (event) => this.onInput(event) }, this.options.map((option) => {
28
+ return (index.h("option", { value: option.value }, option.label));
29
+ })), this.error && index.h("div", { style: { color: 'red' } }, this.error)));
30
+ }
31
+ };
32
+ SelectInput.style = selectInputCss;
33
+
34
+ const textInputCss = ":host{display:block}label{display:block}";
35
+
36
+ const TextInput = class {
37
+ constructor(hostRef) {
38
+ index.registerInstance(this, hostRef);
39
+ this.fieldReceivedInput = index.createEvent(this, "fieldReceivedInput", 7);
40
+ this.name = undefined;
41
+ this.label = undefined;
42
+ this.defaultValue = undefined;
43
+ this.error = undefined;
44
+ this.internalValue = '';
45
+ }
46
+ onInput(event) {
47
+ const target = event.target;
48
+ const name = target.getAttribute('name');
49
+ this.fieldReceivedInput.emit({ name: name, value: target.value });
50
+ }
51
+ ;
52
+ render() {
53
+ return (index.h(index.Host, null, index.h("label", null, this.label), index.h("input", { name: this.name, type: "text", onInput: (event) => this.onInput(event), value: this.internalValue || this.defaultValue }), this.error && index.h("div", { style: { color: 'red' } }, this.error)));
54
+ }
55
+ };
56
+ TextInput.style = textInputCss;
57
+
58
+ exports.select_input = SelectInput;
59
+ exports.text_input = TextInput;
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-e1b45289.js');
5
+ const index = require('./index-3947d225.js');
6
6
 
7
7
  /*
8
- Stencil Client Patch Browser v2.22.2 | MIT Licensed | https://stenciljs.com
8
+ Stencil Client Patch Browser v2.22.3 | 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-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);
20
+ return index.bootstrapLazy([["justifi-billing-form.cjs",[[1,"justifi-billing-form",{"billingFields":[32],"billingFieldsErrors":[32],"validate":[64]},[[0,"fieldReceivedInput","setFormValue"]]]]],["justifi-payment-method-form.cjs",[[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]}]]],["justifi-bank-account-form.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"]]]]],["justifi-card-form.cjs",[[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"]]]]],["justifi-payments-list.cjs",[[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}]]],["select-input_2.cjs",[[1,"select-input",{"name":[1],"label":[1],"defaultValue":[1,"default-value"],"error":[1],"options":[16],"internalValue":[32]}],[1,"text-input",{"name":[1],"label":[1],"defaultValue":[1,"default-value"],"error":[1],"internalValue":[32]}]]]], options);
21
21
  });
22
22
 
23
23
  exports.setNonce = index.setNonce;
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "entries": [
3
3
  "./components/bank-account-form/bank-account-form.js",
4
+ "./components/billing-form/billing-form.js",
4
5
  "./components/card-form/card-form.js",
5
6
  "./components/payment-method-form/payment-method-form.js",
6
- "./components/payments-list/payments-list.js"
7
+ "./components/payments-list/payments-list.js",
8
+ "./components/select-input/select-input.js",
9
+ "./components/text-input/text-input.js"
7
10
  ],
8
11
  "compiler": {
9
12
  "name": "@stencil/core",
10
- "version": "2.22.2",
13
+ "version": "2.22.3",
11
14
  "typescriptVersion": "4.9.4"
12
15
  },
13
16
  "collections": [],
@@ -138,7 +138,7 @@ export class BankAccountForm {
138
138
  return {
139
139
  "tokenize": {
140
140
  "complexType": {
141
- "signature": "(clientKey: string, paymentMethodMetadata: any, account?: string) => Promise<any>",
141
+ "signature": "(clientId: string, paymentMethodMetadata: any, account?: string) => Promise<any>",
142
142
  "parameters": [{
143
143
  "tags": [],
144
144
  "text": ""
@@ -0,0 +1,14 @@
1
+ import { object, string } from 'yup';
2
+ export const RegExZip = /^\d{5}/;
3
+ const BillingFormSchema = object({
4
+ // name: string().required('Enter name'),
5
+ address_line1: string().required('Enter street address'),
6
+ address_line2: string(),
7
+ address_city: string().required('Enter city'),
8
+ address_state: string().required('Choose state'),
9
+ address_postal_code: string()
10
+ .required('Enter ZIP')
11
+ .matches(RegExZip, 'Enter a valid ZIP')
12
+ .min(5, 'Enter a valid ZIP')
13
+ });
14
+ export default BillingFormSchema;
@@ -0,0 +1,11 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ label {
6
+ display: block;
7
+ }
8
+
9
+ input {
10
+ margin-bottom: 8px;
11
+ }
@@ -0,0 +1,92 @@
1
+ import { Host, h } from '@stencil/core';
2
+ import BillingFormSchema from './billing-form-schema';
3
+ import StateOptions from './state-options';
4
+ export class BillingForm {
5
+ constructor() {
6
+ this.billingFields = {
7
+ address_line1: '',
8
+ address_line2: '',
9
+ address_city: '',
10
+ address_state: '',
11
+ address_postal_code: ''
12
+ };
13
+ this.billingFieldsErrors = {};
14
+ }
15
+ setFormValue(event) {
16
+ const data = event.detail;
17
+ const billingFieldsClone = Object.assign({}, this.billingFields);
18
+ if (data.name) {
19
+ billingFieldsClone[data.name] = data.value;
20
+ this.billingFields = billingFieldsClone;
21
+ }
22
+ }
23
+ async validate() {
24
+ const newErrors = {};
25
+ let isValid = true;
26
+ try {
27
+ await BillingFormSchema.validate(this.billingFields, { abortEarly: false });
28
+ }
29
+ catch (err) {
30
+ isValid = false;
31
+ err.inner.map((item) => {
32
+ newErrors[item.path] = item.message;
33
+ });
34
+ }
35
+ this.billingFieldsErrors = newErrors;
36
+ return { isValid: isValid };
37
+ }
38
+ render() {
39
+ return (h(Host, null, h("fieldset", null, h("text-input", { name: "address_line1", label: "Street Address", defaultValue: this.billingFields.address_line1, error: this.billingFieldsErrors.address_line1 }), h("text-input", { name: "address_line2", label: "Apartment, Suite, etc. (optional)", defaultValue: this.billingFields.address_line2, error: this.billingFieldsErrors.address_line2 }), h("text-input", { name: "address_city", label: "City", defaultValue: this.billingFields.address_city, error: this.billingFieldsErrors.address_city }), h("select-input", { name: "address_state", label: "State", options: StateOptions, defaultValue: this.billingFields.address_state, error: this.billingFieldsErrors.address_state }), h("text-input", { name: "address_postal_code", label: "ZIP", defaultValue: this.billingFields.address_postal_code, error: this.billingFieldsErrors.address_postal_code }))));
40
+ }
41
+ static get is() { return "justifi-billing-form"; }
42
+ static get encapsulation() { return "shadow"; }
43
+ static get originalStyleUrls() {
44
+ return {
45
+ "$": ["billing-form.css"]
46
+ };
47
+ }
48
+ static get styleUrls() {
49
+ return {
50
+ "$": ["billing-form.css"]
51
+ };
52
+ }
53
+ static get states() {
54
+ return {
55
+ "billingFields": {},
56
+ "billingFieldsErrors": {}
57
+ };
58
+ }
59
+ static get methods() {
60
+ return {
61
+ "validate": {
62
+ "complexType": {
63
+ "signature": "() => Promise<{ isValid: boolean; }>",
64
+ "parameters": [],
65
+ "references": {
66
+ "Promise": {
67
+ "location": "global"
68
+ },
69
+ "ValidationError": {
70
+ "location": "import",
71
+ "path": "yup"
72
+ }
73
+ },
74
+ "return": "Promise<{ isValid: boolean; }>"
75
+ },
76
+ "docs": {
77
+ "text": "",
78
+ "tags": []
79
+ }
80
+ }
81
+ };
82
+ }
83
+ static get listeners() {
84
+ return [{
85
+ "name": "fieldReceivedInput",
86
+ "method": "setFormValue",
87
+ "target": undefined,
88
+ "capture": false,
89
+ "passive": false
90
+ }];
91
+ }
92
+ }