@justifi/webcomponents 0.0.6
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/LICENSE +21 -0
- package/dist/cjs/index-c1726348.js +1347 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/justifi-card-form_2.cjs.entry.js +4305 -0
- package/dist/cjs/justifi-webcomponents.cjs.js +19 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/api/Api.js +44 -0
- package/dist/collection/api/Pagination.js +8 -0
- package/dist/collection/api/Payment.js +67 -0
- package/dist/collection/api/index.js +4 -0
- package/dist/collection/api/mockData/MockPayments.js +216 -0
- package/dist/collection/collection-manifest.json +13 -0
- package/dist/collection/components/card-form/card-form.css +9 -0
- package/dist/collection/components/card-form/card-form.js +191 -0
- package/dist/collection/components/payments-list/payments-list.css +3 -0
- package/dist/collection/components/payments-list/payments-list.js +92 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/utils.js +33 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/components/index.js +3 -0
- package/dist/components/justifi-card-form.d.ts +11 -0
- package/dist/components/justifi-card-form.js +93 -0
- package/dist/components/justifi-payments-list.d.ts +11 -0
- package/dist/components/justifi-payments-list.js +4253 -0
- package/dist/esm/index-df3d4282.js +1320 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/justifi-card-form_2.entry.js +4300 -0
- package/dist/esm/justifi-webcomponents.js +17 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/justifi-webcomponents/index.esm.js +0 -0
- package/dist/justifi-webcomponents/justifi-webcomponents.esm.js +1 -0
- package/dist/justifi-webcomponents/p-3487f6b8.js +2 -0
- package/dist/justifi-webcomponents/p-69e18be7.entry.js +1 -0
- package/dist/types/api/Api.d.ts +25 -0
- package/dist/types/api/Pagination.d.ts +13 -0
- package/dist/types/api/Payment.d.ts +99 -0
- package/dist/types/api/index.d.ts +4 -0
- package/dist/types/api/mockData/MockPayments.d.ts +3 -0
- package/dist/types/components/card-form/card-form.d.ts +17 -0
- package/dist/types/components/payments-list/payments-list.d.ts +11 -0
- package/dist/types/components.d.ts +65 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1581 -0
- package/dist/types/utils/utils.d.ts +4 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +11 -0
- package/package.json +45 -0
- package/readme.md +75 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Host, h } from '@stencil/core';
|
|
2
|
+
import { Api, Payment } from '../../api';
|
|
3
|
+
import { formatCurrency, formatDate, formatTime } from '../../utils/utils';
|
|
4
|
+
export class PaymentsList {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.accountId = undefined;
|
|
7
|
+
this.auth = {};
|
|
8
|
+
this.payments = [];
|
|
9
|
+
}
|
|
10
|
+
requestPropsChanged() {
|
|
11
|
+
this.fetchData();
|
|
12
|
+
}
|
|
13
|
+
fetchData() {
|
|
14
|
+
const accountId = this.accountId;
|
|
15
|
+
const endpoint = `account/${accountId}/payments`;
|
|
16
|
+
Api(this.auth.token).get(endpoint)
|
|
17
|
+
.then((response) => {
|
|
18
|
+
const data = response.data.map((dataItem) => new Payment(dataItem));
|
|
19
|
+
this.payments = data;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
;
|
|
23
|
+
render() {
|
|
24
|
+
return (h(Host, null, h("table", { class: "justifi-table" }, h("thead", null, h("tr", null, h("th", { scope: "col", title: "The date and time each payment was made" }, "Made on"), h("th", { scope: "col", title: "The dollar amount of each payment" }, "Amount"), h("th", { scope: "col" }, "Account"), h("th", { scope: "col" }, "Description"), h("th", { scope: "col" }, "Payment ID"), h("th", { scope: "col" }, "Cardholder"), h("th", { scope: "col" }, "Payment Method"), h("th", { scope: "col" }, "Status"))), h("tbody", null, this.payments.map((payment) => {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
26
|
+
h("tr", null, h("td", null, h("div", null, formatDate(payment.created_at)), h("div", null, formatTime(payment.created_at))), h("td", null, formatCurrency(payment.amount)), h("td", null, payment.account_id), h("td", null, payment.description), h("td", null, payment.id), h("td", null, (_b = (_a = payment.payment_method) === null || _a === void 0 ? void 0 : _a.card) === null || _b === void 0 ? void 0 : _b.name), h("td", null, (_d = (_c = payment.payment_method) === null || _c === void 0 ? void 0 : _c.card) === null || _d === void 0 ? void 0 : _d.acct_last_four), h("td", null, payment.status));
|
|
27
|
+
})))));
|
|
28
|
+
}
|
|
29
|
+
static get is() { return "justifi-payments-list"; }
|
|
30
|
+
static get encapsulation() { return "shadow"; }
|
|
31
|
+
static get originalStyleUrls() {
|
|
32
|
+
return {
|
|
33
|
+
"$": ["payments-list.css"]
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
static get styleUrls() {
|
|
37
|
+
return {
|
|
38
|
+
"$": ["payments-list.css"]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
static get properties() {
|
|
42
|
+
return {
|
|
43
|
+
"accountId": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"mutable": false,
|
|
46
|
+
"complexType": {
|
|
47
|
+
"original": "string",
|
|
48
|
+
"resolved": "string",
|
|
49
|
+
"references": {}
|
|
50
|
+
},
|
|
51
|
+
"required": false,
|
|
52
|
+
"optional": false,
|
|
53
|
+
"docs": {
|
|
54
|
+
"tags": [],
|
|
55
|
+
"text": ""
|
|
56
|
+
},
|
|
57
|
+
"attribute": "account-id",
|
|
58
|
+
"reflect": false
|
|
59
|
+
},
|
|
60
|
+
"auth": {
|
|
61
|
+
"type": "unknown",
|
|
62
|
+
"mutable": false,
|
|
63
|
+
"complexType": {
|
|
64
|
+
"original": "{ token?: string }",
|
|
65
|
+
"resolved": "{ token?: string; }",
|
|
66
|
+
"references": {}
|
|
67
|
+
},
|
|
68
|
+
"required": false,
|
|
69
|
+
"optional": false,
|
|
70
|
+
"docs": {
|
|
71
|
+
"tags": [],
|
|
72
|
+
"text": ""
|
|
73
|
+
},
|
|
74
|
+
"defaultValue": "{}"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
static get states() {
|
|
79
|
+
return {
|
|
80
|
+
"payments": {}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static get watchers() {
|
|
84
|
+
return [{
|
|
85
|
+
"propName": "accountId",
|
|
86
|
+
"methodName": "requestPropsChanged"
|
|
87
|
+
}, {
|
|
88
|
+
"propName": "auth",
|
|
89
|
+
"methodName": "requestPropsChanged"
|
|
90
|
+
}];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { format } from 'date-fns';
|
|
2
|
+
import Dinero from 'dinero.js';
|
|
3
|
+
export function formatCurrency(amount, withSymbol = true) {
|
|
4
|
+
if (!amount)
|
|
5
|
+
amount = 0;
|
|
6
|
+
function format(amount) {
|
|
7
|
+
const formattedString = withSymbol ? '$0,0.00' : '0,0.00';
|
|
8
|
+
return Dinero({ amount: amount, currency: 'USD' }).toFormat(formattedString);
|
|
9
|
+
}
|
|
10
|
+
return (amount < 0) ? `(${format(-amount)})` : format(amount);
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
export function formatDate(dateString) {
|
|
14
|
+
if (!dateString)
|
|
15
|
+
return '';
|
|
16
|
+
const date = new Date(dateString);
|
|
17
|
+
return format(date, 'MMM d, yyyy');
|
|
18
|
+
}
|
|
19
|
+
;
|
|
20
|
+
export function formatTime(dateString) {
|
|
21
|
+
if (!dateString)
|
|
22
|
+
return '';
|
|
23
|
+
const date = new Date(dateString);
|
|
24
|
+
return format(date, 'h:mmaaa');
|
|
25
|
+
}
|
|
26
|
+
;
|
|
27
|
+
export function formatTimeSeconds(dateString) {
|
|
28
|
+
if (!dateString)
|
|
29
|
+
return '';
|
|
30
|
+
const date = new Date(dateString);
|
|
31
|
+
return format(date, 'h:mm:ssaaa');
|
|
32
|
+
}
|
|
33
|
+
;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* JustifiWebcomponents custom elements */
|
|
2
|
+
export { CardForm as JustifiCardForm } from '../types/components/card-form/card-form';
|
|
3
|
+
export { PaymentsList as JustifiPaymentsList } from '../types/components/payments-list/payments-list';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Used to manually set the base path where assets can be found.
|
|
7
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
8
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
9
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setAssetPath: (path: string) => void;
|
|
16
|
+
|
|
17
|
+
export interface SetPlatformOptions {
|
|
18
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
19
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
20
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
23
|
+
export * from '../types';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|
|
2
|
+
export { JustifiCardForm, defineCustomElement as defineCustomElementJustifiCardForm } from './justifi-card-form.js';
|
|
3
|
+
export { JustifiPaymentsList, defineCustomElement as defineCustomElementJustifiPaymentsList } from './justifi-payments-list.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface JustifiCardForm extends Components.JustifiCardForm, HTMLElement {}
|
|
4
|
+
export const JustifiCardForm: {
|
|
5
|
+
prototype: JustifiCardForm;
|
|
6
|
+
new (): JustifiCardForm;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const cardFormCss = ":host{display:block}iframe{border:none;height:55px;width:100%}";
|
|
4
|
+
|
|
5
|
+
var DispatchedEventTypes;
|
|
6
|
+
(function (DispatchedEventTypes) {
|
|
7
|
+
DispatchedEventTypes["blur"] = "blur";
|
|
8
|
+
DispatchedEventTypes["change"] = "change";
|
|
9
|
+
DispatchedEventTypes["ready"] = "ready";
|
|
10
|
+
DispatchedEventTypes["tokenize"] = "tokenize";
|
|
11
|
+
})(DispatchedEventTypes || (DispatchedEventTypes = {}));
|
|
12
|
+
const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.__registerHost();
|
|
16
|
+
this.__attachShadow();
|
|
17
|
+
this.cardFormReady = createEvent(this, "cardFormReady", 7);
|
|
18
|
+
this.cardFormChange = createEvent(this, "cardFormChange", 7);
|
|
19
|
+
this.cardFormBlur = createEvent(this, "cardFormBlur", 7);
|
|
20
|
+
this.cardFormTokenize = createEvent(this, "cardFormTokenize", 7);
|
|
21
|
+
this.iframeOrigin = undefined;
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
window.addEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
25
|
+
}
|
|
26
|
+
disconnectedCallback() {
|
|
27
|
+
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
28
|
+
}
|
|
29
|
+
dispatchMessageEvent(messageEvent) {
|
|
30
|
+
const messagePayload = messageEvent.data;
|
|
31
|
+
const messageType = messagePayload.eventType;
|
|
32
|
+
const messageData = messagePayload.data;
|
|
33
|
+
switch (messageType) {
|
|
34
|
+
case DispatchedEventTypes.ready:
|
|
35
|
+
this.cardFormReady.emit(messageData);
|
|
36
|
+
break;
|
|
37
|
+
case DispatchedEventTypes.change:
|
|
38
|
+
this.cardFormChange.emit(messageData);
|
|
39
|
+
break;
|
|
40
|
+
case DispatchedEventTypes.blur:
|
|
41
|
+
this.cardFormBlur.emit(messageData);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
triggerTokenization(clientKey, account, paymentMethodMetadata) {
|
|
46
|
+
if (this.iframeElement && this.iframeElement.contentWindow) {
|
|
47
|
+
this.iframeElement.contentWindow.postMessage({
|
|
48
|
+
eventType: DispatchedEventTypes.tokenize,
|
|
49
|
+
clientKey: clientKey,
|
|
50
|
+
paymentMethodMetadata: paymentMethodMetadata,
|
|
51
|
+
account: account
|
|
52
|
+
}, '*');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async tokenize(clientKey, account, paymentMethodMetadata) {
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
const tokenizeEventListener = (event) => {
|
|
58
|
+
if (event.data.eventType !== DispatchedEventTypes.tokenize)
|
|
59
|
+
return;
|
|
60
|
+
window.removeEventListener('message', tokenizeEventListener);
|
|
61
|
+
resolve(event.data.data);
|
|
62
|
+
};
|
|
63
|
+
window.addEventListener('message', tokenizeEventListener);
|
|
64
|
+
this.triggerTokenization(clientKey, account, paymentMethodMetadata);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
;
|
|
68
|
+
render() {
|
|
69
|
+
return (h(Host, null, h("iframe", { id: "justifi-card-form", src: this.iframeOrigin || 'https://js.justifi.ai', ref: (el) => this.iframeElement = el })));
|
|
70
|
+
}
|
|
71
|
+
static get style() { return cardFormCss; }
|
|
72
|
+
}, [1, "justifi-card-form", {
|
|
73
|
+
"iframeOrigin": [1, "iframe-origin"],
|
|
74
|
+
"tokenize": [64]
|
|
75
|
+
}]);
|
|
76
|
+
function defineCustomElement$1() {
|
|
77
|
+
if (typeof customElements === "undefined") {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const components = ["justifi-card-form"];
|
|
81
|
+
components.forEach(tagName => { switch (tagName) {
|
|
82
|
+
case "justifi-card-form":
|
|
83
|
+
if (!customElements.get(tagName)) {
|
|
84
|
+
customElements.define(tagName, CardForm);
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
} });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const JustifiCardForm = CardForm;
|
|
91
|
+
const defineCustomElement = defineCustomElement$1;
|
|
92
|
+
|
|
93
|
+
export { JustifiCardForm, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface JustifiPaymentsList extends Components.JustifiPaymentsList, HTMLElement {}
|
|
4
|
+
export const JustifiPaymentsList: {
|
|
5
|
+
prototype: JustifiPaymentsList;
|
|
6
|
+
new (): JustifiPaymentsList;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|