@tesouro/embedded-components-react 0.9.39 → 0.9.41

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 (16) hide show
  1. package/dist/experimental/ApprovalRequests.d.ts +44 -1
  2. package/dist/experimental/index.d.ts +44 -1
  3. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index.js +3 -3
  4. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index6.js +22 -1
  5. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js +45 -35
  6. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/constants.js +7 -2
  7. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/labels.js +7 -0
  8. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/permissions.js +9 -0
  9. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsFilters.js +149 -0
  10. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js +40 -33
  11. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js +3 -2
  12. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js +23 -3
  13. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index3.js +136 -89
  14. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index4.js +104 -0
  15. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  16. package/package.json +1 -1
@@ -333,6 +333,21 @@ type EmbeddedClient = Client;
333
333
  type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
334
334
  type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
335
335
 
336
+ interface FilterMenuButtonLabels {
337
+ /** Button text, followed by "(N)" when `activeCount` is set. */
338
+ filters: string;
339
+ }
340
+
341
+ interface FilterTagLabels {
342
+ /**
343
+ * Accessible name for the editable tag body. `{label}` is substituted with
344
+ * the tag's own text; keep the placeholder when overriding.
345
+ */
346
+ edit: string;
347
+ /** Accessible name for the × dismiss button. `{label}` is substituted. */
348
+ remove: string;
349
+ }
350
+
336
351
  type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
337
352
  children?: ReactNode;
338
353
  };
@@ -598,6 +613,23 @@ interface WidgetProviderProps extends WidgetProviderBaseProps {
598
613
  providerLabels?: Partial<WidgetProviderLabels>;
599
614
  }
600
615
 
