@tesouro/embedded-components-react 0.8.5 → 0.8.7

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 (14) hide show
  1. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index4.js +23 -28
  2. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/formatters.js +15 -17
  3. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/formatters.js +18 -20
  4. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/formatters.js +12 -15
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/discount.js +6 -11
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +16 -20
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/lineItems.js +15 -19
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +3 -7
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +3 -7
  10. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  11. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +49 -51
  12. package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/createCurrencyFormatter.js +25 -0
  13. package/package.json +1 -1
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/currencyDisplay.js +0 -6
@@ -1,46 +1,41 @@
1
- import { parseDateOrTimestamp as e } from "../../../../shared/util/dist/lib/parseCalendarDate.js";
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 t(t) {
4
- let n = t.trim();
4
+ function n(e) {
5
+ let n = e.trim();
5
6
  if (!n) return "";
6
- let r = e(n);
7
+ let r = t(n);
7
8
  return r ? new Intl.DateTimeFormat(void 0, { dateStyle: "medium" }).format(r) : n;
8
9
  }
9
- function n(e) {
10
- return t(e);
10
+ function r(e) {
11
+ return n(e);
11
12
  }
12
- function r(t) {
13
- let n = t.trim();
13
+ function i(e) {
14
+ let n = e.trim();
14
15
  if (!n) return "";
15
- let r = e(n);
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 i(e, t = "—") {
22
- if (!e) return t;
23
- let n = Number(e.value);
24
- return Number.isFinite(n) ? new Intl.NumberFormat(void 0, {
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 a(e, t, n = "—") {
30
- if (!e) return n;
31
- let r = Math.abs(Number(e.value));
32
- if (!Number.isFinite(r)) return n;
33
- let i = new Intl.NumberFormat(void 0, {
34
- style: "currency",
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 o(e) {
34
+ function s(e) {
40
35
  let t = e.trim();
41
36
  return t ? `••••••••${t.slice(-4)}` : "";
42
37
  }
43
- async function s(e) {
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 { s as copyTextToClipboard, i as formatAmountLabel, a as formatSignedTransactionAmountLabel, r as formatStatementPeriodLabel, n as formatTransactionDateLabel, o as maskAccountNumber };
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 e(e, t = "—") {
3
- if (!e) return t;
4
- let n = Number(e.value);
5
- return Number.isFinite(n) ? new Intl.NumberFormat(void 0, {
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 t(t) {
11
- if (t.length <= 1) return;
8
+ function n(e) {
9
+ if (e.length <= 1) return;
12
10
  let n = /* @__PURE__ */ new Map();
13
- for (let e of t) {
14
- let { currencyCode: t, value: r } = e.balance;
15
- t && n.set(t, (n.get(t) ?? 0) + Number(r));
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(([t, n]) => e({
18
- currencyCode: t,
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 n(e) {
20
+ function r(e) {
23
21
  let t = e.trim();
24
22
  return t ? `••••••••${t.slice(-4)}` : "";
25
23
  }
26
- async function r(e) {
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 { r as copyTextToClipboard, e as formatAmountLabel, t as formatTotalAvailableBalanceLabel, n as maskAccountNumber };
33
+ export { i as copyTextToClipboard, t as formatAmountLabel, n as formatTotalAvailableBalanceLabel, r as maskAccountNumber };
@@ -1,15 +1,16 @@
1
- import { amountOutputToMajorUnits as e } from "../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
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 t = "••••";
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 i(e) {
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 a(e) {
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 o(e) {
36
+ function s(e) {
36
37
  return e.filter((e) => !!e?.trim());
37
38
  }
38
- function s(e) {
39
+ function c(e) {
39
40
  if (!e) return;
40
- let t = e.address1?.trim() || void 0, n = o([e.address2, e.address3]).join(" ") || void 0, r = o([e.city, e.state]).join(", ") || void 0, i = e.postalCode?.trim() || void 0;
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 c({ amountLimit: t, currencyCode: n }) {
49
- let r = e({
50
- value: t,
51
- currencyCode: n
49
+ function l({ amountLimit: n, currencyCode: r }) {
50
+ let i = t({
51
+ value: n,
52
+ currencyCode: r
52
53
  });
53
- if (Number.isFinite(r)) return new Intl.NumberFormat(void 0, {
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 { a as copyTextToClipboard, s as formatBillingAddressFields, r as formatCardNumber, i as formatExpirationDate, c as formatVelocityControlAmount, n as maskCardNumber };
57
+ export { o as copyTextToClipboard, c as formatBillingAddressFields, i as formatCardNumber, a as formatExpirationDate, l as formatVelocityControlAmount, r as maskCardNumber };
@@ -1,27 +1,24 @@
1
- import { minorExponentForCurrency as e } from "../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
- import { normalizeAmountOutputCurrencyCode as t } from "../../../../shared/util/dist/lib/normalizeAmountOutputCurrencyCode.js";
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 n(e) {
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 r({ limit: r, currencyCode: i }) {
10
- let a = n(r);
11
- if (a === void 0) return;
12
- let o = t(i);
13
- return new Intl.NumberFormat(void 0, {
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 i(e) {
16
+ function a(e) {
20
17
  let t = e?.trim().slice(-4);
21
18
  return t ? `••••${t}` : void 0;
22
19
  }
23
- function a(e, t) {
20
+ function o(e, t) {
24
21
  return e?.trim() || t;
25
22
  }
26
23
  //#endregion
27
- export { r as formatCardLimit, i as maskAccountNumber, a as withFallback };
24
+ export { i as formatCardLimit, a as maskAccountNumber, o as withFallback };
@@ -1,9 +1,9 @@
1
- import { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
- import { currencyDisplayFor as t } from "./currencyDisplay.js";
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(t, n) {
6
- return t === "percentage" ? 2 : e(n);
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(e, n, r) {
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(e / 10 ** (i + 2)) : new Intl.NumberFormat(void 0, {
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 { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
- import { parseDateOrTimestamp as t } from "../../../../../shared/util/dist/lib/parseCalendarDate.js";
3
- import { isEmail as n } from "../../../../../../shared/util-validation/dist/index5.js";
4
- import { currencyDisplayFor as r } from "./currencyDisplay.js";
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, n) {
41
- let r = t(e);
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) : n;
46
+ }).format(r) : t;
47
47
  }
48
- function k({ amount: t, currency: n, fallback: i }) {
49
- return t == null || !n ? i : new Intl.NumberFormat(void 0, {
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(t, n) {
56
- let r = Number(t);
51
+ function A(e, n) {
52
+ let r = Number(e);
57
53
  if (!Number.isFinite(r)) return;
58
- let i = n ? e(n) : 2;
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: r = !1, hasStartedRecurrence: i = !1, canCreateCustomer: a = !0 }) {
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 && !n(c) && (o.customerEmail = t.customerEmailInvalid), e.currency || (o.currency = t.currencyRequired), r && !e.paymentTermsId && (o.paymentTermsId = t.paymentTermsRequired), r && !e.bankAccountId && (o.bankAccountId = t.bankAccountRequired);
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: r || i
152
- }), d = (r || i && g(e)) && !l && e.lineItems.length > 0 ? T(e, t) : void 0, p = u(l, w(e, t) ?? d, (r || i) && e.lineItems.length === 0 ? t.lineItemsRequired : void 0);
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 { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
- import { currencyDisplayFor as t } from "./currencyDisplay.js";
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(t, n) {
25
- let r = e(n);
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(t / 10 ** r);
29
+ }).format(e / 10 ** r);
30
30
  }
31
- function l(t, n, i = r()) {
32
- return Math.round(u(t, i) * 10 ** e(n));
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(t, n, i, a = r()) {
45
- let o = l(t, n, a) / 10 ** e(n);
46
- return c(Math.round(o * 10 ** e(i)), i);
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(e) {
71
+ function y(t) {
72
72
  try {
73
- return new Intl.NumberFormat(void 0, {
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 e;
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(t) {
257
- return new Intl.NumberFormat().format(n / 10 ** e(t));
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 { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
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(new Intl.NumberFormat(void 0, {
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 { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
- import { currencyDisplayFor as t } from "./currencyDisplay.js";
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 = new Intl.NumberFormat(void 0, {
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) {
@@ -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.5", n = "e16e2f9bbd85302962aef1167aea5c1bb4da7cc3", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.8.7", n = "76e4c4b57f43ef1e970eba48cd3516b4a65f357d", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -1,8 +1,9 @@
1
- import { extractApiErrorMessage as e } from "../../../../util/dist/lib/apiErrors.js";
2
- import { parseApiValidationErrors as t } from "../../../../util/dist/lib/apiValidationErrors.js";
3
- import { PRODUCT_MESSAGE_LABELS_EN as n } from "./labels.js";
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 r(e) {
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 i(e, t) {
16
- let n = 10 ** r(t);
16
+ function a(e, t) {
17
+ let n = 10 ** i(t);
17
18
  return Math.round(e * n);
18
19
  }
19
- function a(e, t) {
20
- return e / 10 ** r(t);
20
+ function o(e, t) {
21
+ return e / 10 ** i(t);
21
22
  }
22
- function o(e) {
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 s(e) {
34
- if (!e) return "";
35
- let t = a(e.value, e.currency);
34
+ function c(t) {
35
+ if (!t) return "";
36
+ let n = o(t.value, t.currency);
36
37
  try {
37
- return new Intl.NumberFormat(void 0, {
38
- style: "currency",
39
- currency: e.currency
40
- }).format(t);
38
+ return e(t.currency).format(n);
41
39
  } catch {
42
- return `${t} ${e.currency}`;
40
+ return `${n} ${t.currency}`;
43
41
  }
44
42
  }
45
- var c = new Intl.DateTimeFormat(void 0, {
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 l(e) {
48
+ function u(e) {
51
49
  if (!e) return "";
52
50
  let t = new Date(e);
53
- return Number.isNaN(t.getTime()) ? "" : c.format(t);
51
+ return Number.isNaN(t.getTime()) ? "" : l.format(t);
54
52
  }
55
- function u(e) {
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 d(e) {
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 f({ products: e, unitNamesById: t }) {
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: s(e.price)
71
+ priceLabel: c(e.price)
74
72
  }));
75
73
  }
76
- function p({ product: e, unitNamesById: t }) {
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: s(e.price),
83
- createdAtLabel: l(e.created_at),
84
- updatedAtLabel: l(e.updated_at)
80
+ priceLabel: c(e.price),
81
+ createdAtLabel: u(e.created_at),
82
+ updatedAtLabel: u(e.updated_at)
85
83
  };
86
84
  }
87
- var m = {
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 h(e, t) {
93
+ function g(e, t) {
96
94
  return Object.keys(e).every((n) => e[n] === t[n]);
97
95
  }
98
- function g(e) {
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(a(e.price.value, e.price.currency)) : "",
103
+ pricePerUnit: e.price ? String(o(e.price.value, e.price.currency)) : "",
106
104
  currency: t
107
105
  };
108
106
  }
109
- function _(e) {
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: i(Number(t), "USD"),
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 v(e) {
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: i(Number(t), e.currency),
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 y = 100, b = 255;
136
- function x(e, t = n) {
137
- let r = {};
138
- e.name.trim().length === 0 ? r.name = t.nameRequired : e.name.trim().length > y && (r.name = t.nameTooLong), e.type !== "product" && e.type !== "service" && (r.type = t.typeRequired);
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) && (r.pricePerUnit = t.priceInvalid);
140
+ (!Number.isFinite(e) || e < 0) && (n.pricePerUnit = t.priceInvalid);
143
141
  }
144
- return e.description.trim().length > b && (r.description = t.descriptionTooLong), r;
142
+ return e.description.trim().length > x && (n.description = t.descriptionTooLong), n;
145
143
  }
146
- var S = {
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 C(r, i = n) {
155
- let a = t(r);
156
- if (!a.length) return { form: e(r) ?? i.genericError };
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 = S[e];
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 w(e) {
162
+ function T(e) {
165
163
  return Object.values(e).some(Boolean);
166
164
  }
167
- function T(e, t = n) {
165
+ function E(e, t = r) {
168
166
  return e.name.trim().length === 0 ? t.unitNameRequired : void 0;
169
167
  }
170
- function E() {
168
+ function D() {
171
169
  let e = globalThis.getSelection?.();
172
170
  return !!(e && e.toString().length > 0);
173
171
  }
174
172
  //#endregion
175
- export { m as EMPTY_PRODUCT_FORM_VALUES, C as apiErrorToProductFormErrors, h as areProductFormValuesEqual, p as buildProductDetailsView, f as buildProductRows, u as buildUnitNamesById, d as buildUnitOptions, o as currencySymbol, s as formatPrice, l as formatProductDate, a as fromMinorUnits, w as hasProductFormErrors, E as hasSelectedText, _ as productFormValuesToRequest, v as productFormValuesToUpdateRequest, g as productToFormValues, i as toMinorUnits, T as validateMeasureUnit, x as validateProductForm };
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 };
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,6 +0,0 @@
1
- //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/currencyDisplay.js
2
- function e(e) {
3
- return e.toUpperCase() === "USD" ? "narrowSymbol" : "symbol";
4
- }
5
- //#endregion
6
- export { e as currencyDisplayFor };