@tesouro/embedded-components-react 0.11.113 → 0.11.116

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.
@@ -1,9 +1,10 @@
1
1
  import { InvoicesFilterField as e } from "../../../../ui/dist/index3.js";
2
2
  import "../../../../ui/dist/index.js";
3
- import { INVOICES_DATE_PRESET_GROUPS as t } from "./datePresets.js";
4
- import { addDays as n, formatISO as r, startOfDay as i } from "date-fns";
3
+ import { formatMoney as t } from "./helpers.js";
4
+ import { INVOICES_DATE_PRESET_GROUPS as n } from "./datePresets.js";
5
+ import { addDays as r, format as i, formatISO as a, startOfDay as o } from "date-fns";
5
6
  // ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/invoicesFilter.js
6
- var a = [
7
+ var s = [
7
8
  "draft",
8
9
  "issued",
9
10
  "overdue",
@@ -12,32 +13,32 @@ var a = [
12
13
  "uncollectible",
13
14
  "canceled",
14
15
  "recurring"
15
- ], o = [
16
+ ], c = [
16
17
  "draft",
17
18
  "issued",
18
19
  "overdue",
19
20
  "partially_paid",
20
21
  "paid",
21
22
  "uncollectible"
22
- ], s = [
23
+ ], l = [
23
24
  e.DueDate,
24
25
  e.CreatedAt,
25
26
  e.IssueDate,
26
27
  e.Status,
27
28
  e.Amount,
28
29
  e.Customer
29
- ], c = {
30
+ ], u = {
30
31
  dueDate: "due_date",
31
32
  createdAt: "created_at",
32
33
  issueDate: "issue_date"
33
- }, l = {
34
+ }, d = {
34
35
  Status: "status",
35
36
  Customer: "customer",
36
37
  Counterpart: "counterpart",
37
38
  Amount: "amount",
38
39
  Search: "search"
39
- }, u = "date_";
40
- function d(e) {
40
+ }, f = "date_";
41
+ function p(e) {
41
42
  return {
42
43
  dateRanges: {},
43
44
  statuses: [],
@@ -48,71 +49,105 @@ function d(e) {
48
49
  customerId: e
49
50
  };
50
51
  }
51
- function f(e) {
52
+ function m(e) {
52
53
  return !!(e?.from || e?.to || e?.preset);
53
54
  }
54
- function p(e) {
55
+ function h(e) {
55
56
  return Object.entries(e.dateRanges);
56
57
  }
57
- function m(e) {
58
+ function g(e) {
58
59
  let t = Number.parseFloat(e);
59
60
  return Number.isNaN(t) ? void 0 : Math.round(t * 100);
60
61
  }
61
- function h(e) {
62
+ function _(e) {
63
+ if (e.amountMode === "any") return {};
64
+ let t = g(e.amountMin);
65
+ return e.amountMode === "exact" ? {
66
+ min: t,
67
+ max: t
68
+ } : {
69
+ min: t,
70
+ max: g(e.amountMax)
71
+ };
72
+ }
73
+ function v(e) {
74
+ let { min: t, max: n } = _(e);
75
+ return t !== void 0 || n !== void 0;
76
+ }
77
+ function y(e) {
62
78
  let t = {};
63
- for (let [a, o] of p(e)) {
64
- let e = c[a];
65
- e === "due_date" ? (o?.from && (t.due_date__gte = r(o.from, { representation: "date" })), o?.to && (t.due_date__lte = r(o.to, { representation: "date" }))) : (o?.from && (t[`${e}__gte`] = i(o.from).toISOString()), o?.to && (t[`${e}__lt`] = n(i(o.to), 1).toISOString()));
66
- }
67
- if (t.status__in = e.statuses.length > 0 ? e.statuses : o, e.customerName && (t.counterpart_name__icontains = e.customerName), e.customerId && (t.counterpart_id = e.customerId), e.amountMode !== "any") {
68
- let n = m(e.amountMin), r = m(e.amountMax);
69
- e.amountMode === "exact" ? n !== void 0 && (t.total_amount__gte = n, t.total_amount__lte = n) : (n !== void 0 && (t.total_amount__gte = n), r !== void 0 && (t.total_amount__lte = r));
79
+ for (let [n, i] of h(e)) {
80
+ let e = u[n];
81
+ e === "due_date" ? (i?.from && (t.due_date__gte = a(i.from, { representation: "date" })), i?.to && (t.due_date__lte = a(i.to, { representation: "date" }))) : (i?.from && (t[`${e}__gte`] = o(i.from).toISOString()), i?.to && (t[`${e}__lt`] = r(o(i.to), 1).toISOString()));
70
82
  }
71
- return t;
83
+ t.status__in = e.statuses.length > 0 ? e.statuses : c, e.customerName && (t.counterpart_name__icontains = e.customerName), e.customerId && (t.counterpart_id = e.customerId);
84
+ let { min: n, max: i } = _(e);
85
+ return n !== void 0 && (t.total_amount__gte = n), i !== void 0 && (t.total_amount__lte = i), t;
72
86
  }
73
- function g(e, t) {
87
+ function b(e, t) {
74
88
  return [
75
- Object.values(e.dateRanges).some(f),
89
+ Object.values(e.dateRanges).some(m),
76
90
  e.statuses.length > 0,
77
91
  !!e.customerName,
78
92
  !!e.customerId,
79
- e.amountMode !== "any",
93
+ v(e),
80
94
  !!t
81
95
  ].filter(Boolean).length;
82
96
  }
83
- function _({ state: e, search: t, counterpartName: n, labels: r, statusLabels: i }) {
97
+ var x = "MMM d, yyyy";
98
+ function S(e, t) {
99
+ if (e?.preset && e.preset in t.presets) return t.presets[e.preset];
100
+ let n = e?.from && i(e.from, x), r = e?.to && i(e.to, x);
101
+ if (n && r) return t.dateRange(n, r);
102
+ if (n) return t.dateFrom(n);
103
+ if (r) return t.dateTo(r);
104
+ }
105
+ var C = (e) => e === void 0 ? void 0 : t({
106
+ amount: e,
107
+ currency: "USD",
108
+ fallback: ""
109
+ });
110
+ function w(e, t) {
111
+ let n = _(e), r = C(n.min), i = C(n.max);
112
+ if (e.amountMode === "exact") return r;
113
+ if (r && i) return t.amountBetween(r, i);
114
+ if (r) return t.amountAtLeast(r);
115
+ if (i) return t.amountAtMost(i);
116
+ }
117
+ function T({ state: e, search: t, counterpartName: n, labels: r, statusLabels: i }) {
84
118
  let a = [], o = new Map(Object.entries(i));
85
- for (let [t, n] of p(e)) {
86
- if (!f(n)) continue;
87
- let e = n?.preset && n.preset in r.presets ? r.presets[n.preset] : void 0;
88
- a.push({
89
- key: `${u}${t}`,
90
- label: r.dateChip(r.dateFieldNames[t], e ?? r.customRange)
119
+ for (let [t, n] of h(e)) {
120
+ let e = S(n, r);
121
+ e && a.push({
122
+ key: `${f}${t}`,
123
+ label: r.dateChip(r.dateFieldNames[t], e)
91
124
  });
92
125
  }
93
126
  if (e.statuses.length > 0) {
94
127
  let [t, ...n] = e.statuses.map((e) => o.get(e) ?? e);
95
128
  a.push({
96
- key: l.Status,
129
+ key: d.Status,
97
130
  label: r.statusChip(n.length === 0 ? t : r.moreSelected(t, n.length))
98
131
  });
99
132
  }
100
- return e.customerName && a.push({
101
- key: l.Customer,
133
+ e.customerName && a.push({
134
+ key: d.Customer,
102
135
  label: r.customerChip(e.customerName)
103
136
  }), e.customerId && a.push({
104
- key: l.Counterpart,
137
+ key: d.Counterpart,
105
138
  label: r.customerChip(n || e.customerId)
106
- }), e.amountMode !== "any" && a.push({
107
- key: l.Amount,
108
- label: r.amountChip
139
+ });
140
+ let s = w(e, r);
141
+ return s && a.push({
142
+ key: d.Amount,
143
+ label: r.amountChip(s)
109
144
  }), t && a.push({
110
- key: l.Search,
145
+ key: d.Search,
111
146
  label: r.searchChip(t)
112
147
  }), a;
113
148
  }
114
- function v(e, t) {
115
- if (t.startsWith(u)) {
149
+ function E(e, t) {
150
+ if (t.startsWith(f)) {
116
151
  let n = t.slice(5), r = { ...e.dateRanges };
117
152
  return delete r[n], {
118
153
  ...e,
@@ -120,19 +155,19 @@ function v(e, t) {
120
155
  };
121
156
  }
122
157
  switch (t) {
123
- case l.Status: return {
158
+ case d.Status: return {
124
159
  ...e,
125
160
  statuses: []
126
161
  };
127
- case l.Customer: return {
162
+ case d.Customer: return {
128
163
  ...e,
129
164
  customerName: ""
130
165
  };
131
- case l.Counterpart: return {
166
+ case d.Counterpart: return {
132
167
  ...e,
133
168
  customerId: void 0
134
169
  };
135
- case l.Amount: return {
170
+ case d.Amount: return {
136
171
  ...e,
137
172
  amountMode: "any",
138
173
  amountMin: "",
@@ -141,18 +176,18 @@ function v(e, t) {
141
176
  default: return e;
142
177
  }
143
178
  }
144
- function y(e, t) {
145
- return a.map((n) => ({
179
+ function D(e, t) {
180
+ return s.map((n) => ({
146
181
  value: n,
147
182
  label: e[n],
148
183
  description: t.statusDescriptions[n]
149
184
  }));
150
185
  }
151
- function b(e) {
152
- return Object.entries(t).map(([t, n]) => ({
186
+ function O(e) {
187
+ return Object.entries(n).map(([t, n]) => ({
153
188
  value: t,
154
189
  label: e.presets[t],
155
190
  group: n === "current" ? e.presetGroupCurrent : e.presetGroupPast
156
191
  }));
157
192
  }
158
- export { s as INVOICES_FILTER_FIELDS, o as INVOICE_DEFAULT_STATUSES, a as INVOICE_FILTER_STATUSES, l as InvoicesFilterChipKey, b as buildInvoicesDatePresetOptions, _ as buildInvoicesFilterChips, h as buildInvoicesFilterQuery, y as buildInvoicesStatusOptions, v as clearInvoicesFilter, g as countActiveInvoiceFilters, d as emptyInvoicesFilterState };
193
+ export { l as INVOICES_FILTER_FIELDS, c as INVOICE_DEFAULT_STATUSES, s as INVOICE_FILTER_STATUSES, d as InvoicesFilterChipKey, O as buildInvoicesDatePresetOptions, T as buildInvoicesFilterChips, y as buildInvoicesFilterQuery, D as buildInvoicesStatusOptions, E as clearInvoicesFilter, b as countActiveInvoiceFilters, p as emptyInvoicesFilterState };
@@ -22,7 +22,9 @@ var t = {
22
22
  createdAt: "Created on",
23
23
  issueDate: "Issue date"
24
24
  },
25
- customRange: "Custom range",
25
+ dateRange: (e, t) => `${e} - ${t}`,
26
+ dateFrom: (e) => `From ${e}`,
27
+ dateTo: (e) => `Until ${e}`,
26
28
  statusDescriptions: {
27
29
  draft: "Created but not yet sent",
28
30
  overdue: "Past due date",
@@ -33,7 +35,10 @@ var t = {
33
35
  statusChip: (e) => `Status: ${e}`,
34
36
  moreSelected: (e, t) => `${e} + ${t} more`,
35
37
  customerChip: (e) => `Customer: ${e}`,
36
- amountChip: "Amount",
38
+ amountChip: (e) => `Amount: ${e}`,
39
+ amountAtLeast: (e) => `${e} or more`,
40
+ amountAtMost: (e) => `${e} or less`,
41
+ amountBetween: (e, t) => `${e} - ${t}`,
37
42
  searchChip: (e) => `Search: ${e}`
38
43
  };
39
44
  function n(e) {
@@ -1,5 +1,5 @@
1
1
  // ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.11.113", n = "860d8fe9c734b30d9d3d12d1cd6fdf0c82f5d333", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.11.116", n = "40d2b4ab6611b58bdceed06101c83e902941346f", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -11,8 +11,9 @@ import "../../../../../../invoicing-widget/feature/dist/index.js";
11
11
  import { jsx as i } from "react/jsx-runtime";
12
12
  // ../../libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/InvoicingSection.js
13
13
  function a({ renderTitle: n } = {}) {
14
- let { arrivingFlow: a } = t();
14
+ let { arrivingFlow: a, labels: o } = t();
15
15
  return /* @__PURE__ */ i(r, {
16
+ ...o.sections.invoicing,
16
17
  headerStart: n?.(),
17
18
  ...a === e.Invoicing && { initialView: "create" }
18
19
  });
@@ -186,20 +186,10 @@ F("ellipsis", [
186
186
  key: "1pcz8c"
187
187
  }]
188
188
  ]);
189
- var ue = F("list-filter", [
190
- ["path", {
191
- d: "M2 5h20",
192
- key: "1fs1ex"
193
- }],
194
- ["path", {
195
- d: "M6 12h12",
196
- key: "8npq4p"
197
- }],
198
- ["path", {
199
- d: "M9 19h6",
200
- key: "456am0"
201
- }]
202
- ]), de = F("loader-circle", [["path", {
189
+ var ue = F("funnel", [["path", {
190
+ d: "M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",
191
+ key: "sc7q7i"
192
+ }]]), de = F("loader-circle", [["path", {
203
193
  d: "M21 12a9 9 0 1 1-6.219-8.56",
204
194
  key: "13zald"
205
195
  }]]);
@@ -17435,9 +17425,12 @@ function OM({ activeCount: e, size: t = "sm", labels: n, className: r, ...i }) {
17435
17425
  };
17436
17426
  return /* @__PURE__ */ v("button", {
17437
17427
  type: "button",
17438
- className: Y("ttw:inline-flex ttw:items-center ttw:gap-1", t === "default" ? "ttw:h-9" : "ttw:h-8", "ttw:px-3 ttw:py-2 ttw:rounded-md", "ttw:bg-background ttw:border ttw:border-input ttw:shadow-xs", "ttw:text-sm ttw:font-medium ttw:text-foreground", "ttw:transition-[color,background-color,box-shadow] ttw:cursor-pointer", "ttw:hover:bg-accent ttw:hover:text-accent-foreground", "ttw:focus-visible:outline-none ttw:focus-visible:border-ring", "ttw:focus-visible:ring-[3px] ttw:focus-visible:ring-ring/50", "ttw:disabled:pointer-events-none ttw:disabled:opacity-50", r),
17428
+ className: Y(Cv({
17429
+ variant: "ghost",
17430
+ size: t
17431
+ }), r),
17439
17432
  ...i,
17440
- children: [/* @__PURE__ */ _(ue, { className: "ttw:size-4 ttw:shrink-0" }), /* @__PURE__ */ v("span", { children: [a.filters, e !== void 0 && e > 0 ? ` (${e})` : null] })]
17433
+ children: [/* @__PURE__ */ _(ue, { "aria-hidden": !0 }), /* @__PURE__ */ v("span", { children: [a.filters, e !== void 0 && e > 0 ? ` (${e})` : null] })]
17441
17434
  });
17442
17435
  }
17443
17436
  var kM = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.11.113",
3
+ "version": "0.11.116",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [