@tesouro/embedded-components-react 0.9.37 → 0.9.39

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.
@@ -600,10 +600,14 @@ interface WidgetProviderProps extends WidgetProviderBaseProps {
600
600
 
601
601
  interface ApprovalRequestsScreenLabels {
602
602
  columnInvoiceNumber: string;
603
+ columnVendor: string;
603
604
  columnIssueDate: string;
604
605
  columnDueDate: string;
605
606
  columnStatus: string;
606
607
  columnAmount: string;
608
+ columnAddedBy: string;
609
+ /** Read by screen readers in a cell whose name is still loading. */
610
+ loadingValue: string;
607
611
  errorTitle: string;
608
612
  errorDescription: string;
609
613
  errorRetry: string;
@@ -616,6 +620,8 @@ interface ApprovalRequestsListLabels {
616
620
  filterEmptyDescription: string;
617
621
  /** Shown in a cell whose value the request's payable does not carry. */
618
622
  missingValue: string;
623
+ /** Shown for a vendor or creator this session may not read, or whose lookup failed. */
624
+ unavailableValue: string;
619
625
  status: Record<ApprovalRequestStatus, string>;
620
626
  }
621
627
 
@@ -600,10 +600,14 @@ interface WidgetProviderProps extends WidgetProviderBaseProps {
600
600
 
601
601
  interface ApprovalRequestsScreenLabels {
602
602
  columnInvoiceNumber: string;
603
+ columnVendor: string;
603
604
  columnIssueDate: string;
604
605
  columnDueDate: string;
605
606
  columnStatus: string;
606
607
  columnAmount: string;
608
+ columnAddedBy: string;
609
+ /** Read by screen readers in a cell whose name is still loading. */
610
+ loadingValue: string;
607
611
  errorTitle: string;
608
612
  errorDescription: string;
609
613
  errorRetry: string;
@@ -616,6 +620,8 @@ interface ApprovalRequestsListLabels {
616
620
  filterEmptyDescription: string;
617
621
  /** Shown in a cell whose value the request's payable does not carry. */
618
622
  missingValue: string;
623
+ /** Shown for a vendor or creator this session may not read, or whose lookup failed. */
624
+ unavailableValue: string;
619
625
  status: Record<ApprovalRequestStatus, string>;
620
626
  }
621
627
 
@@ -5,4 +5,5 @@ import { useApprovalRequestsQuery as e } from "./index3.js";
5
5
  import "./index4.js";
6
6
  import "./index5.js";
7
7
  import "./index6.js";
8
- export { e as useApprovalRequestsQuery };
8
+ import { useEntityUsersByIdsQuery as t } from "./index7.js";
9
+ export { e as useApprovalRequestsQuery, t as useEntityUsersByIdsQuery };
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { getEntityUsersOptions as e } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
6
+ import { withAuthEpoch as t } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
7
+ import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
9
+ import "../../../shared/data-access/dist/index.js";
10
+ import { useMemo as i } from "react";
11
+ import { useQuery as a } from "@tanstack/react-query";
12
+ //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index7.js
13
+ function o({ ids: o, enabled: s }) {
14
+ let { client: c, organizationId: l, widgetToken: u, authEpoch: d, organizationStatus: f } = n(), p = i(() => [...new Set(o.filter(Boolean))].sort().slice(0, 100), [o]), m = e({
15
+ client: c,
16
+ headers: r(l),
17
+ query: {
18
+ id__in: p,
19
+ limit: 100
20
+ }
21
+ });
22
+ return a({
23
+ ...t(m, {
24
+ authEpoch: d,
25
+ organizationStatus: f
26
+ }, { carryWithinOrg: !0 }),
27
+ enabled: !!(l && u) && (s === !0 || s === void 0) && p.length > 0
28
+ });
29
+ }
30
+ //#endregion
31
+ export { o as useEntityUsersByIdsQuery };
@@ -2,28 +2,41 @@ import { createCurrencyFormatter as e } from "../../../../../shared/util/dist/li
2
2
  import { formatCalendarDate as t } from "../../../../../shared/util/dist/lib/formatCalendarDate.js";
3
3
  import "../../../../../shared/util/dist/index.js";
4
4
  import { STATUS_TONE as n } from "./constants.js";
5
+ import { NameLookupState as r } from "./useApprovalRequestNames.js";
5
6
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js
6
- var r = { day: "2-digit" };
7
- function i(t, n) {
7
+ var i = { day: "2-digit" };
8
+ function a(t, n) {
8
9
  let r = new Intl.NumberFormat("en-US", {
9
10
  style: "currency",
10
11
  currency: n
11
12
  }).resolvedOptions().maximumFractionDigits ?? 2;
12
13
  return e(n).format(t / 10 ** r);
13
14
  }
14
- function a(e, a) {
15
- return e.map(({ request: e, payable: o }) => {
16
- let s = o?.amount_to_pay, c = o?.currency;
15
+ function o(e, t, n) {
16
+ if (!e) return n.missingValue;
17
+ let i = t.names.get(e);
18
+ if (i) return i;
19
+ switch (t.state) {
20
+ case r.Resolving: return;
21
+ case r.Unavailable: return n.unavailableValue;
22
+ case r.Settled: return n.missingValue;
23
+ }
24
+ }
25
+ function s(e, r, s) {
26
+ return e.map(({ request: e, payable: c }) => {
27
+ let l = c?.amount_to_pay, u = c?.currency;
17
28
  return {
18
29
  id: e.id,
19
- invoiceNumber: o?.document_id || a.missingValue,
20
- issueDate: t(o?.issued_at, r) || a.missingValue,
21
- dueDate: t(o?.due_date, r) || a.missingValue,
22
- statusLabel: a.status[e.status],
30
+ invoiceNumber: c?.document_id || s.missingValue,
31
+ vendor: o(c?.counterpart_id, r.vendors, s),
32
+ issueDate: t(c?.issued_at, i) || s.missingValue,
33
+ dueDate: t(c?.due_date, i) || s.missingValue,
34
+ statusLabel: s.status[e.status],
23
35
  statusTone: n[e.status],
24
- amount: typeof s == "number" && c ? i(s, c) : a.missingValue
36
+ amount: typeof l == "number" && u ? a(l, u) : s.missingValue,
37
+ addedBy: o(e.created_by, r.users, s)
25
38
  };
26
39
  });
27
40
  }
28
41
  //#endregion
29
- export { a as buildApprovalRequestRows };
42
+ export { s as buildApprovalRequestRows };
@@ -5,6 +5,7 @@ var e = {
5
5
  filterEmptyTitle: "No approval requests found",
6
6
  filterEmptyDescription: "Try adjusting your filter criteria.",
7
7
  missingValue: "—",
8
+ unavailableValue: "Unavailable",
8
9
  status: {
9
10
  waiting: "In approval",
10
11
  approved: "Approved",
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { hasAnyScope as e } from "../../../../../shared/data-access/dist/lib/hasAnyScope.js";
6
+ import { Scope as t } from "../../../../../shared/data-access/dist/lib/scopes.js";
7
+ import "../../../../../shared/data-access/dist/index.js";
8
+ import { useWidgetConfig as n, useWidgetInitStaleForToken as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
+ import "../../../../../shared/feature/dist/index.js";
10
+ import { getCounterpartName as i } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
11
+ import { useCounterpartsByIdsQuery as a } from "../../../../../shared/counterpart-management/data-access/dist/index3.js";
12
+ import "../../../../../shared/counterpart-management/feature/dist/index.js";
13
+ import { useEntityUsersByIdsQuery as o } from "../../../../data-access/dist/index7.js";
14
+ import "../../../../data-access/dist/index.js";
15
+ import { useMemo as s } from "react";
16
+ //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestNames.js
17
+ var c = {
18
+ Resolving: "resolving",
19
+ Unavailable: "unavailable",
20
+ Settled: "settled"
21
+ }, l = /* @__PURE__ */ new Map();
22
+ function u(e, t) {
23
+ let n = /* @__PURE__ */ new Map();
24
+ for (let r of e ?? []) {
25
+ let e = t(r);
26
+ e && n.set(r.id, e);
27
+ }
28
+ return n;
29
+ }
30
+ function d({ isInitResolved: e, canRead: t, isPaused: n }, { isFetching: r, isError: i }) {
31
+ return !e || n ? c.Resolving : t ? r ? c.Resolving : i ? c.Unavailable : c.Settled : c.Unavailable;
32
+ }
33
+ function f({ items: c }) {
34
+ let { initResponse: f } = n(), p = r(), m = !!f, h = e(f?.scopes, [t.CounterpartReadOrg]), g = e(f?.scopes, [t.UserReadOrg]), _ = s(() => c.map(({ payable: e }) => e?.counterpart_id).filter((e) => !!e), [c]), v = s(() => c.map(({ request: e }) => e.created_by).filter((e) => !!e), [c]), y = a({
35
+ counterpartIds: _,
36
+ enabled: h && !p
37
+ }), b = o({
38
+ ids: v,
39
+ enabled: g && !p
40
+ }), x = m && !h && !p, S = m && !g && !p, C = s(() => x ? l : u(y.data?.data, i), [y.data, x]), w = s(() => S ? l : u(b.data?.data, (e) => `${e.first_name ?? ""} ${e.last_name ?? ""}`.trim()), [b.data, S]), T = d({
41
+ isInitResolved: m,
42
+ canRead: h,
43
+ isPaused: p
44
+ }, y), E = d({
45
+ isInitResolved: m,
46
+ canRead: g,
47
+ isPaused: p
48
+ }, b);
49
+ return s(() => ({
50
+ vendors: {
51
+ names: C,
52
+ state: T
53
+ },
54
+ users: {
55
+ names: w,
56
+ state: E
57
+ }
58
+ }), [
59
+ C,
60
+ T,
61
+ w,
62
+ E
63
+ ]);
64
+ }
65
+ //#endregion
66
+ export { c as NameLookupState, f as useApprovalRequestNames };
@@ -5,12 +5,13 @@
5
5
  import { useEmbedApi as e } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
6
  import "../../../../../shared/data-access/dist/index.js";
7
7
  import { PAGE_SIZE_OPTIONS as t } from "./constants.js";
8
- import { buildApprovalRequestRows as n } from "./buildApprovalRequestRows.js";
9
- import { useApprovalRequestsQuery as r } from "../../../../data-access/dist/index3.js";
8
+ import { useApprovalRequestsQuery as n } from "../../../../data-access/dist/index3.js";
10
9
  import "../../../../data-access/dist/index.js";
11
- import { useCallback as i, useMemo as a, useState as o } from "react";
10
+ import { useApprovalRequestNames as r } from "./useApprovalRequestNames.js";
11
+ import { buildApprovalRequestRows as i } from "./buildApprovalRequestRows.js";
12
+ import { useCallback as a, useMemo as o, useState as s } from "react";
12
13
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js
13
- function s(e, t) {
14
+ function c(e, t) {
14
15
  return e ? {
15
16
  title: t.filterEmptyTitle,
16
17
  description: t.filterEmptyDescription
@@ -19,35 +20,39 @@ function s(e, t) {
19
20
  description: t.emptyDescription
20
21
  };
21
22
  }
22
- function c({ labels: c }) {
23
- let [l, u] = o(t[0]), [d, f] = o(), { organizationId: p } = e(), [m, h] = o(p);
24
- p && p !== m && (h(p), f(void 0));
25
- let g = r({
26
- limit: l,
27
- pagination_token: d
28
- }), _ = a(() => n(g.data?.data ?? [], c), [g.data, c]), v = g.isPlaceholderData ? void 0 : g.data, y = v?.next_pagination_token ?? void 0, b = v?.prev_pagination_token ?? void 0, x = i((e) => {
29
- u(e), f(void 0);
30
- }, []), S = i(() => {
31
- y && f(y);
32
- }, [y]), C = i(() => {
33
- b && f(b);
34
- }, [b]), { refetch: w } = g, T = i(() => {
35
- w();
36
- }, [w]);
23
+ function l({ labels: l }) {
24
+ let [u, d] = s(t[0]), [f, p] = s(), { organizationId: m } = e(), [h, g] = s(m);
25
+ m && m !== h && (g(m), p(void 0));
26
+ let _ = n({
27
+ limit: u,
28
+ pagination_token: f
29
+ }), v = o(() => _.data?.data ?? [], [_.data]), y = r({ items: v }), b = o(() => i(v, y, l), [
30
+ v,
31
+ y,
32
+ l
33
+ ]), x = _.isPlaceholderData ? void 0 : _.data, S = x?.next_pagination_token ?? void 0, C = x?.prev_pagination_token ?? void 0, w = a((e) => {
34
+ d(e), p(void 0);
35
+ }, []), T = a(() => {
36
+ S && p(S);
37
+ }, [S]), E = a(() => {
38
+ C && p(C);
39
+ }, [C]), { refetch: D } = _, O = a(() => {
40
+ D();
41
+ }, [D]);
37
42
  return {
38
- rows: _,
39
- isLoading: g.isLoading,
40
- isError: g.isError,
41
- pageSize: l,
43
+ rows: b,
44
+ isLoading: _.isLoading,
45
+ isError: _.isError,
46
+ pageSize: u,
42
47
  pageSizeOptions: t,
43
- onPageSizeChange: x,
44
- hasNextPage: !!y,
45
- hasPrevPage: !!b,
46
- onNextPage: S,
47
- onPrevPage: C,
48
- emptyState: s(!1, c),
49
- onRetry: T
48
+ onPageSizeChange: w,
49
+ hasNextPage: !!S,
50
+ hasPrevPage: !!C,
51
+ onNextPage: T,
52
+ onPrevPage: E,
53
+ emptyState: c(!1, l),
54
+ onRetry: O
50
55
  };
51
56
  }
52
57
  //#endregion
53
- export { s as selectEmptyState, c as useApprovalRequestsTable };
58
+ export { c as selectEmptyState, l as useApprovalRequestsTable };
@@ -1,10 +1,13 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js
2
2
  var e = {
3
3
  columnInvoiceNumber: "Invoice #",
4
+ columnVendor: "Vendor",
4
5
  columnIssueDate: "Issue date",
5
6
  columnDueDate: "Due date",
6
7
  columnStatus: "Status",
7
8
  columnAmount: "Amount",
9
+ columnAddedBy: "Added by",
10
+ loadingValue: "Loading",
8
11
  errorTitle: "Couldn't load approval requests",
9
12
  errorDescription: "Try again.",
10
13
  errorRetry: "Try again"
@@ -1,71 +1,96 @@
1
- import { Badge as e, DataTable as t } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { EmptyState as n } from "../../../shared/ui/dist/lib/EmptyState/EmptyState.js";
3
- import { ErrorState as r } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
1
+ import { Badge as e, DataTable as t, Skeleton as n } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { EmptyState as r } from "../../../shared/ui/dist/lib/EmptyState/EmptyState.js";
3
+ import { ErrorState as i } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
4
4
  import "../../../shared/ui/dist/index.js";
5
- import { APPROVAL_REQUESTS_SCREEN_LABELS_EN as i } from "./index2.js";
6
- import { jsx as a } from "react/jsx-runtime";
5
+ import { APPROVAL_REQUESTS_SCREEN_LABELS_EN as a } from "./index2.js";
6
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
7
7
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index3.js
8
- var o = [], s = () => void 0;
9
- function c({ rows: c, isLoading: l, isError: u, pageSize: d, onPageSizeChange: f, pageSizeOptions: p, hasNextPage: m, hasPrevPage: h, onNextPage: g, onPrevPage: _, emptyState: v, onRetry: y, labels: b }) {
10
- let x = {
11
- ...i,
12
- ...b
13
- }, S = [
8
+ var l = [], u = () => void 0;
9
+ function d({ name: e, loadingLabel: t }) {
10
+ return e === void 0 ? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(n, {
11
+ className: "ttw:h-4 ttw:w-32",
12
+ "aria-hidden": !0
13
+ }), /* @__PURE__ */ s("span", {
14
+ className: "ttw:sr-only",
15
+ children: t
16
+ })] }) : /* @__PURE__ */ s(o, { children: e });
17
+ }
18
+ function f({ rows: n, isLoading: o, isError: c, pageSize: f, onPageSizeChange: p, pageSizeOptions: m, hasNextPage: h, hasPrevPage: g, onNextPage: _, onPrevPage: v, emptyState: y, onRetry: b, labels: x }) {
19
+ let S = {
20
+ ...a,
21
+ ...x
22
+ }, C = [
14
23
  {
15
24
  accessorKey: "invoiceNumber",
16
- header: x.columnInvoiceNumber
25
+ header: S.columnInvoiceNumber
26
+ },
27
+ {
28
+ accessorKey: "vendor",
29
+ header: S.columnVendor,
30
+ cell: ({ row: e }) => /* @__PURE__ */ s(d, {
31
+ name: e.original.vendor,
32
+ loadingLabel: S.loadingValue
33
+ })
17
34
  },
18
35
  {
19
36
  accessorKey: "issueDate",
20
- header: x.columnIssueDate
37
+ header: S.columnIssueDate
21
38
  },
22
39
  {
23
40
  accessorKey: "dueDate",
24
- header: x.columnDueDate
41
+ header: S.columnDueDate
25
42
  },
26
43
  {
27
44
  accessorKey: "statusLabel",
28
- header: x.columnStatus,
29
- cell: ({ row: t }) => /* @__PURE__ */ a(e, {
45
+ header: S.columnStatus,
46
+ cell: ({ row: t }) => /* @__PURE__ */ s(e, {
30
47
  tone: t.original.statusTone,
31
48
  children: t.original.statusLabel
32
49
  })
33
50
  },
34
51
  {
35
52
  accessorKey: "amount",
36
- header: () => /* @__PURE__ */ a("div", {
53
+ header: () => /* @__PURE__ */ s("div", {
37
54
  className: "ttw:text-right",
38
- children: x.columnAmount
55
+ children: S.columnAmount
39
56
  }),
40
- cell: ({ row: e }) => /* @__PURE__ */ a("div", {
57
+ cell: ({ row: e }) => /* @__PURE__ */ s("div", {
41
58
  className: "ttw:text-right ttw:tabular-nums",
42
59
  children: e.original.amount
43
60
  })
61
+ },
62
+ {
63
+ accessorKey: "addedBy",
64
+ header: S.columnAddedBy,
65
+ cell: ({ row: e }) => /* @__PURE__ */ s(d, {
66
+ name: e.original.addedBy,
67
+ loadingLabel: S.loadingValue
68
+ })
44
69
  }
45
70
  ];
46
- return u ? /* @__PURE__ */ a(r, {
47
- title: x.errorTitle,
48
- description: x.errorDescription,
49
- retryLabel: y ? x.errorRetry : void 0,
50
- onRetry: y
51
- }) : /* @__PURE__ */ a(t, {
52
- columns: S,
53
- data: c,
54
- isLoading: l,
55
- sorting: o,
56
- onSortingChange: s,
57
- pageSize: d,
58
- onPageSizeChange: f,
59
- pageSizeOptions: p,
60
- hasNextPage: m,
61
- hasPrevPage: h,
62
- onNextPage: g,
63
- onPrevPage: _,
64
- children: /* @__PURE__ */ a(n, {
65
- title: v.title,
66
- description: v.description
71
+ return c ? /* @__PURE__ */ s(i, {
72
+ title: S.errorTitle,
73
+ description: S.errorDescription,
74
+ retryLabel: b ? S.errorRetry : void 0,
75
+ onRetry: b
76
+ }) : /* @__PURE__ */ s(t, {
77
+ columns: C,
78
+ data: n,
79
+ isLoading: o,
80
+ sorting: l,
81
+ onSortingChange: u,
82
+ pageSize: f,
83
+ onPageSizeChange: p,
84
+ pageSizeOptions: m,
85
+ hasNextPage: h,
86
+ hasPrevPage: g,
87
+ onNextPage: _,
88
+ onPrevPage: v,
89
+ children: /* @__PURE__ */ s(r, {
90
+ title: y.title,
91
+ description: y.description
67
92
  })
68
93
  });
69
94
  }
70
95
  //#endregion
71
- export { c as ApprovalRequestsScreen, c as default };
96
+ export { f as ApprovalRequestsScreen, f as default };
@@ -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.9.37", n = "09c1ca22c40fa06851e49ad3410bd807486ce75d", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.9.39", n = "9a6cb2d3b516b6821374e3a4483594af885ce0ce", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.9.37",
3
+ "version": "0.9.39",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [