@tesouro/embedded-components-react 0.9.40 → 0.9.43
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.
- package/dist/experimental/ApprovalRequests.d.ts +57 -2
- package/dist/experimental/index.d.ts +57 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index2.js +9 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index4.js +29 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index5.js +30 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index6.js +22 -1
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js +49 -34
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js +17 -14
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/canDecideApprovalRequest.js +8 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/constants.js +7 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/labels.js +7 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js +76 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsFilters.js +149 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js +53 -38
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js +4 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js +32 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index3.js +136 -92
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index4.js +137 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index5.js +44 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +3432 -3332
- package/package.json +1 -1
|
@@ -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 { useEntityUsersSearchQuery as r } from "../../../../data-access/dist/index6.js";
|
|
11
|
+
import "../../../../data-access/dist/index.js";
|
|
12
|
+
import { APPROVAL_REQUEST_STATUSES as i } from "./constants.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 = r({
|
|
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(() => i.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 };
|
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
"use client";
|
|
5
5
|
import { useEmbedApi as e } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
6
6
|
import "../../../../../shared/data-access/dist/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useWidgetConfig as t } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
8
|
+
import "../../../../../shared/feature/dist/index.js";
|
|
8
9
|
import { useApprovalRequestsQuery as n } from "../../../../data-access/dist/index3.js";
|
|
9
10
|
import "../../../../data-access/dist/index.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { PAGE_SIZE_OPTIONS as r } from "./constants.js";
|
|
12
|
+
import { useApprovalRequestNames as i } from "./useApprovalRequestNames.js";
|
|
13
|
+
import { buildApprovalRequestRows as a } from "./buildApprovalRequestRows.js";
|
|
14
|
+
import { useApprovalRequestsFilters as o } from "./useApprovalRequestsFilters.js";
|
|
15
|
+
import { useCallback as s, useMemo as c, useState as l } from "react";
|
|
13
16
|
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js
|
|
14
|
-
function
|
|
17
|
+
function u(e, t) {
|
|
15
18
|
return e ? {
|
|
16
19
|
title: t.filterEmptyTitle,
|
|
17
20
|
description: t.filterEmptyDescription
|
|
@@ -20,40 +23,52 @@ function c(e, t) {
|
|
|
20
23
|
description: t.emptyDescription
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
|
-
function
|
|
24
|
-
let [
|
|
25
|
-
|
|
26
|
-
let v =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
function d({ labels: d, enabled: f = !0, pendingRequestIds: p, areDecisionsPaused: m = !1 }) {
|
|
27
|
+
let [h, g] = l(r[0]), [_, v] = l(), { organizationId: y } = e(), [b, x] = l(y);
|
|
28
|
+
y && y !== b && (x(y), v(void 0));
|
|
29
|
+
let S = s(() => v(void 0), []), { filters: C, query: w, isFiltering: T } = o({
|
|
30
|
+
labels: d,
|
|
31
|
+
onFiltersChange: S
|
|
32
|
+
}), E = n({
|
|
33
|
+
...w,
|
|
34
|
+
limit: h,
|
|
35
|
+
pagination_token: _,
|
|
36
|
+
enabled: f
|
|
37
|
+
}), D = c(() => E.data?.data ?? [], [E.data]), O = i({ items: D }), k = t().initResponse?.userId ?? void 0, A = m || E.isPlaceholderData, j = c(() => a(D, O, d, {
|
|
38
|
+
currentUserId: k,
|
|
39
|
+
pendingRequestIds: p,
|
|
40
|
+
areDecisionsPaused: A
|
|
41
|
+
}), [
|
|
42
|
+
D,
|
|
43
|
+
O,
|
|
44
|
+
d,
|
|
45
|
+
k,
|
|
46
|
+
p,
|
|
47
|
+
A
|
|
48
|
+
]), M = E.isPlaceholderData ? void 0 : E.data, N = M?.next_pagination_token ?? void 0, P = M?.prev_pagination_token ?? void 0, F = s((e) => {
|
|
49
|
+
g(e), v(void 0);
|
|
50
|
+
}, []), I = s(() => {
|
|
51
|
+
N && v(N);
|
|
52
|
+
}, [N]), L = s(() => {
|
|
53
|
+
P && v(P);
|
|
54
|
+
}, [P]), { refetch: R } = E, z = s(() => {
|
|
55
|
+
R();
|
|
56
|
+
}, [R]);
|
|
43
57
|
return {
|
|
44
|
-
rows:
|
|
45
|
-
isLoading:
|
|
46
|
-
isError:
|
|
47
|
-
pageSize:
|
|
48
|
-
pageSizeOptions:
|
|
49
|
-
onPageSizeChange:
|
|
50
|
-
hasNextPage: !!
|
|
51
|
-
hasPrevPage: !!
|
|
52
|
-
onNextPage:
|
|
53
|
-
onPrevPage:
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
rows: j,
|
|
59
|
+
isLoading: E.isLoading,
|
|
60
|
+
isError: E.isError,
|
|
61
|
+
pageSize: h,
|
|
62
|
+
pageSizeOptions: r,
|
|
63
|
+
onPageSizeChange: F,
|
|
64
|
+
hasNextPage: !!N,
|
|
65
|
+
hasPrevPage: !!P,
|
|
66
|
+
onNextPage: I,
|
|
67
|
+
onPrevPage: L,
|
|
68
|
+
filters: C,
|
|
69
|
+
emptyState: u(T, d),
|
|
70
|
+
onRetry: z
|
|
56
71
|
};
|
|
57
72
|
}
|
|
58
73
|
//#endregion
|
|
59
|
-
export {
|
|
74
|
+
export { u as selectEmptyState, d as useApprovalRequestsTable };
|
package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import "./index2.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ApprovalRequestsFilterField as e } from "./index3.js";
|
|
3
|
+
import { ApprovalRequestsScreen as t } from "./index4.js";
|
|
4
|
+
import { RejectApprovalRequestDialog as n } from "./index5.js";
|
|
5
|
+
export { e as ApprovalRequestsFilterField, t as ApprovalRequestsScreen, n as RejectApprovalRequestDialog };
|
package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js
CHANGED
|
@@ -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
|
|
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",
|
|
@@ -7,12 +24,25 @@ var e = {
|
|
|
7
24
|
columnStatus: "Status",
|
|
8
25
|
columnAmount: "Amount",
|
|
9
26
|
columnAddedBy: "Added by",
|
|
27
|
+
columnActions: "Actions",
|
|
28
|
+
rowActions: "Request actions",
|
|
29
|
+
approve: "Approve request",
|
|
30
|
+
reject: "Reject request",
|
|
10
31
|
loadingValue: "Loading",
|
|
11
32
|
errorTitle: "Couldn't load approval requests",
|
|
12
33
|
errorDescription: "Try again.",
|
|
13
34
|
errorRetry: "Try again",
|
|
35
|
+
filterBar: n,
|
|
14
36
|
accessRestrictedTitle: "Access restricted",
|
|
15
37
|
accessRestrictedDescription: "You don't have permission to view approval requests."
|
|
38
|
+
}, i = {
|
|
39
|
+
title: "Reject this request?",
|
|
40
|
+
description: "The bill is rejected and nobody else is asked to approve it.",
|
|
41
|
+
reason: "Reason",
|
|
42
|
+
optionalNote: "(optional)",
|
|
43
|
+
confirm: "Reject request",
|
|
44
|
+
cancel: "Cancel",
|
|
45
|
+
close: "Close"
|
|
16
46
|
};
|
|
17
47
|
//#endregion
|
|
18
|
-
export {
|
|
48
|
+
export { n as APPROVAL_REQUESTS_FILTER_BAR_LABELS_EN, r as APPROVAL_REQUESTS_SCREEN_LABELS_EN, i as REJECT_APPROVAL_REQUEST_DIALOG_LABELS_EN };
|
package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index3.js
CHANGED
|
@@ -1,99 +1,143 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
accessorKey: "vendor",
|
|
29
|
-
header: C.columnVendor,
|
|
30
|
-
cell: ({ row: e }) => /* @__PURE__ */ s(d, {
|
|
31
|
-
name: e.original.vendor,
|
|
32
|
-
loadingLabel: C.loadingValue
|
|
33
|
-
})
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
accessorKey: "issueDate",
|
|
37
|
-
header: C.columnIssueDate
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
accessorKey: "dueDate",
|
|
41
|
-
header: C.columnDueDate
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
accessorKey: "statusLabel",
|
|
45
|
-
header: C.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
|
-
|
|
53
|
-
|
|
54
|
-
className: "ttw:text-right",
|
|
55
|
-
children: C.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
|
-
|
|
64
|
-
|
|
65
|
-
cell: ({ row: e }) => /* @__PURE__ */ s(d, {
|
|
66
|
-
name: e.original.addedBy,
|
|
67
|
-
loadingLabel: C.loadingValue
|
|
68
|
-
})
|
|
32
|
+
filterTag: {
|
|
33
|
+
...E.filterTag,
|
|
34
|
+
...T?.filterTag
|
|
69
35
|
}
|
|
70
|
-
];
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
+
})] })
|
|
96
140
|
});
|
|
97
141
|
}
|
|
98
142
|
//#endregion
|
|
99
|
-
export {
|
|
143
|
+
export { w as ApprovalRequestsFilterBar, w as default, b as ApprovalRequestsFilterField };
|