@tesouro/embedded-components-react 0.5.210 → 0.5.212

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 (33) hide show
  1. package/dist/index.d.ts +16 -0
  2. package/dist/index.js +1 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +16 -0
  4. package/dist/lib/ReceivablesWidget.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +113 -109
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +416 -132
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +113 -211
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +154 -37
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +193 -135
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +32 -37
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +150 -58
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +35 -89
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +58 -116
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +96 -47
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +103 -347
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +364 -64
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +66 -106
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +105 -275
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +288 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +76 -61
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +48 -422
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +5 -5
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +38 -62
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +61 -391
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +457 -89
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +91 -234
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +234 -78
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +80 -331
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +344 -0
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +10 -0
  32. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  33. package/package.json +1 -1
@@ -27,38 +27,47 @@ function s(t, n) {
27
27
  maximumFractionDigits: r
28
28
  }).format(t / 10 ** r);
29
29
  }
30
- function c(t, i, a = n()) {
31
- if (t.trim() === "") return 0;
32
- let o = Array.from(t, (e) => {
33
- let t = a.digits.indexOf(e);
34
- return t === -1 ? e : String(t);
30
+ function c(t, r, i = n()) {
31
+ return Math.round(l(t, i) * 10 ** e(r));
32
+ }
33
+ function l(e, t = n()) {
34
+ if (e.trim() === "") return 0;
35
+ let i = Array.from(e, (e) => {
36
+ let n = t.digits.indexOf(e);
37
+ return n === -1 ? e : String(n);
35
38
  }).join("");
36
- a.group && (o = o.replace(new RegExp(r(a.group), "g"), "")), o = o.replace(a.decimal, ".");
37
- let s = parseFloat(o);
38
- return Number.isNaN(s) ? 0 : Math.round(s * 10 ** e(i));
39
+ t.group && (i = i.replace(new RegExp(r(t.group), "g"), "")), i = i.replace(t.decimal, ".");
40
+ let a = parseFloat(i);
41
+ return Number.isNaN(a) ? 0 : a;
39
42
  }
40
- function l(t, r, i, a = n()) {
43
+ function u(t, r, i, a = n()) {
41
44
  let o = c(t, r, a) / 10 ** e(r);
42
45
  return s(Math.round(o * 10 ** e(i)), i);
43
46
  }
44
- function u(e) {
47
+ function d(e) {
45
48
  let t = i(e);
46
49
  return t.length > 1 && t.startsWith("0") && t[1] !== "." && (t = t.replace(/^0+/, "") || "0"), t === "" || t === "." ? t : Number(t) > 100 ? "100" : t;
47
50
  }
48
- function d(e) {
51
+ function f(e) {
49
52
  return e.endsWith(".") ? e.slice(0, -1) : e;
50
53
  }
51
- function f(e) {
54
+ function p(e) {
52
55
  return Math.round((Number(e) || 0) * 100);
53
56
  }
54
- function p(e) {
57
+ function m(e, t) {
58
+ return t !== void 0 && p(e) === p(t);
59
+ }
60
+ function h(e, t, n) {
61
+ return n && e.savedTaxRate !== void 0 && g(e.savedTaxStatus) ? e.savedTaxRate : t;
62
+ }
63
+ function g(e) {
55
64
  return (e ?? "taxable") === "taxable";
56
65
  }
57
- function m(e) {
58
- let t = e.find((e) => p(e.tax_status))?.product.tax_rate?.value;
66
+ function _(e) {
67
+ let t = e.find((e) => g(e.tax_status))?.product.tax_rate?.value;
59
68
  return t === void 0 ? "" : String(t / 100);
60
69
  }
61
- function h(e) {
70
+ function v(e) {
62
71
  try {
63
72
  return new Intl.NumberFormat(void 0, {
64
73
  style: "currency",
@@ -68,12 +77,12 @@ function h(e) {
68
77
  return e;
69
78
  }
70
79
  }
71
- function g() {
80
+ function y() {
72
81
  return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
73
82
  }
74
- function _(e = "USD") {
83
+ function b(e = "USD") {
75
84
  return {
76
- id: g(),
85
+ id: y(),
77
86
  productId: "",
78
87
  name: "",
79
88
  quantity: "1",
@@ -84,7 +93,7 @@ function _(e = "USD") {
84
93
  taxable: !0
85
94
  };
86
95
  }
87
- function v({ id: e, name: t, quantity: n, price: r, measureUnitId: i, taxable: a }) {
96
+ function x({ id: e, name: t, quantity: n, price: r, measureUnitId: i, taxable: a }) {
88
97
  return {
89
98
  id: e,
90
99
  name: t,
@@ -94,14 +103,14 @@ function v({ id: e, name: t, quantity: n, price: r, measureUnitId: i, taxable: a
94
103
  taxable: a
95
104
  };
96
105
  }
97
- function y(e) {
106
+ function S(e) {
98
107
  return !e.name.trim();
99
108
  }
100
- function b(e) {
101
- let t = e.filter((e) => !y(e));
109
+ function C(e) {
110
+ let t = e.filter((e) => !S(e));
102
111
  return t.length > 0 ? t : e.slice(0, 1);
103
112
  }
104
- function x({ product: e, currency: t, unitNamesById: n }) {
113
+ function w({ product: e, currency: t, unitNamesById: n }) {
105
114
  let r = e.measure_unit_id ?? "";
106
115
  return {
107
116
  productId: e.id,
@@ -115,13 +124,13 @@ function x({ product: e, currency: t, unitNamesById: n }) {
115
124
  } : {}
116
125
  };
117
126
  }
118
- function S(e) {
127
+ function T(e) {
119
128
  return e.quantity === void 0 ? e : {
120
129
  ...e,
121
130
  quantity: i(e.quantity)
122
131
  };
123
132
  }
124
- function C({ lineItem: e, field: t, rowCount: r, currency: l, separators: u = n() }) {
133
+ function E({ lineItem: e, field: t, rowCount: r, currency: l, separators: u = n() }) {
125
134
  if (t === "price") return {
126
135
  kind: "update",
127
136
  patch: { price: s(c(e.price, l, u), l) }
@@ -135,31 +144,34 @@ function C({ lineItem: e, field: t, rowCount: r, currency: l, separators: u = n(
135
144
  patch: { quantity: String(d) }
136
145
  };
137
146
  }
138
- function w({ lineItem: e, step: t, rowCount: n }) {
139
- if (y(e)) return;
147
+ function D({ lineItem: e, step: t, rowCount: n }) {
148
+ if (S(e)) return;
140
149
  let r = o(Math.max(0, a(e.quantity)) + t);
141
150
  return r <= 0 && n > 1 ? { kind: "remove" } : {
142
151
  kind: "update",
143
152
  patch: { quantity: String(Math.max(n > 1 ? 0 : 1, r)) }
144
153
  };
145
154
  }
146
- function T(e) {
155
+ function O(e) {
147
156
  return Object.fromEntries(e.map((t) => {
148
- let n = !y(t), r = a(t.quantity);
157
+ let n = !S(t), r = a(t.quantity);
149
158
  return [t.id, {
150
159
  canDecreaseQuantity: n && (e.length > 1 || r > 1),
151
160
  canIncreaseQuantity: n
152
161
  }];
153
162
  }));
154
163
  }
155
- function E(e, t) {
156
- return {
157
- tax_status: e.taxable ? "taxable" : "non_taxable",
158
- tax_rate_value: e.taxable ? f(t) : void 0
164
+ function k(e, t, n = !1) {
165
+ return e.taxable ? {
166
+ tax_status: "taxable",
167
+ tax_rate_value: h(e, p(t), n)
168
+ } : {
169
+ tax_status: e.savedTaxStatus === "exempt" ? "exempt" : "non_taxable",
170
+ tax_rate_value: void 0
159
171
  };
160
172
  }
161
- function D({ lineItem: e, currency: t, taxRate: n, unitNamesById: r }) {
162
- let i = e.measureUnitId ? r[e.measureUnitId] : void 0, { tax_status: o, tax_rate_value: s } = E(e, n);
173
+ function A({ lineItem: e, currency: t, taxRate: n, unitNamesById: r }) {
174
+ let i = e.measureUnitId ? r[e.measureUnitId] : void 0, { tax_status: o, tax_rate_value: s } = k(e, n);
163
175
  return {
164
176
  quantity: a(e.quantity),
165
177
  tax_status: o,
@@ -175,24 +187,25 @@ function D({ lineItem: e, currency: t, taxRate: n, unitNamesById: r }) {
175
187
  tax_rate_value: s
176
188
  };
177
189
  }
178
- function O({ lineItem: e, currency: t, taxRate: n, unitNamesById: r }) {
179
- let i = e.measureUnitId && r[e.measureUnitId] || e.measureUnitName || void 0, { tax_status: o, tax_rate_value: s } = E(e, n);
190
+ function j({ lineItem: e, currency: t, taxRate: n, keepSavedRate: r, unitNamesById: i }) {
191
+ let o = e.measureUnitId && i[e.measureUnitId] || e.measureUnitName || void 0, { tax_status: s, tax_rate_value: l } = k(e, n, r);
180
192
  return {
181
193
  quantity: a(e.quantity),
182
- tax_status: o,
194
+ tax_status: s,
183
195
  product: {
184
196
  name: e.name,
185
197
  type: e.productType,
186
- measure_unit: i ? { name: i } : void 0,
198
+ measure_unit: o ? { name: o } : void 0,
187
199
  price: {
188
200
  currency: t,
189
201
  value: c(e.price, t)
190
202
  }
191
203
  },
192
- tax_rate_value: s
204
+ tax_rate_value: l,
205
+ discount: e.savedDiscount
193
206
  };
194
207
  }
195
- function k({ lineItem: e, currency: t, units: n }) {
208
+ function M({ lineItem: e, currency: t, units: n }) {
196
209
  let r = e.product.measure_unit;
197
210
  return {
198
211
  id: e.id,
@@ -200,23 +213,26 @@ function k({ lineItem: e, currency: t, units: n }) {
200
213
  name: e.product.name,
201
214
  quantity: String(e.quantity),
202
215
  price: s(e.product.price?.value ?? 0, t),
203
- measureUnitId: j(r?.id ?? "", r?.name ?? "", n),
216
+ measureUnitId: P(r?.id ?? "", r?.name ?? "", n),
204
217
  measureUnitName: r?.name ?? "",
205
218
  productType: e.product.type ?? "product",
206
- taxable: p(e.tax_status)
219
+ taxable: g(e.tax_status),
220
+ savedTaxStatus: e.tax_status,
221
+ savedTaxRate: e.product.tax_rate?.value,
222
+ savedDiscount: e.discount ?? void 0
207
223
  };
208
224
  }
209
- function A(e, t) {
225
+ function N(e, t) {
210
226
  if (!t) return;
211
227
  let n = t.toLowerCase();
212
228
  return e.find((e) => e.name.toLowerCase() === n);
213
229
  }
214
- function j(e, t, n) {
215
- return n?.length ? ((e ? n.find((t) => t.id === e) : void 0) ?? A(n, t))?.id ?? (t ? "" : e) : e;
230
+ function P(e, t, n) {
231
+ return n?.length ? ((e ? n.find((t) => t.id === e) : void 0) ?? N(n, t))?.id ?? (t ? "" : e) : e;
216
232
  }
217
- function M(e, t) {
233
+ function F(e, t) {
218
234
  let n = !1, r = e.map((e) => {
219
- let r = j(e.measureUnitId, e.measureUnitName, t);
235
+ let r = P(e.measureUnitId, e.measureUnitName, t);
220
236
  return r === e.measureUnitId ? e : (n = !0, {
221
237
  ...e,
222
238
  measureUnitId: r
@@ -224,26 +240,25 @@ function M(e, t) {
224
240
  });
225
241
  return n ? r : e;
226
242
  }
227
- function N(n) {
243
+ function I(n) {
228
244
  return new Intl.NumberFormat().format(t / 10 ** e(n));
229
245
  }
230
- function P(e, { currency: n, messages: r }) {
231
- let i = {};
232
- for (let a of e) {
246
+ function L(e, { currency: t, messages: n }) {
247
+ let r = {};
248
+ for (let i of e) {
233
249
  let e = {};
234
- a.name.length > 100 && (e.name = r.lineItemNameTooLong), c(a.price, n) > t && (e.price = r.lineItemPriceTooHigh.replace("{maxAmount}", N(n))), Object.keys(e).length > 0 && (i[a.id] = e);
250
+ i.name.length > 100 && (e.name = n.lineItemNameTooLong), c(i.price, t) > 9e15 && (e.price = n.lineItemPriceTooHigh.replace("{maxAmount}", I(t))), Object.keys(e).length > 0 && (r[i.id] = e);
235
251
  }
236
- return Object.keys(i).length > 0 ? i : void 0;
252
+ return Object.keys(r).length > 0 ? r : void 0;
237
253
  }
238
- function F(e) {
239
- if (!e) return;
240
- let t = Object.values(e), n = [
254
+ function R(e, t) {
255
+ let n = Object.values(e ?? {}), r = [t, ...[
241
256
  "name",
242
257
  "quantity",
243
258
  "price",
244
259
  "measureUnit"
245
- ].map((e) => t.find((t) => t[e])?.[e]).filter((e) => !!e);
246
- return n.length > 0 ? n : void 0;
260
+ ].map((e) => n.find((t) => t[e])?.[e])].filter((e) => !!e);
261
+ return r.length > 0 ? r : void 0;
247
262
  }
248
263
  //#endregion
249
- export { T as buildLineItemControls, C as commitLineItemField, d as commitTaxRateInput, l as convertPriceInput, _ as createLineItem, s as formatPriceInput, h as getCurrencySymbol, n as getNumberSeparators, y as isBlankLineItem, p as isLineItemTaxable, x as lineItemFromProduct, D as lineItemToCreatePayload, O as lineItemToUpdatePayload, a as parseQuantity, c as priceInputToMinorUnits, M as reconcileMeasureUnits, k as responseLineItemToFormValues, S as sanitizeLineItemPatch, i as sanitizeQuantityInput, u as sanitizeTaxRateInput, w as stepLineItemQuantity, b as stripBlankLineItems, F as summarizeLineItemErrors, m as taxRateFromLineItems, f as taxRateToMinorUnits, v as toSheetLineItem, P as validateLineItems };
264
+ export { t as MAX_AMOUNT_MINOR_UNITS, O as buildLineItemControls, E as commitLineItemField, f as commitTaxRateInput, u as convertPriceInput, b as createLineItem, r as escapeRegex, s as formatPriceInput, v as getCurrencySymbol, n as getNumberSeparators, S as isBlankLineItem, g as isLineItemTaxable, m as keepsSavedTaxRates, w as lineItemFromProduct, h as lineItemTaxRateMinorUnits, A as lineItemToCreatePayload, j as lineItemToUpdatePayload, I as maxAmountLabel, l as parseLocaleDecimal, a as parseQuantity, c as priceInputToMinorUnits, F as reconcileMeasureUnits, M as responseLineItemToFormValues, T as sanitizeLineItemPatch, i as sanitizeQuantityInput, d as sanitizeTaxRateInput, D as stepLineItemQuantity, C as stripBlankLineItems, R as summarizeLineItemErrors, _ as taxRateFromLineItems, p as taxRateToMinorUnits, x as toSheetLineItem, L as validateLineItems };