616
+ interface ApprovalRequestsFilterBarLabels {
617
+ fields: {
618
+ status: string;
619
+ addedBy: string;
620
+ requestedOn: string;
621
+ };
622
+ fieldMenuLabel: string;
623
+ onlyMine: string;
624
+ userSearchLabel: string;
625
+ userSearchPlaceholder: string;
626
+ userEmpty: string;
627
+ userLoading: string;
628
+ userError: string;
629
+ clearAll: string;
630
+ filterMenuButton: FilterMenuButtonLabels;
631
+ filterTag: FilterTagLabels;
632
+ }
601
633
  interface ApprovalRequestsScreenLabels {
602
634
  columnInvoiceNumber: string;
603
635
  columnVendor: string;
@@ -611,8 +643,18 @@ interface ApprovalRequestsScreenLabels {
611
643
  errorTitle: string;
612
644
  errorDescription: string;
613
645
  errorRetry: string;
646
+ filterBar: ApprovalRequestsFilterBarLabels;
647
+ accessRestrictedTitle: string;
648
+ accessRestrictedDescription: string;
614
649
  }
615
650
 
651
+ interface ApprovalRequestsFilterLabels {
652
+ statusChip: (value: string) => string;
653
+ addedByChip: (name: string) => string;
654
+ requestedOnChip: (range: string) => string;
655
+ moreSelected: (first: string, count: number) => string;
656
+ dateRange: (from: string, to: string) => string;
657
+ }
616
658
  interface ApprovalRequestsListLabels {
617
659
  emptyTitle: string;
618
660
  emptyDescription: string;
@@ -623,10 +665,11 @@ interface ApprovalRequestsListLabels {
623
665
  /** Shown for a vendor or creator this session may not read, or whose lookup failed. */
624
666
  unavailableValue: string;
625
667
  status: Record<ApprovalRequestStatus, string>;
668
+ filters: ApprovalRequestsFilterLabels;
626
669
  }
627
670
 
628
671
  interface ApprovalRequestsWidgetOwnProps {
629
- screenLabels?: Partial<ApprovalRequestsScreenLabels>;
672
+ screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
630
673
  listLabels?: PartialDeep<ApprovalRequestsListLabels>;
631
674
  }
632
675
  /** Public props for {@link ApprovalRequestsWidget}. */
@@ -333,6 +333,21 @@ type EmbeddedClient = Client;
333
333
  type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
334
334
  type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
335
335
 
336
+ interface FilterMenuButtonLabels {
337
+ /** Button text, followed by "(N)" when `activeCount` is set. */
338
+ filters: string;
339
+ }
340
+
341
+ interface FilterTagLabels {
342
+ /**
343
+ * Accessible name for the editable tag body. `{label}` is substituted with
344
+ * the tag's own text; keep the placeholder when overriding.
345
+ */
346
+ edit: string;
347
+ /** Accessible name for the × dismiss button. `{label}` is substituted. */
348
+ remove: string;
349
+ }
350
+
336
351
  type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
337
352
  children?: ReactNode;
338
353
  };
@@ -598,6 +613,23 @@ interface WidgetProviderProps extends WidgetProviderBaseProps {
598
613
  providerLabels?: Partial<WidgetProviderLabels>;
599
614
  }
600
615
 
616
+ interface ApprovalRequestsFilterBarLabels {
617
+ fields: {
618
+ status: string;
619
+ addedBy: string;
620
+ requestedOn: string;
621
+ };
622
+ fieldMenuLabel: string;
623
+ onlyMine: string;
624
+ userSearchLabel: string;
625
+ userSearchPlaceholder: string;
626
+ userEmpty: string;
627
+ userLoading: string;
628
+ userError: string;
629
+ clearAll: string;
630
+ filterMenuButton: FilterMenuButtonLabels;
631
+ filterTag: FilterTagLabels;
632
+ }
601
633
  interface ApprovalRequestsScreenLabels {
602
634
  columnInvoiceNumber: string;
603
635
  columnVendor: string;
@@ -611,8 +643,18 @@ interface ApprovalRequestsScreenLabels {
611
643
  errorTitle: string;
612
644
  errorDescription: string;
613
645
  errorRetry: string;
646
+ filterBar: ApprovalRequestsFilterBarLabels;
647
+ accessRestrictedTitle: string;
648
+ accessRestrictedDescription: string;
614
649
  }
615
650
 
651
+ interface ApprovalRequestsFilterLabels {
652
+ statusChip: (value: string) => string;
653
+ addedByChip: (name: string) => string;
654
+ requestedOnChip: (range: string) => string;
655
+ moreSelected: (first: string, count: number) => string;
656
+ dateRange: (from: string, to: string) => string;
657
+ }
616
658
  interface ApprovalRequestsListLabels {
617
659
  emptyTitle: string;
618
660
  emptyDescription: string;
@@ -623,10 +665,11 @@ interface ApprovalRequestsListLabels {
623
665
  /** Shown for a vendor or creator this session may not read, or whose lookup failed. */
624
666
  unavailableValue: string;
625
667
  status: Record<ApprovalRequestStatus, string>;
668
+ filters: ApprovalRequestsFilterLabels;
626
669
  }
627
670
 
628
671
  interface ApprovalRequestsWidgetOwnProps {
629
- screenLabels?: Partial<ApprovalRequestsScreenLabels>;
672
+ screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
630
673
  listLabels?: PartialDeep<ApprovalRequestsListLabels>;
631
674
  }
632
675
  /** Public props for {@link ApprovalRequestsWidget}. */
@@ -4,6 +4,6 @@ import "./index2.js";
4
4
  import { useApprovalRequestsQuery as e } from "./index3.js";
5
5
  import "./index4.js";
6
6
  import "./index5.js";
7
- import "./index6.js";
8
- import { useEntityUsersByIdsQuery as t } from "./index7.js";
9
- export { e as useApprovalRequestsQuery, t as useEntityUsersByIdsQuery };
7
+ import { useEntityUsersSearchQuery as t } from "./index6.js";
8
+ import { useEntityUsersByIdsQuery as n } from "./index7.js";
9
+ export { e as useApprovalRequestsQuery, n as useEntityUsersByIdsQuery, t as useEntityUsersSearchQuery };
@@ -2,5 +2,26 @@
2
2
  "use client";
3
3
  "use client";
4
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";
5
9
  import "../../../shared/data-access/dist/index.js";
6
- import "@tanstack/react-query";
10
+ import { useQuery as i } from "@tanstack/react-query";
11
+ //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index6.js
12
+ function a({ search: a, enabled: o } = {}) {
13
+ let { client: s, organizationId: c, widgetToken: l, authEpoch: u, organizationStatus: d } = n(), f = e({
14
+ client: s,
15
+ headers: r(c),
16
+ query: { name__istartswith: a || void 0 }
17
+ });
18
+ return i({
19
+ ...t(f, {
20
+ authEpoch: u,
21
+ organizationStatus: d
22
+ }, { carryWithinOrg: !0 }),
23
+ enabled: !!(c && l) && (o === !0 || o === void 0)
24
+ });
25
+ }
26
+ //#endregion
27
+ export { a as useEntityUsersSearchQuery };
@@ -7,54 +7,64 @@ import { useEmbedApi as t } from "../../../../../shared/data-access/dist/lib/Emb
7
7
  import "../../../../../shared/data-access/dist/index.js";
8
8
  import { useAnalyticsTrack as n } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
9
9
  import { WidgetProvider as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
10
- import { useRefetchWidget as i, useWidgetConfig as a, useWidgetError as o, useWidgetInitStaleForToken as s } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useRefetchWidget as i, useWidgetConfig as a, useWidgetError as o, useWidgetInitStaleForToken as s, useWidgetLoading as c } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
11
  import "../../../../../shared/feature/dist/index.js";
12
- import { ApprovalRequestsWidgetAnalyticsEvent as c, WIDGET_NAME as l } from "../analytics/events.js";
13
- import { APPROVAL_REQUESTS_LIST_LABELS_EN as u } from "./labels.js";
14
- import { useApprovalRequestsTable as d } from "./useApprovalRequestsTable.js";
15
- import { ApprovalRequestsScreen as f } from "../../../../ui/dist/index3.js";
12
+ import { ApprovalRequestsWidgetAnalyticsEvent as l, WIDGET_NAME as u } from "../analytics/events.js";
13
+ import { APPROVAL_REQUESTS_LIST_LABELS_EN as d } from "./labels.js";
14
+ import { getApprovalRequestPermissions as f } from "./permissions.js";
15
+ import { ApprovalRequestsScreen as p } from "../../../../ui/dist/index4.js";
16
16
  import "../../../../ui/dist/index.js";
17
- import { useEffect as p, useMemo as m } from "react";
18
- import { jsx as h } from "react/jsx-runtime";
17
+ import { useApprovalRequestsTable as m } from "./useApprovalRequestsTable.js";
18
+ import { useEffect as h, useMemo as g } from "react";
19
+ import { jsx as _ } from "react/jsx-runtime";
19
20
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js
20
- function g({ screenLabels: r, listLabels: l }) {
21
- let g = n();
22
- p(() => {
23
- g(c.Mounted);
24
- }, [g]);
25
- let _ = m(() => ({
21
+ function v({ screenLabels: r, listLabels: u }) {
22
+ let v = n();
23
+ h(() => {
24
+ v(l.Mounted);
25
+ }, [v]);
26
+ let y = g(() => ({
27
+ ...d,
26
28
  ...u,
27
- ...l,
28
29
  status: {
29
- ...u.status,
30
- ...l?.status
30
+ ...d.status,
31
+ ...u?.status
32
+ },
33
+ filters: {
34
+ ...d.filters,
35
+ ...u?.filters
31
36
  }
32
- }), [l]), v = d({ labels: _ }), { initResponse: y } = a(), b = o(), x = s(), S = i(), { organizationStatus: C } = t(), w = !!b && (!y || x);
33
- return /* @__PURE__ */ h(f, {
34
- rows: v.rows,
35
- isLoading: v.isLoading || e(C) && v.rows.length === 0,
36
- isError: w || v.isError,
37
- pageSize: v.pageSize,
38
- onPageSizeChange: v.onPageSizeChange,
39
- pageSizeOptions: v.pageSizeOptions,
40
- hasNextPage: v.hasNextPage,
41
- hasPrevPage: v.hasPrevPage,
42
- onNextPage: v.onNextPage,
43
- onPrevPage: v.onPrevPage,
44
- emptyState: v.emptyState,
45
- onRetry: w ? S : v.onRetry,
37
+ }), [u]), { initResponse: b, widgetToken: x } = a(), S = c(), C = o(), w = s(), T = i(), { organizationStatus: E } = t(), D = g(() => f(w ? void 0 : b?.scopes), [w, b?.scopes]), O = !(!x || b || C) || S && !b || w, k = !!C && (!b || w), A = m({
38
+ labels: y,
39
+ enabled: D.canRead
40
+ });
41
+ return /* @__PURE__ */ _(p, {
42
+ rows: A.rows,
43
+ isLoading: A.isLoading || (O || e(E)) && A.rows.length === 0,
44
+ isError: k || A.isError,
45
+ isAccessRestricted: !O && !k && !D.canRead,
46
+ pageSize: A.pageSize,
47
+ onPageSizeChange: A.onPageSizeChange,
48
+ pageSizeOptions: A.pageSizeOptions,
49
+ hasNextPage: A.hasNextPage,
50
+ hasPrevPage: A.hasPrevPage,
51
+ onNextPage: A.onNextPage,
52
+ onPrevPage: A.onPrevPage,
53
+ emptyState: A.emptyState,
54
+ filters: A.filters,
55
+ onRetry: k ? T : A.onRetry,
46
56
  labels: r
47
57
  });
48
58
  }
49
- function _({ screenLabels: e, listLabels: t, ...n }) {
50
- return /* @__PURE__ */ h(r, {
59
+ function y({ screenLabels: e, listLabels: t, ...n }) {
60
+ return /* @__PURE__ */ _(r, {
51
61
  ...n,
52
- widgetName: l,
53
- children: /* @__PURE__ */ h(g, {
62
+ widgetName: u,
63
+ children: /* @__PURE__ */ _(v, {
54
64
  screenLabels: e,
55
65
  listLabels: t
56
66
  })
57
67
  });
58
68
  }
59
69
  //#endregion
60
- export { _ as ApprovalRequestsWidget, _ as default };
70
+ export { y as ApprovalRequestsWidget, y as default };
@@ -9,6 +9,11 @@ var e = [
9
9
  approved: "success",
10
10
  rejected: "destructive",
11
11
  canceled: "neutral"
12
- };
12
+ }, n = [
13
+ "waiting",
14
+ "approved",
15
+ "rejected",
16
+ "canceled"
17
+ ];
13
18
  //#endregion
14
- export { e as PAGE_SIZE_OPTIONS, t as STATUS_TONE };
19
+ export { n as APPROVAL_REQUEST_STATUSES, e as PAGE_SIZE_OPTIONS, t as STATUS_TONE };
@@ -11,6 +11,13 @@ var e = {
11
11
  approved: "Approved",
12
12
  rejected: "Rejected",
13
13
  canceled: "Canceled"
14
+ },
15
+ filters: {
16
+ statusChip: (e) => `Status: ${e}`,
17
+ addedByChip: (e) => `Added by: ${e}`,
18
+ requestedOnChip: (e) => `Requested on: ${e}`,
19
+ moreSelected: (e, t) => `${e} + ${t} more`,
20
+ dateRange: (e, t) => `${e} - ${t}`
14
21
  }
15
22
  };
16
23
  //#endregion
@@ -0,0 +1,9 @@
1
+ import { Scope as e } from "../../../../../shared/data-access/dist/lib/scopes.js";
2
+ import "../../../../../shared/data-access/dist/index.js";
3
+ //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/permissions.js
4
+ function t(t) {
5
+ let n = new Set(t ?? []);
6
+ return { canRead: n.has(e.ApprovalRequestReadOrg) && n.has(e.PayableReadOrg) };
7
+ }
8
+ //#endregion
9
+ export { t as getApprovalRequestPermissions };
@@ -0,0 +1,149 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useFilterPanel as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { useEmbedApi as t } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
7
+ import "../../../../../shared/data-access/dist/index.js";
8
+ import { useWidgetConfig as n } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
+ import "../../../../../shared/feature/dist/index.js";
10
+ import { APPROVAL_REQUEST_STATUSES as r } from "./constants.js";
11
+ import { useEntityUsersSearchQuery as i } from "../../../../data-access/dist/index6.js";
12
+ import "../../../../data-access/dist/index.js";
13
+ import { ApprovalRequestsFilterField as a } from "../../../../ui/dist/index3.js";
14
+ import "../../../../ui/dist/index.js";
15
+ import { useCallback as o, useEffect as s, useMemo as c, useState as l } from "react";
16
+ import { addDays as u, format as d, formatISO as f, startOfDay as p } from "date-fns";
17
+ //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsFilters.js
18
+ var m = {
19
+ Status: "status",
20
+ AddedBy: "addedBy",
21
+ RequestedOn: "requestedOn"
22
+ }, h = 300, g = "MMM d, yyyy", _ = {
23
+ statuses: [],
24
+ isOnlyMine: !1
25
+ };
26
+ function v(e) {
27
+ return `${e.first_name ?? ""} ${e.last_name ?? ""}`.trim() || e.login;
28
+ }
29
+ function y({ labels: y, onFiltersChange: b }) {
30
+ let [x, S] = l(_), [C, w] = l(""), [T, E] = l(""), D = e();
31
+ s(() => {
32
+ let e = setTimeout(() => E(C.trim()), h);
33
+ return () => clearTimeout(e);
34
+ }, [C]);
35
+ let O = n().initResponse?.userId ?? void 0, [k, A] = l(O);
36
+ O && O !== k && A(O);
37
+ let { organizationId: j } = t(), [M, N] = l(j);
38
+ j && j !== M && (N(j), M && S((e) => ({
39
+ ...e,
40
+ addedBy: void 0
41
+ })));
42
+ let P = i({
43
+ search: T,
44
+ enabled: D.activePanelId === a.AddedBy
45
+ }), F = o((e) => {
46
+ S((t) => ({
47
+ ...t,
48
+ ...e
49
+ })), b();
50
+ }, [b]), I = c(() => (P.data?.data ?? []).map((e) => ({
51
+ value: e.id,
52
+ label: v(e)
53
+ })), [P.data?.data]), L = c(() => r.map((e) => ({
54
+ value: e,
55
+ label: y.status[e]
56
+ })), [y.status]), R = c(() => {
57
+ let e = {};
58
+ x.statuses.length > 0 && (e.status__in = [...x.statuses]);
59
+ let t = x.isOnlyMine ? k : x.addedBy?.value;
60
+ if (t && (e.created_by = t), x.requestedFrom) {
61
+ let t = p(x.requestedFrom), n = p(x.requestedTo ?? x.requestedFrom);
62
+ e.created_at__gte = f(t), e.created_at__lt = f(u(n, 1));
63
+ }
64
+ return e;
65
+ }, [x, k]), z = c(() => {
66
+ let e = [], { filters: t } = y;
67
+ if (x.statuses.length > 0) {
68
+ let [n, ...r] = x.statuses.map((e) => y.status[e]);
69
+ e.push({
70
+ key: m.Status,
71
+ label: t.statusChip(r.length === 0 ? n : t.moreSelected(n, r.length))
72
+ });
73
+ }
74
+ if (x.addedBy && e.push({
75
+ key: m.AddedBy,
76
+ label: t.addedByChip(x.addedBy.label)
77
+ }), x.requestedFrom) {
78
+ let n = d(x.requestedFrom, g), r = x.requestedTo ? d(x.requestedTo, g) : n;
79
+ e.push({
80
+ key: m.RequestedOn,
81
+ label: t.requestedOnChip(n === r ? n : t.dateRange(n, r))
82
+ });
83
+ }
84
+ return e;
85
+ }, [y, x]), B = o((e) => {
86
+ switch (e) {
87
+ case m.Status:
88
+ F({ statuses: [] });
89
+ break;
90
+ case m.AddedBy:
91
+ F({ addedBy: void 0 });
92
+ break;
93
+ case m.RequestedOn: F({
94
+ requestedFrom: void 0,
95
+ requestedTo: void 0
96
+ });
97
+ }
98
+ }, [F]), V = o(() => {
99
+ S(_), b();
100
+ }, [b]), H = o((e) => {
101
+ let t = I.find((t) => t.value === e);
102
+ t && F({
103
+ addedBy: t,
104
+ isOnlyMine: !1
105
+ });
106
+ }, [F, I]), U = o((e) => F(e ? {
107
+ isOnlyMine: !0,
108
+ addedBy: void 0
109
+ } : { isOnlyMine: !1 }), [F]), W = o(() => {
110
+ D.closeMenu(), D.closePanel();
111
+ }, [D]);
112
+ return {
113
+ filters: {
114
+ isPopoverOpen: D.isMenuOpen || !!D.activePanelId,
115
+ isMenuOpen: D.isMenuOpen,
116
+ activePanel: D.activePanelId,
117
+ onMenuToggle: D.toggleMenu,
118
+ onPopoverClose: W,
119
+ onFieldSelect: D.openPanel,
120
+ activeFilterCount: z.length,
121
+ chips: z,
122
+ onRemoveChip: B,
123
+ onClearAll: V,
124
+ statusOptions: L,
125
+ selectedStatuses: x.statuses,
126
+ onStatusChange: (e) => F({ statuses: e }),
127
+ userOptions: I,
128
+ selectedUser: x.addedBy?.value ?? "",
129
+ onUserChange: H,
130
+ userSearchValue: C,
131
+ onUserSearchChange: w,
132
+ isUserLoading: P.isLoading,
133
+ isUserError: P.isError,
134
+ requestedFrom: x.requestedFrom,
135
+ requestedTo: x.requestedTo,
136
+ onRequestedRangeChange: ({ from: e, to: t }) => F({
137
+ requestedFrom: e,
138
+ requestedTo: t
139
+ }),
140
+ isOnlyMine: x.isOnlyMine,
141
+ onOnlyMineChange: U,
142
+ isOnlyMineDisabled: !k
143
+ },
144
+ query: R,
145
+ isFiltering: z.length > 0 || x.isOnlyMine
146
+ };
147
+ }
148
+ //#endregion
149
+ export { m as ApprovalRequestsFilterChipKey, y as useApprovalRequestsFilters };
@@ -9,9 +9,10 @@ import { useApprovalRequestsQuery as n } from "../../../../data-access/dist/inde
9
9
  import "../../../../data-access/dist/index.js";
10
10
  import { useApprovalRequestNames as r } from "./useApprovalRequestNames.js";
11
11
  import { buildApprovalRequestRows as i } from "./buildApprovalRequestRows.js";
12
- import { useCallback as a, useMemo as o, useState as s } from "react";
12
+ import { useApprovalRequestsFilters as a } from "./useApprovalRequestsFilters.js";
13
+ import { useCallback as o, useMemo as s, useState as c } from "react";
13
14
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js
14
- function c(e, t) {
15
+ function l(e, t) {
15
16
  return e ? {
16
17
  title: t.filterEmptyTitle,
17
18
  description: t.filterEmptyDescription
@@ -20,39 +21,45 @@ function c(e, t) {
20
21
  description: t.emptyDescription
21
22
  };
22
23
  }
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]);
24
+ function u({ labels: u, enabled: d = !0 }) {
25
+ let [f, p] = c(t[0]), [m, h] = c(), { organizationId: g } = e(), [_, v] = c(g);
26
+ g && g !== _ && (v(g), h(void 0));
27
+ let y = o(() => h(void 0), []), { filters: b, query: x, isFiltering: S } = a({
28
+ labels: u,
29
+ onFiltersChange: y
30
+ }), C = n({
31
+ ...x,
32
+ limit: f,
33
+ pagination_token: m,
34
+ enabled: d
35
+ }), w = s(() => C.data?.data ?? [], [C.data]), T = r({ items: w }), E = s(() => i(w, T, u), [
36
+ w,
37
+ T,
38
+ u
39
+ ]), D = C.isPlaceholderData ? void 0 : C.data, O = D?.next_pagination_token ?? void 0, k = D?.prev_pagination_token ?? void 0, A = o((e) => {
40
+ p(e), h(void 0);
41
+ }, []), j = o(() => {
42
+ O && h(O);
43
+ }, [O]), M = o(() => {
44
+ k && h(k);
45
+ }, [k]), { refetch: N } = C, P = o(() => {
46
+ N();
47
+ }, [N]);
42
48
  return {
43
- rows: b,
44
- isLoading: _.isLoading,
45
- isError: _.isError,
46
- pageSize: u,
49
+ rows: E,
50
+ isLoading: C.isLoading,
51
+ isError: C.isError,
52
+ pageSize: f,
47
53
  pageSizeOptions: t,
48
- onPageSizeChange: w,
49
- hasNextPage: !!S,
50
- hasPrevPage: !!C,
51
- onNextPage: T,
52
- onPrevPage: E,
53
- emptyState: c(!1, l),
54
- onRetry: O
54
+ onPageSizeChange: A,
55
+ hasNextPage: !!O,
56
+ hasPrevPage: !!k,
57
+ onNextPage: j,
58
+ onPrevPage: M,
59
+ filters: b,
60
+ emptyState: l(S, u),
61
+ onRetry: P
55
62
  };
56
63
  }
57
64
  //#endregion
58
- export { c as selectEmptyState, l as useApprovalRequestsTable };
65
+ export { l as selectEmptyState, u as useApprovalRequestsTable };
@@ -1,3 +1,4 @@
1
1
  import "./index2.js";
2
- import { ApprovalRequestsScreen as e } from "./index3.js";
3
- export { e as ApprovalRequestsScreen };
2
+ import { ApprovalRequestsFilterField as e } from "./index3.js";
3
+ import { ApprovalRequestsScreen as t } from "./index4.js";
4
+ export { e as ApprovalRequestsFilterField, t as ApprovalRequestsScreen };
@@ -1,5 +1,22 @@
1
+ import { FILTER_MENU_BUTTON_LABELS_EN as e, FILTER_TAG_LABELS_EN as t } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
1
2
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js
2
- var e = {
3
+ var n = {
4
+ fields: {
5
+ status: "Status",
6
+ addedBy: "Added by",
7
+ requestedOn: "Requested on"
8
+ },
9
+ fieldMenuLabel: "Filter approval requests by",
10
+ onlyMine: "Only my approvals",
11
+ userSearchLabel: "Search users",
12
+ userSearchPlaceholder: "Search users",
13
+ userEmpty: "No users found",
14
+ userLoading: "Loading users",
15
+ userError: "Couldn't load users",
16
+ clearAll: "Clear all",
17
+ filterMenuButton: e,
18
+ filterTag: t
19
+ }, r = {
3
20
  columnInvoiceNumber: "Invoice #",
4
21
  columnVendor: "Vendor",
5
22
  columnIssueDate: "Issue date",
@@ -10,7 +27,10 @@ var e = {
10
27
  loadingValue: "Loading",
11
28
  errorTitle: "Couldn't load approval requests",
12
29
  errorDescription: "Try again.",
13
- errorRetry: "Try again"
30
+ errorRetry: "Try again",
31
+ filterBar: n,
32
+ accessRestrictedTitle: "Access restricted",
33
+ accessRestrictedDescription: "You don't have permission to view approval requests."
14
34
  };
15
35
  //#endregion
16
- export { e as APPROVAL_REQUESTS_SCREEN_LABELS_EN };
36
+ export { n as APPROVAL_REQUESTS_FILTER_BAR_LABELS_EN, r as APPROVAL_REQUESTS_SCREEN_LABELS_EN };
@@ -1,96 +1,143 @@
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
- import "../../../shared/ui/dist/index.js";
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";
1
+ import { DateRangePicker as e, FilterMenuButton as t, FilterTag as n, Input as r, Label as i, MultiSelectFilter as a, Popover as o, PopoverContent as s, PopoverTrigger as c, RadioGroup as l, RadioGroupItem as u, Switch as d, TableToolbar as f, cn as p } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { APPROVAL_REQUESTS_FILTER_BAR_LABELS_EN as m } from "./index2.js";
3
+ import { useId as h } from "react";
4
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
5
+ import { ListFilter as y } from "lucide-react";
7
6
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index3.js
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 = [
23
- {
24
- accessorKey: "invoiceNumber",
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
- })
34
- },
35
- {
36
- accessorKey: "issueDate",
37
- header: S.columnIssueDate
38
- },
39
- {
40
- accessorKey: "dueDate",
41
- header: S.columnDueDate
42
- },
43
- {
44
- accessorKey: "statusLabel",
45
- header: S.columnStatus,
46
- cell: ({ row: t }) => /* @__PURE__ */ s(e, {
47
- tone: t.original.statusTone,
48
- children: t.original.statusLabel
49
- })
7
+ var b = {
8
+ Status: "status",
9
+ AddedBy: "addedBy",
10
+ RequestedOn: "requestedOn"
11
+ }, x = [
12
+ b.Status,
13
+ b.AddedBy,
14
+ b.RequestedOn
15
+ ], S = {
16
+ status: "ttw:w-56",
17
+ addedBy: "ttw:w-64",
18
+ requestedOn: "ttw:w-auto"
19
+ }, C = "ttw:flex ttw:w-full ttw:cursor-pointer ttw:items-center ttw:gap-2 ttw:rounded-md ttw:px-2 ttw:py-1.5 ttw:text-xs ttw:font-medium ttw:transition-colors ttw:hover:bg-accent";
20
+ function w({ filters: w, labels: T }) {
21
+ let E = m, D = {
22
+ ...E,
23
+ ...T,
24
+ fields: {
25
+ ...E.fields,
26
+ ...T?.fields
50
27
  },
51
- {
52
- accessorKey: "amount",
53
- header: () => /* @__PURE__ */ s("div", {
54
- className: "ttw:text-right",
55
- children: S.columnAmount
56
- }),
57
- cell: ({ row: e }) => /* @__PURE__ */ s("div", {
58
- className: "ttw:text-right ttw:tabular-nums",
59
- children: e.original.amount
60
- })
28
+ filterMenuButton: {
29
+ ...E.filterMenuButton,
30
+ ...T?.filterMenuButton
61
31
  },
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
- })
32
+ filterTag: {
33
+ ...E.filterTag,
34
+ ...T?.filterTag
69
35
  }
70
- ];
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
92
- })
36
+ }, O = h(), { activePanel: k } = w, A = k && S[k] || "ttw:w-52";
37
+ return /* @__PURE__ */ _(f, {
38
+ className: "ttw:px-4",
39
+ filters: /* @__PURE__ */ v("div", {
40
+ className: "ttw:flex ttw:h-8 ttw:items-center ttw:gap-2",
41
+ children: [/* @__PURE__ */ _(d, {
42
+ id: O,
43
+ checked: w.isOnlyMine,
44
+ onCheckedChange: w.onOnlyMineChange,
45
+ disabled: w.isOnlyMineDisabled
46
+ }), /* @__PURE__ */ _(i, {
47
+ htmlFor: O,
48
+ className: "ttw:text-sm",
49
+ children: D.onlyMine
50
+ })]
51
+ }),
52
+ filterButton: /* @__PURE__ */ v(o, {
53
+ open: w.isPopoverOpen,
54
+ onOpenChange: (e) => {
55
+ e || w.onPopoverClose();
56
+ },
57
+ children: [/* @__PURE__ */ _(c, {
58
+ asChild: !0,
59
+ children: /* @__PURE__ */ _(t, {
60
+ activeCount: w.activeFilterCount,
61
+ onClick: (e) => {
62
+ k && e.preventDefault(), w.onMenuToggle();
63
+ },
64
+ labels: D.filterMenuButton
65
+ })
66
+ }), /* @__PURE__ */ v(s, {
67
+ align: "start",
68
+ className: p("ttw:p-0", A),
69
+ children: [
70
+ w.isMenuOpen && /* @__PURE__ */ _("div", {
71
+ className: "ttw:p-1",
72
+ role: "menu",
73
+ "aria-label": D.fieldMenuLabel,
74
+ children: x.map((e) => /* @__PURE__ */ v("button", {
75
+ type: "button",
76
+ role: "menuitem",
77
+ className: C,
78
+ onClick: () => w.onFieldSelect(e),
79
+ children: [/* @__PURE__ */ _(y, {
80
+ className: "ttw:size-4 ttw:shrink-0 ttw:text-muted-foreground",
81
+ "aria-hidden": !0
82
+ }), D.fields[e]]
83
+ }, e))
84
+ }),
85
+ k === b.Status && /* @__PURE__ */ _(a, {
86
+ options: [...w.statusOptions],
87
+ selectedValues: [...w.selectedStatuses],
88
+ onSelectionChange: w.onStatusChange
89
+ }),
90
+ k === b.AddedBy && /* @__PURE__ */ v("div", {
91
+ className: "ttw:flex ttw:flex-col ttw:gap-2 ttw:p-3",
92
+ children: [/* @__PURE__ */ _(r, {
93
+ type: "search",
94
+ className: "ttw:h-8 ttw:text-xs",
95
+ "aria-label": D.userSearchLabel,
96
+ placeholder: D.userSearchPlaceholder,
97
+ value: w.userSearchValue,
98
+ onChange: (e) => w.onUserSearchChange(e.target.value)
99
+ }), w.isUserLoading ? /* @__PURE__ */ _("p", {
100
+ className: "ttw:px-1 ttw:text-xs ttw:text-muted-foreground",
101
+ children: D.userLoading
102
+ }) : w.isUserError ? /* @__PURE__ */ _("p", {
103
+ className: "ttw:px-1 ttw:text-xs ttw:text-destructive",
104
+ children: D.userError
105
+ }) : w.userOptions.length === 0 ? /* @__PURE__ */ _("p", {
106
+ className: "ttw:px-1 ttw:text-xs ttw:text-muted-foreground",
107
+ children: D.userEmpty
108
+ }) : /* @__PURE__ */ _(l, {
109
+ value: w.selectedUser,
110
+ onValueChange: w.onUserChange,
111
+ "aria-label": D.fields.addedBy,
112
+ className: "ttw:flex ttw:max-h-64 ttw:flex-col ttw:gap-1 ttw:overflow-y-auto",
113
+ children: w.userOptions.map((e) => /* @__PURE__ */ v("label", {
114
+ className: "ttw:flex ttw:cursor-pointer ttw:items-center ttw:gap-2 ttw:rounded-md ttw:px-2 ttw:py-1.5 ttw:hover:bg-accent",
115
+ children: [/* @__PURE__ */ _(u, { value: e.value }), /* @__PURE__ */ _("span", {
116
+ className: "ttw:text-xs ttw:font-medium",
117
+ children: e.label
118
+ })]
119
+ }, e.value))
120
+ })]
121
+ }),
122
+ k === b.RequestedOn && /* @__PURE__ */ _(e, {
123
+ from: w.requestedFrom,
124
+ to: w.requestedTo,
125
+ onRangeChange: w.onRequestedRangeChange
126
+ })
127
+ ]
128
+ })]
129
+ }),
130
+ tags: /* @__PURE__ */ v(g, { children: [w.chips.map((e) => /* @__PURE__ */ _(n, {
131
+ label: e.label,
132
+ labels: D.filterTag,
133
+ onDismiss: () => w.onRemoveChip(e.key)
134
+ }, e.key)), w.chips.length > 0 && /* @__PURE__ */ _("button", {
135
+ type: "button",
136
+ className: "ttw:cursor-pointer ttw:whitespace-nowrap ttw:text-xs ttw:text-muted-foreground ttw:transition-colors ttw:hover:text-foreground",
137
+ onClick: w.onClearAll,
138
+ children: D.clearAll
139
+ })] })
93
140
  });
94
141
  }
95
142
  //#endregion
96
- export { f as ApprovalRequestsScreen, f as default };
143
+ export { w as ApprovalRequestsFilterBar, w as default, b as ApprovalRequestsFilterField };
@@ -0,0 +1,104 @@
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
+ import "../../../shared/ui/dist/index.js";
5
+ import { APPROVAL_REQUESTS_SCREEN_LABELS_EN as a } from "./index2.js";
6
+ import { ApprovalRequestsFilterBar as o } from "./index3.js";
7
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index4.js
9
+ var u = [], d = () => void 0;
10
+ function f({ name: e, loadingLabel: t }) {
11
+ return e === void 0 ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(n, {
12
+ className: "ttw:h-4 ttw:w-32",
13
+ "aria-hidden": !0
14
+ }), /* @__PURE__ */ c("span", {
15
+ className: "ttw:sr-only",
16
+ children: t
17
+ })] }) : /* @__PURE__ */ c(s, { children: e });
18
+ }
19
+ function p({ rows: n, isLoading: s, isError: l, isAccessRestricted: p, pageSize: m, onPageSizeChange: h, pageSizeOptions: g, hasNextPage: _, hasPrevPage: v, onNextPage: y, onPrevPage: b, emptyState: x, filters: S, onRetry: C, labels: w }) {
20
+ let T = a, { filterBar: E, ...D } = w ?? {}, O = {
21
+ ...T,
22
+ ...D
23
+ }, k = [
24
+ {
25
+ accessorKey: "invoiceNumber",
26
+ header: O.columnInvoiceNumber
27
+ },
28
+ {
29
+ accessorKey: "vendor",
30
+ header: O.columnVendor,
31
+ cell: ({ row: e }) => /* @__PURE__ */ c(f, {
32
+ name: e.original.vendor,
33
+ loadingLabel: O.loadingValue
34
+ })
35
+ },
36
+ {
37
+ accessorKey: "issueDate",
38
+ header: O.columnIssueDate
39
+ },
40
+ {
41
+ accessorKey: "dueDate",
42
+ header: O.columnDueDate
43
+ },
44
+ {
45
+ accessorKey: "statusLabel",
46
+ header: O.columnStatus,
47
+ cell: ({ row: t }) => /* @__PURE__ */ c(e, {
48
+ tone: t.original.statusTone,
49
+ children: t.original.statusLabel
50
+ })
51
+ },
52
+ {
53
+ accessorKey: "amount",
54
+ header: () => /* @__PURE__ */ c("div", {
55
+ className: "ttw:text-right",
56
+ children: O.columnAmount
57
+ }),
58
+ cell: ({ row: e }) => /* @__PURE__ */ c("div", {
59
+ className: "ttw:text-right ttw:tabular-nums",
60
+ children: e.original.amount
61
+ })
62
+ },
63
+ {
64
+ accessorKey: "addedBy",
65
+ header: O.columnAddedBy,
66
+ cell: ({ row: e }) => /* @__PURE__ */ c(f, {
67
+ name: e.original.addedBy,
68
+ loadingLabel: O.loadingValue
69
+ })
70
+ }
71
+ ];
72
+ return p ? /* @__PURE__ */ c(i, {
73
+ title: O.accessRestrictedTitle,
74
+ description: O.accessRestrictedDescription
75
+ }) : l ? /* @__PURE__ */ c(i, {
76
+ title: O.errorTitle,
77
+ description: O.errorDescription,
78
+ retryLabel: C ? O.errorRetry : void 0,
79
+ onRetry: C
80
+ }) : /* @__PURE__ */ c(t, {
81
+ columns: k,
82
+ data: n,
83
+ isLoading: s,
84
+ sorting: u,
85
+ onSortingChange: d,
86
+ pageSize: m,
87
+ onPageSizeChange: h,
88
+ pageSizeOptions: g,
89
+ hasNextPage: _,
90
+ hasPrevPage: v,
91
+ onNextPage: y,
92
+ onPrevPage: b,
93
+ filterComponent: /* @__PURE__ */ c(o, {
94
+ filters: S,
95
+ labels: E
96
+ }),
97
+ children: /* @__PURE__ */ c(r, {
98
+ title: x.title,
99
+ description: x.description
100
+ })
101
+ });
102
+ }
103
+ //#endregion
104
+ export { p as ApprovalRequestsScreen, p 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.39", n = "9a6cb2d3b516b6821374e3a4483594af885ce0ce", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.9.41", n = "64c2e0da0918115a4ccbe3e956c8e197a3a4fc85", 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.39",
3
+ "version": "0.9.41",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [