@tesouro/embedded-components-react 0.8.5 → 0.8.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/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index4.js +23 -28
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/formatters.js +15 -17
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/formatters.js +18 -20
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/formatters.js +12 -15
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/discount.js +6 -11
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +16 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/lineItems.js +15 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +3 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +3 -7
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +49 -51
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/createCurrencyFormatter.js +25 -0
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/currencyDisplay.js +0 -6
|
@@ -1,46 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { parseDateOrTimestamp as t } from "../../../../shared/util/dist/lib/parseCalendarDate.js";
|
|
2
3
|
//#region ../../libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index4.js
|
|
3
|
-
function
|
|
4
|
-
let n =
|
|
4
|
+
function n(e) {
|
|
5
|
+
let n = e.trim();
|
|
5
6
|
if (!n) return "";
|
|
6
|
-
let r =
|
|
7
|
+
let r = t(n);
|
|
7
8
|
return r ? new Intl.DateTimeFormat(void 0, { dateStyle: "medium" }).format(r) : n;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
10
|
+
function r(e) {
|
|
11
|
+
return n(e);
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
-
let n =
|
|
13
|
+
function i(e) {
|
|
14
|
+
let n = e.trim();
|
|
14
15
|
if (!n) return "";
|
|
15
|
-
let r =
|
|
16
|
+
let r = t(n);
|
|
16
17
|
return r ? new Intl.DateTimeFormat(void 0, {
|
|
17
18
|
month: "long",
|
|
18
19
|
year: "numeric"
|
|
19
20
|
}).format(r) : n;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
if (!
|
|
23
|
-
let
|
|
24
|
-
return Number.isFinite(
|
|
25
|
-
style: "currency",
|
|
26
|
-
currency: e.currencyCode
|
|
27
|
-
}).format(n / 100) : t;
|
|
22
|
+
function a(t, n = "—") {
|
|
23
|
+
if (!t) return n;
|
|
24
|
+
let r = Number(t.value);
|
|
25
|
+
return Number.isFinite(r) ? e(t.currencyCode).format(r / 100) : n;
|
|
28
26
|
}
|
|
29
|
-
function
|
|
30
|
-
if (!
|
|
31
|
-
let
|
|
32
|
-
if (!Number.isFinite(
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
currency: e.currencyCode
|
|
36
|
-
}).format(r / 100);
|
|
37
|
-
return t === "CREDIT" ? `+${i}` : `-${i}`;
|
|
27
|
+
function o(t, n, r = "—") {
|
|
28
|
+
if (!t) return r;
|
|
29
|
+
let i = Math.abs(Number(t.value));
|
|
30
|
+
if (!Number.isFinite(i)) return r;
|
|
31
|
+
let a = e(t.currencyCode).format(i / 100);
|
|
32
|
+
return n === "CREDIT" ? `+${a}` : `-${a}`;
|
|
38
33
|
}
|
|
39
|
-
function
|
|
34
|
+
function s(e) {
|
|
40
35
|
let t = e.trim();
|
|
41
36
|
return t ? `••••••••${t.slice(-4)}` : "";
|
|
42
37
|
}
|
|
43
|
-
async function
|
|
38
|
+
async function c(e) {
|
|
44
39
|
if (!e.trim()) return !1;
|
|
45
40
|
try {
|
|
46
41
|
return await navigator.clipboard.writeText(e), !0;
|
|
@@ -49,4 +44,4 @@ async function s(e) {
|
|
|
49
44
|
}
|
|
50
45
|
}
|
|
51
46
|
//#endregion
|
|
52
|
-
export {
|
|
47
|
+
export { c as copyTextToClipboard, a as formatAmountLabel, o as formatSignedTransactionAmountLabel, i as formatStatementPeriodLabel, r as formatTransactionDateLabel, s as maskAccountNumber };
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
1
2
|
//#region ../../libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/formatters.js
|
|
2
|
-
function
|
|
3
|
-
if (!
|
|
4
|
-
let
|
|
5
|
-
return Number.isFinite(
|
|
6
|
-
style: "currency",
|
|
7
|
-
currency: e.currencyCode
|
|
8
|
-
}).format(n / 100) : t;
|
|
3
|
+
function t(t, n = "—") {
|
|
4
|
+
if (!t) return n;
|
|
5
|
+
let r = Number(t.value);
|
|
6
|
+
return Number.isFinite(r) ? e(t.currencyCode).format(r / 100) : n;
|
|
9
7
|
}
|
|
10
|
-
function
|
|
11
|
-
if (
|
|
8
|
+
function n(e) {
|
|
9
|
+
if (e.length <= 1) return;
|
|
12
10
|
let n = /* @__PURE__ */ new Map();
|
|
13
|
-
for (let
|
|
14
|
-
let { currencyCode:
|
|
15
|
-
|
|
11
|
+
for (let t of e) {
|
|
12
|
+
let { currencyCode: e, value: r } = t.balance;
|
|
13
|
+
e && n.set(e, (n.get(e) ?? 0) + Number(r));
|
|
16
14
|
}
|
|
17
|
-
if (n.size !== 0) return [...n.entries()].sort(([e], [t]) => e.localeCompare(t)).map(([
|
|
18
|
-
currencyCode:
|
|
15
|
+
if (n.size !== 0) return [...n.entries()].sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => t({
|
|
16
|
+
currencyCode: e,
|
|
19
17
|
value: n
|
|
20
18
|
})).join(" + ");
|
|
21
19
|
}
|
|
22
|
-
function
|
|
20
|
+
function r(e) {
|
|
23
21
|
let t = e.trim();
|
|
24
22
|
return t ? `••••••••${t.slice(-4)}` : "";
|
|
25
23
|
}
|
|
26
|
-
async function
|
|
24
|
+
async function i(e) {
|
|
27
25
|
if (!e.trim()) return !1;
|
|
28
26
|
try {
|
|
29
27
|
return await navigator.clipboard.writeText(e), !0;
|
|
@@ -32,4 +30,4 @@ async function r(e) {
|
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
//#endregion
|
|
35
|
-
export {
|
|
33
|
+
export { i as copyTextToClipboard, t as formatAmountLabel, n as formatTotalAvailableBalanceLabel, r as maskAccountNumber };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { amountOutputToMajorUnits as t } from "../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
3
|
//#region ../../libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/formatters.js
|
|
3
|
-
var
|
|
4
|
-
function n(e) {
|
|
5
|
-
let n = e.trim().slice(-4);
|
|
6
|
-
return n ? `${t} ${t} ${t} ${n}` : "";
|
|
7
|
-
}
|
|
4
|
+
var n = "••••";
|
|
8
5
|
function r(e) {
|
|
6
|
+
let t = e.trim().slice(-4);
|
|
7
|
+
return t ? `${n} ${n} ${n} ${t}` : "";
|
|
8
|
+
}
|
|
9
|
+
function i(e) {
|
|
9
10
|
let t = e.replace(/\s+/g, "");
|
|
10
11
|
return t ? (t.match(/.{1,4}/g) ?? []).join(" ") : "";
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function a(e) {
|
|
13
14
|
let t = e.trim();
|
|
14
15
|
if (!t) return "";
|
|
15
16
|
let n = /^(\d{4})-(\d{2})(?:\D|$)/.exec(t);
|
|
@@ -24,7 +25,7 @@ function i(e) {
|
|
|
24
25
|
}
|
|
25
26
|
return t;
|
|
26
27
|
}
|
|
27
|
-
async function
|
|
28
|
+
async function o(e) {
|
|
28
29
|
if (!e.trim()) return !1;
|
|
29
30
|
try {
|
|
30
31
|
return await navigator.clipboard.writeText(e), !0;
|
|
@@ -32,12 +33,12 @@ async function a(e) {
|
|
|
32
33
|
return !1;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function s(e) {
|
|
36
37
|
return e.filter((e) => !!e?.trim());
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function c(e) {
|
|
39
40
|
if (!e) return;
|
|
40
|
-
let t = e.address1?.trim() || void 0, n =
|
|
41
|
+
let t = e.address1?.trim() || void 0, n = s([e.address2, e.address3]).join(" ") || void 0, r = s([e.city, e.state]).join(", ") || void 0, i = e.postalCode?.trim() || void 0;
|
|
41
42
|
if (t || n || r || i) return {
|
|
42
43
|
addressLine1: t,
|
|
43
44
|
addressLine2: n,
|
|
@@ -45,15 +46,12 @@ function s(e) {
|
|
|
45
46
|
postalCode: i
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
-
let
|
|
50
|
-
value:
|
|
51
|
-
currencyCode:
|
|
49
|
+
function l({ amountLimit: n, currencyCode: r }) {
|
|
50
|
+
let i = t({
|
|
51
|
+
value: n,
|
|
52
|
+
currencyCode: r
|
|
52
53
|
});
|
|
53
|
-
if (Number.isFinite(
|
|
54
|
-
style: "currency",
|
|
55
|
-
currency: n
|
|
56
|
-
}).format(r);
|
|
54
|
+
if (Number.isFinite(i)) return e(r).format(i);
|
|
57
55
|
}
|
|
58
56
|
//#endregion
|
|
59
|
-
export {
|
|
57
|
+
export { o as copyTextToClipboard, c as formatBillingAddressFields, i as formatCardNumber, a as formatExpirationDate, l as formatVelocityControlAmount, r as maskCardNumber };
|
package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/formatters.js
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { minorExponentForCurrency as t } from "../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
3
|
+
import { normalizeAmountOutputCurrencyCode as n } from "../../../../shared/util/dist/lib/normalizeAmountOutputCurrencyCode.js";
|
|
3
4
|
//#region ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/formatters.js
|
|
4
|
-
function
|
|
5
|
+
function r(e) {
|
|
5
6
|
if (e == null || e === "") return;
|
|
6
7
|
let t = Number(e);
|
|
7
8
|
return Number.isFinite(t) ? t : void 0;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
if (
|
|
12
|
-
let
|
|
13
|
-
return
|
|
14
|
-
style: "currency",
|
|
15
|
-
currency: o,
|
|
16
|
-
maximumFractionDigits: 0
|
|
17
|
-
}).format(a / 10 ** e(o));
|
|
10
|
+
function i({ limit: i, currencyCode: a }) {
|
|
11
|
+
let o = r(i);
|
|
12
|
+
if (o === void 0) return;
|
|
13
|
+
let s = n(a);
|
|
14
|
+
return e(s, { maximumFractionDigits: 0 }).format(o / 10 ** t(s));
|
|
18
15
|
}
|
|
19
|
-
function
|
|
16
|
+
function a(e) {
|
|
20
17
|
let t = e?.trim().slice(-4);
|
|
21
18
|
return t ? `••••${t}` : void 0;
|
|
22
19
|
}
|
|
23
|
-
function
|
|
20
|
+
function o(e, t) {
|
|
24
21
|
return e?.trim() || t;
|
|
25
22
|
}
|
|
26
23
|
//#endregion
|
|
27
|
-
export {
|
|
24
|
+
export { i as formatCardLimit, a as maskAccountNumber, o as withFallback };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { minorExponentForCurrency as t } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
3
3
|
import { escapeRegex as n, getNumberSeparators as r, parseLocaleDecimal as i } from "./lineItems.js";
|
|
4
4
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/discount.js
|
|
5
|
-
function a(
|
|
6
|
-
return
|
|
5
|
+
function a(e, n) {
|
|
6
|
+
return e === "percentage" ? 2 : t(n);
|
|
7
7
|
}
|
|
8
8
|
function o(e, t, i, o = r()) {
|
|
9
9
|
let s = `0-9${n(o.digits.join(""))}${n(o.decimal)}${o.group ? n(o.group) : ""}`, c = e.replace(RegExp(`[^${s}]`, "gu"), ""), l = c.indexOf(o.decimal);
|
|
@@ -19,7 +19,7 @@ function c(e, t, n) {
|
|
|
19
19
|
maximumFractionDigits: r
|
|
20
20
|
}).format(e / 10 ** r);
|
|
21
21
|
}
|
|
22
|
-
function l(
|
|
22
|
+
function l(t, n, r) {
|
|
23
23
|
let i = a(n, r), o = {
|
|
24
24
|
minimumFractionDigits: i,
|
|
25
25
|
maximumFractionDigits: i
|
|
@@ -27,12 +27,7 @@ function l(e, n, r) {
|
|
|
27
27
|
return n === "percentage" ? new Intl.NumberFormat(void 0, {
|
|
28
28
|
...o,
|
|
29
29
|
style: "percent"
|
|
30
|
-
}).format(
|
|
31
|
-
...o,
|
|
32
|
-
style: "currency",
|
|
33
|
-
currency: r,
|
|
34
|
-
currencyDisplay: t(r)
|
|
35
|
-
}).format(e / 10 ** i);
|
|
30
|
+
}).format(t / 10 ** (i + 2)) : e(r, o).format(t / 10 ** i);
|
|
36
31
|
}
|
|
37
32
|
function u({ value: e, type: t, currency: n }) {
|
|
38
33
|
return c(s(e, t, n), t, n);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { minorExponentForCurrency as t } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
3
|
+
import { parseDateOrTimestamp as n } from "../../../../../shared/util/dist/lib/parseCalendarDate.js";
|
|
4
|
+
import { isEmail as r } from "../../../../../../shared/util-validation/dist/index5.js";
|
|
5
5
|
import { createLineItem as i, isBlankLineItem as a, keepsSavedTaxRates as o, lineItemToCreatePayload as s, lineItemToUpdatePayload as c, responseLineItemToFormValues as l, summarizeLineItemErrors as u, taxRateFromLineItems as d, validateLineItems as f } from "./lineItems.js";
|
|
6
6
|
import { attachmentFormValuesToPayload as p, receivableToAttachmentFormValues as m } from "./attachments.js";
|
|
7
7
|
import { createEmptyRecurrenceFields as h, willRecurrenceIssue as g } from "./recurrence.js";
|
|
@@ -37,25 +37,21 @@ function D() {
|
|
|
37
37
|
...h()
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function O(e,
|
|
41
|
-
let r =
|
|
40
|
+
function O(e, t) {
|
|
41
|
+
let r = n(e);
|
|
42
42
|
return r ? new Intl.DateTimeFormat(void 0, {
|
|
43
43
|
day: "2-digit",
|
|
44
44
|
month: "short",
|
|
45
45
|
year: "numeric"
|
|
46
|
-
}).format(r) :
|
|
46
|
+
}).format(r) : t;
|
|
47
47
|
}
|
|
48
|
-
function k({ amount:
|
|
49
|
-
return
|
|
50
|
-
currency: n,
|
|
51
|
-
style: "currency",
|
|
52
|
-
currencyDisplay: r(n)
|
|
53
|
-
}).format(t / 10 ** e(n));
|
|
48
|
+
function k({ amount: n, currency: r, fallback: i }) {
|
|
49
|
+
return n == null || !r ? i : e(r).format(n / 10 ** t(r));
|
|
54
50
|
}
|
|
55
|
-
function A(
|
|
56
|
-
let r = Number(
|
|
51
|
+
function A(e, n) {
|
|
52
|
+
let r = Number(e);
|
|
57
53
|
if (!Number.isFinite(r)) return;
|
|
58
|
-
let i = n ?
|
|
54
|
+
let i = n ? t(n) : 2;
|
|
59
55
|
return Math.round(r * 10 ** i);
|
|
60
56
|
}
|
|
61
57
|
function j(e, t) {
|
|
@@ -140,16 +136,16 @@ function V({ values: e, counterpart: t, addresses: n }) {
|
|
|
140
136
|
shippingAddressId: a
|
|
141
137
|
};
|
|
142
138
|
}
|
|
143
|
-
function H({ values: e, messages: t, willIssue:
|
|
139
|
+
function H({ values: e, messages: t, willIssue: n = !1, hasStartedRecurrence: i = !1, canCreateCustomer: a = !0 }) {
|
|
144
140
|
let o = {}, s = a && !!e.customerName.trim();
|
|
145
141
|
!e.customerId && !s && (o.customerId = t.customerRequired);
|
|
146
142
|
let c = e.customerEmail.trim();
|
|
147
|
-
!e.customerId && c && !
|
|
143
|
+
!e.customerId && c && !r(c) && (o.customerEmail = t.customerEmailInvalid), e.currency || (o.currency = t.currencyRequired), n && !e.paymentTermsId && (o.paymentTermsId = t.paymentTermsRequired), n && !e.bankAccountId && (o.bankAccountId = t.bankAccountRequired);
|
|
148
144
|
let l = f(e.lineItems, {
|
|
149
145
|
currency: e.currency,
|
|
150
146
|
messages: t,
|
|
151
|
-
requireComplete:
|
|
152
|
-
}), d = (
|
|
147
|
+
requireComplete: n || i
|
|
148
|
+
}), d = (n || i && g(e)) && !l && e.lineItems.length > 0 ? T(e, t) : void 0, p = u(l, w(e, t) ?? d, (n || i) && e.lineItems.length === 0 ? t.lineItemsRequired : void 0);
|
|
153
149
|
l && (o.lineItems = l), p && (o.lineItemsSummary = p);
|
|
154
150
|
let m = C(e, t);
|
|
155
151
|
return m && (o.discount = m), o;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { minorExponentForCurrency as t } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
3
3
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/lineItems.js
|
|
4
4
|
var n = 9e15;
|
|
5
5
|
function r(e) {
|
|
@@ -21,15 +21,15 @@ function o(e) {
|
|
|
21
21
|
return e === "" || e === "." ? 0 : Number(e) || 0;
|
|
22
22
|
}
|
|
23
23
|
var s = (e) => Math.round(e * 100) / 100;
|
|
24
|
-
function c(
|
|
25
|
-
let r =
|
|
24
|
+
function c(e, n) {
|
|
25
|
+
let r = t(n);
|
|
26
26
|
return new Intl.NumberFormat(void 0, {
|
|
27
27
|
minimumFractionDigits: r,
|
|
28
28
|
maximumFractionDigits: r
|
|
29
|
-
}).format(
|
|
29
|
+
}).format(e / 10 ** r);
|
|
30
30
|
}
|
|
31
|
-
function l(
|
|
32
|
-
return Math.round(u(
|
|
31
|
+
function l(e, n, i = r()) {
|
|
32
|
+
return Math.round(u(e, i) * 10 ** t(n));
|
|
33
33
|
}
|
|
34
34
|
function u(e, t = r()) {
|
|
35
35
|
if (e.trim() === "") return 0;
|
|
@@ -41,9 +41,9 @@ function u(e, t = r()) {
|
|
|
41
41
|
let a = parseFloat(n);
|
|
42
42
|
return Number.isNaN(a) ? 0 : a;
|
|
43
43
|
}
|
|
44
|
-
function d(
|
|
45
|
-
let o = l(
|
|
46
|
-
return c(Math.round(o * 10 **
|
|
44
|
+
function d(e, n, i, a = r()) {
|
|
45
|
+
let o = l(e, n, a) / 10 ** t(n);
|
|
46
|
+
return c(Math.round(o * 10 ** t(i)), i);
|
|
47
47
|
}
|
|
48
48
|
function f(e) {
|
|
49
49
|
let t = a(e);
|
|
@@ -68,15 +68,11 @@ function v(e) {
|
|
|
68
68
|
let t = e.find((e) => _(e.tax_status))?.product.tax_rate?.value;
|
|
69
69
|
return t === void 0 ? "" : String(t / 100);
|
|
70
70
|
}
|
|
71
|
-
function y(
|
|
71
|
+
function y(t) {
|
|
72
72
|
try {
|
|
73
|
-
return
|
|
74
|
-
style: "currency",
|
|
75
|
-
currency: e,
|
|
76
|
-
currencyDisplay: t(e)
|
|
77
|
-
}).formatToParts(0).find((e) => e.type === "currency")?.value ?? e;
|
|
73
|
+
return e(t).formatToParts(0).find((e) => e.type === "currency")?.value ?? t;
|
|
78
74
|
} catch {
|
|
79
|
-
return
|
|
75
|
+
return t;
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
function b() {
|
|
@@ -253,8 +249,8 @@ function L(e, t) {
|
|
|
253
249
|
});
|
|
254
250
|
return n ? r : e;
|
|
255
251
|
}
|
|
256
|
-
function R(
|
|
257
|
-
return new Intl.NumberFormat().format(n / 10 ** e
|
|
252
|
+
function R(e) {
|
|
253
|
+
return new Intl.NumberFormat().format(n / 10 ** t(e));
|
|
258
254
|
}
|
|
259
255
|
var z = .1;
|
|
260
256
|
function B(e, { currency: t, messages: n, requireComplete: r = !1 }) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { minorExponentForCurrency as t } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
3
|
import "../../../../ui/dist/index20.js";
|
|
3
4
|
import "../../../../ui/dist/index.js";
|
|
4
|
-
import { currencyDisplayFor as t } from "./currencyDisplay.js";
|
|
5
5
|
import { isBlankLineItem as n, keepsSavedTaxRates as r, lineItemTaxRateMinorUnits as i, parseQuantity as a, priceInputToMinorUnits as o, taxRateToMinorUnits as s } from "./lineItems.js";
|
|
6
6
|
import { formatPreviewDate as c, resolveIssueDate as l, termDueDate as u } from "./paymentTerms.js";
|
|
7
7
|
import { bracketAmount as d } from "./totals.js";
|
|
@@ -138,11 +138,7 @@ function M({ lineItems: e, currency: t, unitNamesById: r, messages: i }) {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
function N(n, r) {
|
|
141
|
-
return r ? d(
|
|
142
|
-
style: "currency",
|
|
143
|
-
currency: r,
|
|
144
|
-
currencyDisplay: t(r)
|
|
145
|
-
}), n / 10 ** e(r)) : "";
|
|
141
|
+
return r ? d(e(r), n / 10 ** t(r)) : "";
|
|
146
142
|
}
|
|
147
143
|
function P(e, t) {
|
|
148
144
|
if (!e.taxRate) return t.previewTax;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../../shared/util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { minorExponentForCurrency as t } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
3
3
|
import { isBlankLineItem as n, keepsSavedTaxRates as r, lineItemTaxRateMinorUnits as i, maxAmountLabel as a, parseQuantity as o, priceInputToMinorUnits as s } from "./lineItems.js";
|
|
4
4
|
import { discountFromDraft as c } from "./discount.js";
|
|
5
5
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js
|
|
@@ -106,11 +106,7 @@ function b(e, t) {
|
|
|
106
106
|
return `${o(n.slice(0, i))}(${o(n.slice(i, a + 1))})${o(n.slice(a + 1))}`;
|
|
107
107
|
}
|
|
108
108
|
function x(n, r, i = !1) {
|
|
109
|
-
let a =
|
|
110
|
-
style: "currency",
|
|
111
|
-
currency: r,
|
|
112
|
-
currencyDisplay: t(r)
|
|
113
|
-
}), o = n / 10 ** e(r);
|
|
109
|
+
let a = e(r), o = n / 10 ** t(r);
|
|
114
110
|
return i ? b(a, o) : a.format(o);
|
|
115
111
|
}
|
|
116
112
|
function S(e, t) {
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
|
|
2
|
-
var e = "@tesouro/embedded-components-react", t = "0.8.
|
|
2
|
+
var e = "@tesouro/embedded-components-react", t = "0.8.6", n = "ddb2fc16517211bc0ce402194b7f8e9a5c94a56e", r = Object.freeze({
|
|
3
3
|
library_name: e,
|
|
4
4
|
library_version: t,
|
|
5
5
|
library_sha: n
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createCurrencyFormatter as e } from "../../../../util/dist/lib/createCurrencyFormatter.js";
|
|
2
|
+
import { extractApiErrorMessage as t } from "../../../../util/dist/lib/apiErrors.js";
|
|
3
|
+
import { parseApiValidationErrors as n } from "../../../../util/dist/lib/apiValidationErrors.js";
|
|
4
|
+
import { PRODUCT_MESSAGE_LABELS_EN as r } from "./labels.js";
|
|
4
5
|
//#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js
|
|
5
|
-
function
|
|
6
|
+
function i(e) {
|
|
6
7
|
try {
|
|
7
8
|
return new Intl.NumberFormat("en-US", {
|
|
8
9
|
style: "currency",
|
|
@@ -12,14 +13,14 @@ function r(e) {
|
|
|
12
13
|
return 2;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
let n = 10 **
|
|
16
|
+
function a(e, t) {
|
|
17
|
+
let n = 10 ** i(t);
|
|
17
18
|
return Math.round(e * n);
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
return e / 10 **
|
|
20
|
+
function o(e, t) {
|
|
21
|
+
return e / 10 ** i(t);
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function s(e) {
|
|
23
24
|
try {
|
|
24
25
|
return new Intl.NumberFormat(void 0, {
|
|
25
26
|
style: "currency",
|
|
@@ -30,61 +31,58 @@ function o(e) {
|
|
|
30
31
|
return e;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
if (!
|
|
35
|
-
let
|
|
34
|
+
function c(t) {
|
|
35
|
+
if (!t) return "";
|
|
36
|
+
let n = o(t.value, t.currency);
|
|
36
37
|
try {
|
|
37
|
-
return
|
|
38
|
-
style: "currency",
|
|
39
|
-
currency: e.currency
|
|
40
|
-
}).format(t);
|
|
38
|
+
return e(t.currency).format(n);
|
|
41
39
|
} catch {
|
|
42
|
-
return `${
|
|
40
|
+
return `${n} ${t.currency}`;
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
|
-
var
|
|
43
|
+
var l = new Intl.DateTimeFormat(void 0, {
|
|
46
44
|
year: "numeric",
|
|
47
45
|
month: "short",
|
|
48
46
|
day: "2-digit"
|
|
49
47
|
});
|
|
50
|
-
function
|
|
48
|
+
function u(e) {
|
|
51
49
|
if (!e) return "";
|
|
52
50
|
let t = new Date(e);
|
|
53
|
-
return Number.isNaN(t.getTime()) ? "" :
|
|
51
|
+
return Number.isNaN(t.getTime()) ? "" : l.format(t);
|
|
54
52
|
}
|
|
55
|
-
function
|
|
53
|
+
function d(e) {
|
|
56
54
|
let t = {};
|
|
57
55
|
for (let n of e ?? []) t[n.id] = n.name;
|
|
58
56
|
return t;
|
|
59
57
|
}
|
|
60
|
-
function
|
|
58
|
+
function f(e) {
|
|
61
59
|
return (e ?? []).map((e) => ({
|
|
62
60
|
value: e.id,
|
|
63
61
|
label: e.name
|
|
64
62
|
}));
|
|
65
63
|
}
|
|
66
|
-
function
|
|
64
|
+
function p({ products: e, unitNamesById: t }) {
|
|
67
65
|
return e.map((e) => ({
|
|
68
66
|
id: e.id,
|
|
69
67
|
name: e.name,
|
|
70
68
|
type: e.type,
|
|
71
69
|
description: e.description ?? "",
|
|
72
70
|
unitLabel: e.measure_unit_id ? t[e.measure_unit_id] ?? "" : "",
|
|
73
|
-
priceLabel:
|
|
71
|
+
priceLabel: c(e.price)
|
|
74
72
|
}));
|
|
75
73
|
}
|
|
76
|
-
function
|
|
74
|
+
function m({ product: e, unitNamesById: t }) {
|
|
77
75
|
return {
|
|
78
76
|
name: e.name,
|
|
79
77
|
description: e.description ?? "",
|
|
80
78
|
type: e.type,
|
|
81
79
|
unitLabel: e.measure_unit_id ? t[e.measure_unit_id] ?? "" : "",
|
|
82
|
-
priceLabel:
|
|
83
|
-
createdAtLabel:
|
|
84
|
-
updatedAtLabel:
|
|
80
|
+
priceLabel: c(e.price),
|
|
81
|
+
createdAtLabel: u(e.created_at),
|
|
82
|
+
updatedAtLabel: u(e.updated_at)
|
|
85
83
|
};
|
|
86
84
|
}
|
|
87
|
-
var
|
|
85
|
+
var h = {
|
|
88
86
|
name: "",
|
|
89
87
|
description: "",
|
|
90
88
|
type: "product",
|
|
@@ -92,58 +90,58 @@ var m = {
|
|
|
92
90
|
pricePerUnit: "",
|
|
93
91
|
currency: "USD"
|
|
94
92
|
};
|
|
95
|
-
function
|
|
93
|
+
function g(e, t) {
|
|
96
94
|
return Object.keys(e).every((n) => e[n] === t[n]);
|
|
97
95
|
}
|
|
98
|
-
function
|
|
96
|
+
function _(e) {
|
|
99
97
|
let t = e.price?.currency ?? "USD";
|
|
100
98
|
return {
|
|
101
99
|
name: e.name,
|
|
102
100
|
description: e.description ?? "",
|
|
103
101
|
type: e.type ?? "product",
|
|
104
102
|
unitId: e.measure_unit_id ?? "",
|
|
105
|
-
pricePerUnit: e.price ? String(
|
|
103
|
+
pricePerUnit: e.price ? String(o(e.price.value, e.price.currency)) : "",
|
|
106
104
|
currency: t
|
|
107
105
|
};
|
|
108
106
|
}
|
|
109
|
-
function
|
|
107
|
+
function v(e) {
|
|
110
108
|
let t = e.pricePerUnit.trim();
|
|
111
109
|
return {
|
|
112
110
|
name: e.name.trim(),
|
|
113
111
|
type: e.type,
|
|
114
112
|
measure_unit_id: e.unitId || void 0,
|
|
115
113
|
price: t === "" ? void 0 : {
|
|
116
|
-
value:
|
|
114
|
+
value: a(Number(t), "USD"),
|
|
117
115
|
currency: "USD"
|
|
118
116
|
},
|
|
119
117
|
description: e.description.trim() ? e.description.trim() : void 0
|
|
120
118
|
};
|
|
121
119
|
}
|
|
122
|
-
function
|
|
120
|
+
function y(e) {
|
|
123
121
|
let t = e.pricePerUnit.trim();
|
|
124
122
|
return {
|
|
125
123
|
name: e.name.trim(),
|
|
126
124
|
type: e.type,
|
|
127
125
|
measure_unit_id: e.unitId ? e.unitId : null,
|
|
128
126
|
price: t === "" ? null : {
|
|
129
|
-
value:
|
|
127
|
+
value: a(Number(t), e.currency),
|
|
130
128
|
currency: e.currency
|
|
131
129
|
},
|
|
132
130
|
description: e.description.trim()
|
|
133
131
|
};
|
|
134
132
|
}
|
|
135
|
-
var
|
|
136
|
-
function
|
|
137
|
-
let
|
|
138
|
-
e.name.trim().length === 0 ?
|
|
133
|
+
var b = 100, x = 255;
|
|
134
|
+
function S(e, t = r) {
|
|
135
|
+
let n = {};
|
|
136
|
+
e.name.trim().length === 0 ? n.name = t.nameRequired : e.name.trim().length > b && (n.name = t.nameTooLong), e.type !== "product" && e.type !== "service" && (n.type = t.typeRequired);
|
|
139
137
|
let i = e.pricePerUnit.trim();
|
|
140
138
|
if (i !== "") {
|
|
141
139
|
let e = Number(i);
|
|
142
|
-
(!Number.isFinite(e) || e < 0) && (
|
|
140
|
+
(!Number.isFinite(e) || e < 0) && (n.pricePerUnit = t.priceInvalid);
|
|
143
141
|
}
|
|
144
|
-
return e.description.trim().length >
|
|
142
|
+
return e.description.trim().length > x && (n.description = t.descriptionTooLong), n;
|
|
145
143
|
}
|
|
146
|
-
var
|
|
144
|
+
var C = {
|
|
147
145
|
name: "name",
|
|
148
146
|
type: "type",
|
|
149
147
|
description: "description",
|
|
@@ -151,25 +149,25 @@ var S = {
|
|
|
151
149
|
"price.currency": "pricePerUnit",
|
|
152
150
|
measure_unit_id: "unitId"
|
|
153
151
|
};
|
|
154
|
-
function
|
|
155
|
-
let a =
|
|
156
|
-
if (!a.length) return { form: e
|
|
152
|
+
function w(e, i = r) {
|
|
153
|
+
let a = n(e);
|
|
154
|
+
if (!a.length) return { form: t(e) ?? i.genericError };
|
|
157
155
|
let o = {}, s = [];
|
|
158
156
|
for (let { path: e, msg: t } of a) {
|
|
159
|
-
let n =
|
|
157
|
+
let n = C[e];
|
|
160
158
|
n ? o[n] = t : s.push(t);
|
|
161
159
|
}
|
|
162
160
|
return s.length && (o.form = [...new Set(s)].join("; ")), o;
|
|
163
161
|
}
|
|
164
|
-
function
|
|
162
|
+
function T(e) {
|
|
165
163
|
return Object.values(e).some(Boolean);
|
|
166
164
|
}
|
|
167
|
-
function
|
|
165
|
+
function E(e, t = r) {
|
|
168
166
|
return e.name.trim().length === 0 ? t.unitNameRequired : void 0;
|
|
169
167
|
}
|
|
170
|
-
function
|
|
168
|
+
function D() {
|
|
171
169
|
let e = globalThis.getSelection?.();
|
|
172
170
|
return !!(e && e.toString().length > 0);
|
|
173
171
|
}
|
|
174
172
|
//#endregion
|
|
175
|
-
export {
|
|
173
|
+
export { h as EMPTY_PRODUCT_FORM_VALUES, w as apiErrorToProductFormErrors, g as areProductFormValuesEqual, m as buildProductDetailsView, p as buildProductRows, d as buildUnitNamesById, f as buildUnitOptions, s as currencySymbol, c as formatPrice, u as formatProductDate, o as fromMinorUnits, T as hasProductFormErrors, D as hasSelectedText, v as productFormValuesToRequest, y as productFormValuesToUpdateRequest, _ as productToFormValues, a as toMinorUnits, E as validateMeasureUnit, S as validateProductForm };
|
package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/createCurrencyFormatter.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region ../../libs/tesouro-embedded-components-react/shared/util/dist/lib/createCurrencyFormatter.js
|
|
2
|
+
function e(e, t = {}) {
|
|
3
|
+
let n = new Intl.NumberFormat(void 0, {
|
|
4
|
+
...t,
|
|
5
|
+
style: "currency",
|
|
6
|
+
currency: e
|
|
7
|
+
});
|
|
8
|
+
if (e.toUpperCase() !== "USD") return n;
|
|
9
|
+
let r = (e) => {
|
|
10
|
+
let t = n.formatToParts(e);
|
|
11
|
+
return t.flatMap((e, n) => {
|
|
12
|
+
let r = t[n - 1];
|
|
13
|
+
return e.type === "literal" && e.value.trim() === "" && r?.type === "currency" && /^[A-Z]{3}$/.test(r.value) ? [] : e.type === "currency" ? [{
|
|
14
|
+
...e,
|
|
15
|
+
value: "$"
|
|
16
|
+
}] : [e];
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
formatToParts: r,
|
|
21
|
+
format: (e) => r(e).map((e) => e.value).join("")
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { e as createCurrencyFormatter };
|
package/package.json
CHANGED