@justifi/webcomponents 4.12.2 → 4.13.0-rc.1
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/{Api-a06b996e.js → Api-ab34a402.js} +4 -1
- package/dist/cjs/{Business-21cef37d.js → Business-32a53780.js} +8 -3
- package/dist/cjs/{utils-f8079741.js → ComponentError-8ba0c0e7.js} +0 -25
- package/dist/cjs/additional-questions-details_5.cjs.entry.js +2 -2
- package/dist/cjs/{business-additional-questions-schema-f5f303fb.js → business-additional-questions-schema-0a35f597.js} +17 -9
- package/dist/cjs/{business-form-types-a3cc374d.js → business-form-options-43366c9a.js} +50 -33
- package/dist/cjs/business-form-types-29b2bad9.js +26 -0
- package/dist/cjs/form-control-date_3.cjs.entry.js +1 -1
- package/dist/cjs/form-control-datepart_2.cjs.entry.js +1 -1
- package/dist/cjs/form-control-file.cjs.entry.js +44 -0
- package/dist/cjs/form-control-monetary.cjs.entry.js +7 -12
- package/dist/cjs/form-input-masks-0879c139.js +27 -0
- package/dist/cjs/{index-fc5339a5.js → index-d8e99b54.js} +352 -198
- package/dist/cjs/justifi-additional-questions-form-step_5.cjs.entry.js +10 -9
- package/dist/cjs/justifi-additional-questions_4.cjs.entry.js +6 -6
- package/dist/cjs/justifi-billing-form_4.cjs.entry.js +2 -2
- package/dist/cjs/justifi-business-details.cjs.entry.js +8 -7
- package/dist/cjs/justifi-business-form.cjs.entry.js +6 -5
- package/dist/cjs/justifi-business-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-business-owners.cjs.entry.js +1 -1
- package/dist/cjs/justifi-checkout-core.cjs.entry.js +30 -11
- package/dist/cjs/justifi-checkout.cjs.entry.js +36 -9
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +7 -6
- package/dist/cjs/justifi-new-payment-method_4.cjs.entry.js +12 -12
- package/dist/cjs/justifi-owner-form.cjs.entry.js +6 -5
- package/dist/cjs/justifi-payment-balance-transactions.cjs.entry.js +1 -1
- package/dist/cjs/justifi-payment-details.cjs.entry.js +8 -7
- package/dist/cjs/justifi-payment-form.cjs.entry.js +6 -5
- package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +1 -3
- package/dist/cjs/justifi-payments-list.cjs.entry.js +8 -7
- package/dist/cjs/justifi-payout-details.cjs.entry.js +8 -7
- package/dist/cjs/justifi-payouts-list.cjs.entry.js +7 -6
- package/dist/cjs/justifi-proceeds-list.cjs.entry.js +1 -1
- package/dist/cjs/justifi-refund-form.cjs.entry.js +3 -2
- package/dist/cjs/justifi-subaccount-details.cjs.entry.js +1 -1
- package/dist/cjs/justifi-subaccounts-list.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{payload-parsers-74693a97.js → payload-parsers-6c4b5323.js} +61 -6
- package/dist/cjs/{payment.service-9db24ab9.js → payment.service-336189d3.js} +1 -1
- package/dist/cjs/{payout.service-a0efb71a.js → payout.service-6012d576.js} +1 -1
- package/dist/cjs/utils-491248ca.js +28 -0
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/api/Api.js +4 -1
- package/dist/collection/api/Business.js +8 -3
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/business-details/additional-questions-details/additional-questions-details.js +2 -2
- package/dist/collection/components/business-forms/business-form/additional-questions/additional-questions.js +4 -2
- package/dist/collection/components/business-forms/business-form/business-core-info/business-core-info.js +2 -2
- package/dist/collection/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step.js +4 -2
- package/dist/collection/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step.js +3 -2
- package/dist/collection/components/business-forms/schemas/business-additional-questions-schema.js +16 -9
- package/dist/collection/components/business-forms/schemas/business-core-info-schema.js +3 -1
- package/dist/collection/components/business-forms/schemas/schema-helpers.js +3 -0
- package/dist/collection/components/business-forms/schemas/schema-validations.js +51 -7
- package/dist/collection/components/business-forms/utils/business-form-options.js +119 -0
- package/dist/collection/components/business-forms/utils/business-form-types.js +0 -81
- package/dist/collection/components/checkout/checkout-actions.js +29 -7
- package/dist/collection/components/checkout/checkout-core.js +51 -14
- package/dist/collection/components/checkout/checkout.js +30 -2
- package/dist/collection/components/checkout/new-payment-method.js +11 -11
- package/dist/collection/components/checkout/payment-method-options.js +2 -18
- package/dist/collection/components/checkout/test/checkout-actions.spec.js +124 -0
- package/dist/collection/components/checkout/test/checkout-core.spec.js +127 -0
- package/dist/collection/components/checkout/test/checkout.spec.js +0 -153
- package/dist/collection/components/form/form-control-file.css +1806 -0
- package/dist/collection/components/form/form-control-file.js +169 -0
- package/dist/collection/components/form/form-control-monetary.css +1812 -0
- package/dist/collection/components/form/form-control-monetary.js +24 -11
- package/dist/collection/components/form/test/form-control-file.spec.js +84 -0
- package/dist/collection/components/form/test/form-control-monetary.spec.js +5 -3
- package/dist/collection/components/refund-form/refund-form.js +2 -1
- package/dist/collection/utils/form-input-masks.js +15 -0
- package/dist/docs.json +275 -33
- package/dist/esm/{Api-0e88671c.js → Api-e9d568c7.js} +4 -1
- package/dist/esm/{Business-0e8a9a3a.js → Business-d83fbdb4.js} +8 -3
- package/dist/esm/{utils-4609f32c.js → ComponentError-2a58dbbc.js} +1 -23
- package/dist/esm/additional-questions-details_5.entry.js +2 -2
- package/dist/esm/{business-additional-questions-schema-a84dd641.js → business-additional-questions-schema-e96b0509.js} +18 -10
- package/dist/esm/{business-form-types-7420dc96.js → business-form-options-de11bc46.js} +46 -32
- package/dist/esm/business-form-types-0d76133c.js +26 -0
- package/dist/esm/form-control-date_3.entry.js +1 -1
- package/dist/esm/form-control-datepart_2.entry.js +1 -1
- package/dist/esm/form-control-file.entry.js +40 -0
- package/dist/esm/form-control-monetary.entry.js +7 -12
- package/dist/esm/form-input-masks-0e18300f.js +22 -0
- package/dist/esm/{index-5eb05747.js → index-dc1350b1.js} +352 -198
- package/dist/esm/justifi-additional-questions-form-step_5.entry.js +10 -9
- package/dist/esm/justifi-additional-questions_4.entry.js +6 -6
- package/dist/esm/justifi-billing-form_4.entry.js +2 -2
- package/dist/esm/justifi-business-details.entry.js +4 -3
- package/dist/esm/justifi-business-form.entry.js +6 -5
- package/dist/esm/justifi-business-list.entry.js +2 -2
- package/dist/esm/justifi-business-owners.entry.js +1 -1
- package/dist/esm/justifi-checkout-core.entry.js +30 -11
- package/dist/esm/justifi-checkout.entry.js +37 -10
- package/dist/esm/justifi-gross-payment-chart.entry.js +3 -2
- package/dist/esm/justifi-new-payment-method_4.entry.js +12 -12
- package/dist/esm/justifi-owner-form.entry.js +6 -5
- package/dist/esm/justifi-payment-balance-transactions.entry.js +1 -1
- package/dist/esm/justifi-payment-details.entry.js +4 -3
- package/dist/esm/justifi-payment-form.entry.js +2 -1
- package/dist/esm/justifi-payment-provisioning.entry.js +1 -3
- package/dist/esm/justifi-payments-list.entry.js +4 -3
- package/dist/esm/justifi-payout-details.entry.js +4 -3
- package/dist/esm/justifi-payouts-list.entry.js +4 -3
- package/dist/esm/justifi-proceeds-list.entry.js +1 -1
- package/dist/esm/justifi-refund-form.entry.js +3 -2
- package/dist/esm/justifi-subaccount-details.entry.js +1 -1
- package/dist/esm/justifi-subaccounts-list.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{payload-parsers-0c4fc2b1.js → payload-parsers-32028700.js} +54 -7
- package/dist/esm/{payment.service-ec28a959.js → payment.service-2fdc5018.js} +1 -1
- package/dist/esm/{payout.service-5fd5986c.js → payout.service-15064bcc.js} +1 -1
- package/dist/esm/utils-f580d6b7.js +25 -0
- package/dist/esm/webcomponents.js +1 -1
- package/dist/module/Api.js +4 -1
- package/dist/module/Business.js +8 -3
- package/dist/module/ComponentError.js +16 -0
- package/dist/module/additional-questions-details2.js +2 -2
- package/dist/module/additional-questions.js +18 -4
- package/dist/module/business-additional-questions-form-step.js +18 -4
- package/dist/module/business-additional-questions-schema.js +16 -9
- package/dist/module/business-address-schema.js +1 -1
- package/dist/module/business-core-info-form-step.js +10 -3
- package/dist/module/business-core-info-schema.js +3 -1
- package/dist/module/business-core-info.js +9 -3
- package/dist/module/business-form-options.js +122 -0
- package/dist/module/business-form-types.js +153 -82
- package/dist/module/business-identity-schema.js +1 -1
- package/dist/module/business-representative-form-step.js +1 -1
- package/dist/module/checkout-core.js +30 -13
- package/dist/module/form-control-file.d.ts +11 -0
- package/dist/module/form-control-file.js +67 -0
- package/dist/module/form-control-monetary2.js +8 -12
- package/dist/module/form-input-masks.js +16 -1
- package/dist/module/index2.js +352 -198
- package/dist/module/justifi-business-details.js +2 -1
- package/dist/module/justifi-business-form.js +2 -2
- package/dist/module/justifi-checkout.js +37 -11
- package/dist/module/justifi-gross-payment-chart.js +2 -1
- package/dist/module/justifi-payment-details.js +2 -1
- package/dist/module/justifi-payment-form.js +2 -1
- package/dist/module/justifi-payment-provisioning.js +1 -1
- package/dist/module/justifi-payments-list.js +2 -1
- package/dist/module/justifi-payout-details.js +2 -1
- package/dist/module/justifi-payouts-list.js +2 -1
- package/dist/module/justifi-refund-form.js +2 -1
- package/dist/module/legal-address-form-step.js +1 -1
- package/dist/module/new-payment-method.js +11 -11
- package/dist/module/owner-form.js +2 -2
- package/dist/module/payload-parsers.js +1 -107
- package/dist/module/payment-method-form.js +2 -2
- package/dist/module/payment-method-options.js +2 -2
- package/dist/module/utils3.js +2 -15
- package/dist/types/api/Api.d.ts +1 -0
- package/dist/types/api/Business.d.ts +15 -5
- package/dist/types/api/services/checkout.service.d.ts +3 -3
- package/dist/types/components/business-forms/schemas/business-additional-questions-schema.d.ts +10 -4
- package/dist/types/components/business-forms/schemas/business-core-info-schema.d.ts +2 -0
- package/dist/types/components/business-forms/schemas/business-form-schema.d.ts +12 -4
- package/dist/types/components/business-forms/schemas/schema-helpers.d.ts +3 -0
- package/dist/types/components/business-forms/schemas/schema-validations.d.ts +8 -0
- package/dist/types/components/business-forms/utils/business-form-options.d.ts +21 -0
- package/dist/types/components/business-forms/utils/business-form-types.d.ts +0 -9
- package/dist/types/components/checkout/checkout-core.d.ts +8 -3
- package/dist/types/components/checkout/checkout.d.ts +3 -0
- package/dist/types/components/checkout/payment-method-options.d.ts +1 -1
- package/dist/types/components/checkout/payment-method-payload.d.ts +5 -0
- package/dist/types/components/form/form-control-file.d.ts +17 -0
- package/dist/types/components/form/form-control-monetary.d.ts +1 -0
- package/dist/types/components/payment-method-form/payment-method-responses.d.ts +1 -0
- package/dist/types/components.d.ts +61 -2
- package/dist/types/utils/form-input-masks.d.ts +15 -0
- package/dist/webcomponents/p-00ca94d1.js +1 -0
- package/dist/webcomponents/p-02b18979.entry.js +1 -0
- package/dist/webcomponents/p-0d80748f.js +1 -0
- package/dist/webcomponents/p-101b2648.entry.js +1 -0
- package/dist/webcomponents/p-132ba228.js +1 -0
- package/dist/webcomponents/p-13e2f667.js +1 -0
- package/dist/webcomponents/{p-18cf5a16.entry.js → p-1885c478.entry.js} +1 -1
- package/dist/webcomponents/{p-8abba4c2.entry.js → p-23099f1f.entry.js} +1 -1
- package/dist/webcomponents/p-230b96df.entry.js +1 -0
- package/dist/webcomponents/{p-2fbe8823.entry.js → p-3367225e.entry.js} +1 -1
- package/dist/webcomponents/p-3917edbf.entry.js +1 -0
- package/dist/webcomponents/p-3da23f21.js +1 -0
- package/dist/webcomponents/p-41bdee27.entry.js +1 -0
- package/dist/webcomponents/{p-5ff7826e.entry.js → p-4c84952f.entry.js} +1 -1
- package/dist/webcomponents/p-4ff52695.entry.js +1 -0
- package/dist/webcomponents/p-525db3e8.js +1 -0
- package/dist/webcomponents/p-61fd33c7.js +1 -0
- package/dist/webcomponents/p-64710363.entry.js +1 -0
- package/dist/webcomponents/{p-9245777b.js → p-731085e3.js} +1 -1
- package/dist/webcomponents/p-78b32fb9.entry.js +1 -0
- package/dist/webcomponents/p-7e334dce.entry.js +1 -0
- package/dist/webcomponents/p-7faacb1e.entry.js +1 -0
- package/dist/webcomponents/{p-5f5e730c.entry.js → p-834cba99.entry.js} +1 -1
- package/dist/webcomponents/p-87d646c0.js +1 -0
- package/dist/webcomponents/p-935d6f55.js +1 -0
- package/dist/webcomponents/{p-e3946c2b.js → p-9ada56da.js} +1 -1
- package/dist/webcomponents/p-9ba31a6a.entry.js +1 -0
- package/dist/webcomponents/p-a9af8f40.entry.js +1 -0
- package/dist/webcomponents/p-b81afd51.entry.js +1 -0
- package/dist/webcomponents/{p-c556deda.entry.js → p-bb58e656.entry.js} +1 -1
- package/dist/webcomponents/p-bc12b8b9.js +1 -0
- package/dist/webcomponents/p-bfe7c55c.entry.js +1 -0
- package/dist/webcomponents/p-c1be3378.entry.js +1 -0
- package/dist/webcomponents/p-cb31488b.entry.js +1 -0
- package/dist/webcomponents/p-cf3151a3.entry.js +1 -0
- package/dist/webcomponents/p-d0a8c631.entry.js +1 -0
- package/dist/webcomponents/p-e6ab1f0d.entry.js +1 -0
- package/dist/webcomponents/p-ee68566f.entry.js +1 -0
- package/dist/webcomponents/{p-3adc0688.entry.js → p-efbc8ffc.entry.js} +1 -1
- package/dist/webcomponents/{p-b9f04fb0.entry.js → p-f152d6b8.entry.js} +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/form-input-masks-efd44b8e.js +0 -11
- package/dist/esm/form-input-masks-84875967.js +0 -7
- package/dist/webcomponents/p-01913426.js +0 -1
- package/dist/webcomponents/p-04c7f8f8.js +0 -1
- package/dist/webcomponents/p-0c269feb.entry.js +0 -1
- package/dist/webcomponents/p-0eb77101.entry.js +0 -1
- package/dist/webcomponents/p-19001cc5.entry.js +0 -1
- package/dist/webcomponents/p-2319abaf.entry.js +0 -1
- package/dist/webcomponents/p-2bee72bd.entry.js +0 -1
- package/dist/webcomponents/p-51ee396f.entry.js +0 -1
- package/dist/webcomponents/p-52e4cc27.js +0 -1
- package/dist/webcomponents/p-602a1588.entry.js +0 -1
- package/dist/webcomponents/p-6ec77980.entry.js +0 -1
- package/dist/webcomponents/p-6f294d5d.js +0 -1
- package/dist/webcomponents/p-81c43ba5.entry.js +0 -1
- package/dist/webcomponents/p-927150b4.entry.js +0 -1
- package/dist/webcomponents/p-93579716.js +0 -1
- package/dist/webcomponents/p-9e35b0f6.entry.js +0 -1
- package/dist/webcomponents/p-9e3f9e05.entry.js +0 -1
- package/dist/webcomponents/p-9ec89299.entry.js +0 -1
- package/dist/webcomponents/p-a8caec98.entry.js +0 -1
- package/dist/webcomponents/p-a90f7ca0.js +0 -1
- package/dist/webcomponents/p-abc03d5a.entry.js +0 -1
- package/dist/webcomponents/p-b38baa84.entry.js +0 -1
- package/dist/webcomponents/p-bfc634c6.entry.js +0 -1
- package/dist/webcomponents/p-c1b92cec.entry.js +0 -1
- package/dist/webcomponents/p-cb86b2fd.js +0 -1
- package/dist/webcomponents/p-d2b7beac.js +0 -1
- package/dist/webcomponents/p-d69a485a.entry.js +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Host, h, } from "@stencil/core";
|
|
2
2
|
import IMask from "imask";
|
|
3
|
+
import { CURRENCY_MASK } from "../../utils/form-input-masks";
|
|
3
4
|
export class MonetaryInput {
|
|
4
5
|
constructor() {
|
|
5
6
|
this.imask = null;
|
|
@@ -8,6 +9,7 @@ export class MonetaryInput {
|
|
|
8
9
|
this.error = undefined;
|
|
9
10
|
this.defaultValue = undefined;
|
|
10
11
|
this.inputHandler = undefined;
|
|
12
|
+
this.maskOptions = CURRENCY_MASK.DECIMAL;
|
|
11
13
|
}
|
|
12
14
|
handleDefaultValueChange(newValue) {
|
|
13
15
|
this.updateInput(newValue);
|
|
@@ -23,14 +25,7 @@ export class MonetaryInput {
|
|
|
23
25
|
initializeIMask() {
|
|
24
26
|
if (!this.textInput)
|
|
25
27
|
return;
|
|
26
|
-
this.imask = IMask(this.textInput,
|
|
27
|
-
mask: Number,
|
|
28
|
-
scale: 2,
|
|
29
|
-
thousandsSeparator: ',',
|
|
30
|
-
padFractionalZeros: true,
|
|
31
|
-
normalizeZeros: true,
|
|
32
|
-
radix: '.',
|
|
33
|
-
});
|
|
28
|
+
this.imask = IMask(this.textInput, this.maskOptions);
|
|
34
29
|
this.imask.on('accept', () => {
|
|
35
30
|
const rawValue = this.imask.unmaskedValue;
|
|
36
31
|
this.inputHandler(this.name, rawValue);
|
|
@@ -44,18 +39,18 @@ export class MonetaryInput {
|
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
41
|
render() {
|
|
47
|
-
return (h(Host, { exportparts: "label,input,input-invalid" }, h("label", { part: "label", class: "form-label", htmlFor: this.name }, this.label), h("input", { ref: el => (this.textInput = el), id: this.name, name: this.name, onBlur: () => this.formControlBlur.emit(), part: `input ${this.error && 'input-invalid'}`, class: this.error ? 'form-control is-invalid' : 'form-control', type: "text" }), this.error && h("div", { class: "invalid-feedback" }, this.error)));
|
|
42
|
+
return (h(Host, { exportparts: "label,input,input-invalid" }, h("label", { part: "label", class: "form-label", htmlFor: this.name }, this.label), h("div", { class: "input-group mb-3" }, h("span", { class: "input-group-text" }, "$"), h("input", { ref: el => (this.textInput = el), id: this.name, name: this.name, onBlur: () => this.formControlBlur.emit(), part: `input ${this.error && 'input-invalid'}`, class: this.error ? 'form-control monetary is-invalid' : 'form-control monetary', type: "text" }), this.error && h("div", { class: "invalid-feedback" }, this.error))));
|
|
48
43
|
}
|
|
49
44
|
static get is() { return "form-control-monetary"; }
|
|
50
45
|
static get encapsulation() { return "shadow"; }
|
|
51
46
|
static get originalStyleUrls() {
|
|
52
47
|
return {
|
|
53
|
-
"$": ["form-control-
|
|
48
|
+
"$": ["form-control-monetary.scss"]
|
|
54
49
|
};
|
|
55
50
|
}
|
|
56
51
|
static get styleUrls() {
|
|
57
52
|
return {
|
|
58
|
-
"$": ["form-control-
|
|
53
|
+
"$": ["form-control-monetary.css"]
|
|
59
54
|
};
|
|
60
55
|
}
|
|
61
56
|
static get properties() {
|
|
@@ -142,6 +137,24 @@ export class MonetaryInput {
|
|
|
142
137
|
"tags": [],
|
|
143
138
|
"text": ""
|
|
144
139
|
}
|
|
140
|
+
},
|
|
141
|
+
"maskOptions": {
|
|
142
|
+
"type": "any",
|
|
143
|
+
"mutable": false,
|
|
144
|
+
"complexType": {
|
|
145
|
+
"original": "any",
|
|
146
|
+
"resolved": "any",
|
|
147
|
+
"references": {}
|
|
148
|
+
},
|
|
149
|
+
"required": false,
|
|
150
|
+
"optional": false,
|
|
151
|
+
"docs": {
|
|
152
|
+
"tags": [],
|
|
153
|
+
"text": ""
|
|
154
|
+
},
|
|
155
|
+
"attribute": "mask-options",
|
|
156
|
+
"reflect": false,
|
|
157
|
+
"defaultValue": "CURRENCY_MASK.DECIMAL"
|
|
145
158
|
}
|
|
146
159
|
};
|
|
147
160
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
+
import { FileInput } from "../form-control-file";
|
|
3
|
+
describe('form-control-file', () => {
|
|
4
|
+
it('renders with default props', async () => {
|
|
5
|
+
const page = await newSpecPage({
|
|
6
|
+
components: [FileInput],
|
|
7
|
+
html: `<form-control-file label="Select a file" name="user ID"></form-control-file>`,
|
|
8
|
+
});
|
|
9
|
+
expect(page.root).toMatchSnapshot();
|
|
10
|
+
expect(page.rootInstance.label).toBe('Select a file');
|
|
11
|
+
expect(page.rootInstance.name).toBe('user ID');
|
|
12
|
+
});
|
|
13
|
+
it('renders with all props provided', async () => {
|
|
14
|
+
const page = await newSpecPage({
|
|
15
|
+
components: [FileInput],
|
|
16
|
+
html: `
|
|
17
|
+
<form-control-file
|
|
18
|
+
label="Select a file"
|
|
19
|
+
name="email"
|
|
20
|
+
error="No file selected"
|
|
21
|
+
disabled
|
|
22
|
+
></form-control-file>
|
|
23
|
+
`,
|
|
24
|
+
});
|
|
25
|
+
const inputElement = page.root.shadowRoot.querySelector('input');
|
|
26
|
+
expect(page.rootInstance.label).toBe('Select a file');
|
|
27
|
+
expect(inputElement.disabled).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
it('handles user input correctly', async () => {
|
|
30
|
+
const page = await newSpecPage({
|
|
31
|
+
components: [FileInput],
|
|
32
|
+
html: `<form-control-file></form-control-file>`,
|
|
33
|
+
});
|
|
34
|
+
const inputElement = page.root.shadowRoot.querySelector('input');
|
|
35
|
+
const testValue = 'Hello, World!';
|
|
36
|
+
inputElement.value = testValue;
|
|
37
|
+
await inputElement.dispatchEvent(new Event('input'));
|
|
38
|
+
expect(inputElement.value).toBe(testValue);
|
|
39
|
+
});
|
|
40
|
+
it('emits formControlInput event on input', async () => {
|
|
41
|
+
const page = await newSpecPage({
|
|
42
|
+
components: [FileInput],
|
|
43
|
+
html: `<form-control-file></form-control-file>`,
|
|
44
|
+
});
|
|
45
|
+
// Set a mock inputHandler to prevent it from being undefined
|
|
46
|
+
page.rootInstance.inputHandler = jest.fn();
|
|
47
|
+
const inputEventSpy = jest.fn();
|
|
48
|
+
page.root.addEventListener('formControlInput', inputEventSpy);
|
|
49
|
+
await page.waitForChanges();
|
|
50
|
+
const inputElement = page.root.shadowRoot.querySelector('input');
|
|
51
|
+
inputElement.value = 'Hello, World!';
|
|
52
|
+
inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
53
|
+
await page.waitForChanges();
|
|
54
|
+
expect(inputEventSpy).toHaveBeenCalled();
|
|
55
|
+
});
|
|
56
|
+
it('emits formControlBlur event on blur', async () => {
|
|
57
|
+
const page = await newSpecPage({
|
|
58
|
+
components: [FileInput],
|
|
59
|
+
html: `<form-control-file></form-control-file>`,
|
|
60
|
+
});
|
|
61
|
+
const blurEventSpy = jest.fn();
|
|
62
|
+
page.win.addEventListener('formControlBlur', blurEventSpy);
|
|
63
|
+
const inputElement = page.root.shadowRoot.querySelector('input');
|
|
64
|
+
inputElement.dispatchEvent(new Event('blur'));
|
|
65
|
+
expect(blurEventSpy).toHaveBeenCalled();
|
|
66
|
+
});
|
|
67
|
+
it('disables input when disabled prop is true', async () => {
|
|
68
|
+
const page = await newSpecPage({
|
|
69
|
+
components: [FileInput],
|
|
70
|
+
html: `<form-control-file disabled></form-control-file>`,
|
|
71
|
+
});
|
|
72
|
+
const inputElement = page.root.shadowRoot.querySelector('input');
|
|
73
|
+
expect(inputElement.disabled).toBeTruthy();
|
|
74
|
+
});
|
|
75
|
+
it('shows error and applies error styling when error prop is provided', async () => {
|
|
76
|
+
const page = await newSpecPage({
|
|
77
|
+
components: [FileInput],
|
|
78
|
+
html: `<form-control-file error="This field is required."></form-control-file>`,
|
|
79
|
+
});
|
|
80
|
+
const shadowRoot = page.root.shadowRoot;
|
|
81
|
+
expect(shadowRoot.querySelector('.invalid-feedback').textContent).toBe('This field is required.');
|
|
82
|
+
expect(shadowRoot.querySelector('.form-control').classList.contains('is-invalid')).toBeTruthy();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { newSpecPage } from "@stencil/core/testing";
|
|
2
2
|
import { MonetaryInput } from "../form-control-monetary";
|
|
3
|
+
import { CURRENCY_MASK } from "../../../utils/form-input-masks";
|
|
3
4
|
describe('form-control-monetary', () => {
|
|
4
5
|
it('renders correctly with default props', async () => {
|
|
5
6
|
const page = await newSpecPage({
|
|
@@ -17,6 +18,7 @@ describe('form-control-monetary', () => {
|
|
|
17
18
|
name="amount"
|
|
18
19
|
error="Invalid amount"
|
|
19
20
|
defaultValue="1000"
|
|
21
|
+
maskOptions=${CURRENCY_MASK.DECIMAL}
|
|
20
22
|
></form-control-monetary>
|
|
21
23
|
`,
|
|
22
24
|
});
|
|
@@ -32,7 +34,7 @@ describe('form-control-monetary', () => {
|
|
|
32
34
|
const inputHandlerMock = jest.fn();
|
|
33
35
|
const page = await newSpecPage({
|
|
34
36
|
components: [MonetaryInput],
|
|
35
|
-
html: `<form-control-monetary></form-control-monetary>`,
|
|
37
|
+
html: `<form-control-monetary maskOptions=${CURRENCY_MASK.DECIMAL}></form-control-monetary>`,
|
|
36
38
|
});
|
|
37
39
|
page.rootInstance.inputHandler = inputHandlerMock;
|
|
38
40
|
await page.waitForChanges();
|
|
@@ -48,7 +50,7 @@ describe('form-control-monetary', () => {
|
|
|
48
50
|
it('emits formControlBlur on input blur', async () => {
|
|
49
51
|
const page = await newSpecPage({
|
|
50
52
|
components: [MonetaryInput],
|
|
51
|
-
html: `<form-control-monetary></form-control-monetary>`,
|
|
53
|
+
html: `<form-control-monetary maskOptions=${CURRENCY_MASK.DECIMAL}></form-control-monetary>`,
|
|
52
54
|
});
|
|
53
55
|
const blurSpy = jest.fn();
|
|
54
56
|
page.win.addEventListener('formControlBlur', blurSpy);
|
|
@@ -60,7 +62,7 @@ describe('form-control-monetary', () => {
|
|
|
60
62
|
it('displays error message when error prop is set', async () => {
|
|
61
63
|
const page = await newSpecPage({
|
|
62
64
|
components: [MonetaryInput],
|
|
63
|
-
html: `<form-control-monetary error="Invalid amount"></form-control-monetary>`,
|
|
65
|
+
html: `<form-control-monetary error="Invalid amount" maskOptions=${CURRENCY_MASK.DECIMAL}></form-control-monetary>`,
|
|
64
66
|
});
|
|
65
67
|
const errorDiv = page.root.shadowRoot.querySelector('.invalid-feedback');
|
|
66
68
|
expect(errorDiv.textContent).toBe('Invalid amount');
|
|
@@ -3,6 +3,7 @@ import RefundFormSchema from "./refund-form-schema";
|
|
|
3
3
|
import { Api } from "../../api";
|
|
4
4
|
import { FormController } from "../form/form";
|
|
5
5
|
import { config } from "../../../config";
|
|
6
|
+
import { CURRENCY_MASK } from "../../utils/form-input-masks";
|
|
6
7
|
export class RefundForm {
|
|
7
8
|
constructor() {
|
|
8
9
|
this.authToken = undefined;
|
|
@@ -73,7 +74,7 @@ export class RefundForm {
|
|
|
73
74
|
}
|
|
74
75
|
render() {
|
|
75
76
|
var _a;
|
|
76
|
-
return (h(Host, null, h("h1", null, "Refund"), this.refundInfoText && (h("div", { class: "d-flex align-items-center flex-row gap-4 border-top border-bottom my-4 p-3", role: "alert" }, h("img", { src: "/info-icon.svg", alt: "Information", height: "30", width: "30" }), h("p", { class: "m-0", innerHTML: this.refundInfoText }))), h("form", { onSubmit: e => this.handleSubmit(e), class: "d-grid gap-4" }, h("div", { class: "form-group" }, h("form-control-monetary", { name: "amount", label: "Refund Amount", defaultValue: ((_a = this.amount) === null || _a === void 0 ? void 0 : _a.toString()) || '', inputHandler: (name, value) => this.handleInput(name, value), error: this.errors.amount })), h("div", { class: "form-group" }, h("form-control-text", { name: "notes", label: "Additional Notes", inputHandler: (name, value) => this.handleInput(name, value), error: this.errors.notes })), this.withButton && (h("div", { class: "form-group d-flex flex-row-reverse" }, h("button", { type: "submit", disabled: !!this.isSubmitting, class: "btn btn-primary ml-auto" }, this.submitButtonText))))));
|
|
77
|
+
return (h(Host, null, h("h1", null, "Refund"), this.refundInfoText && (h("div", { class: "d-flex align-items-center flex-row gap-4 border-top border-bottom my-4 p-3", role: "alert" }, h("img", { src: "/info-icon.svg", alt: "Information", height: "30", width: "30" }), h("p", { class: "m-0", innerHTML: this.refundInfoText }))), h("form", { onSubmit: e => this.handleSubmit(e), class: "d-grid gap-4" }, h("div", { class: "form-group" }, h("form-control-monetary", { name: "amount", label: "Refund Amount", defaultValue: ((_a = this.amount) === null || _a === void 0 ? void 0 : _a.toString()) || '', maskOptions: CURRENCY_MASK.DECIMAL, inputHandler: (name, value) => this.handleInput(name, value), error: this.errors.amount })), h("div", { class: "form-group" }, h("form-control-text", { name: "notes", label: "Additional Notes", inputHandler: (name, value) => this.handleInput(name, value), error: this.errors.notes })), this.withButton && (h("div", { class: "form-group d-flex flex-row-reverse" }, h("button", { type: "submit", disabled: !!this.isSubmitting, class: "btn btn-primary ml-auto" }, this.submitButtonText))))));
|
|
77
78
|
}
|
|
78
79
|
static get is() { return "justifi-refund-form"; }
|
|
79
80
|
static get encapsulation() { return "shadow"; }
|
|
@@ -3,3 +3,18 @@ export const PHONE_MASKS = {
|
|
|
3
3
|
};
|
|
4
4
|
export const TAX_ID_MASKS = { US: '00-0000000' };
|
|
5
5
|
export const SSN_MASK = '000-00-0000';
|
|
6
|
+
export const CURRENCY_MASK = {
|
|
7
|
+
WHOLE: {
|
|
8
|
+
mask: Number,
|
|
9
|
+
thousandsSeparator: ',',
|
|
10
|
+
normalizeZeros: true,
|
|
11
|
+
},
|
|
12
|
+
DECIMAL: {
|
|
13
|
+
mask: Number,
|
|
14
|
+
scale: 2,
|
|
15
|
+
thousandsSeparator: ',',
|
|
16
|
+
padFractionalZeros: true,
|
|
17
|
+
normalizeZeros: true,
|
|
18
|
+
radix: '.',
|
|
19
|
+
}
|
|
20
|
+
};
|