@nivaro/react 0.3.39 → 0.3.40
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/CollectionBrowserView.js +1745 -1740
- package/dist/shared/components/PickerExcludedRows.js +55 -0
- package/dist/shared/components/item-edit/RecordGrantTools.js +68 -67
- package/dist/shared/components/queue/QueueWorklist.js +640 -633
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useQueries as _ } from "@tanstack/react-query";
|
|
2
|
+
import { useMemo as c, useCallback as x } from "react";
|
|
3
|
+
import { useNivaroClient as f } from "../context.js";
|
|
4
|
+
import { post as g } from "../lib/commands.js";
|
|
5
|
+
const m = "picker-exclusions-page";
|
|
6
|
+
function S(a, d) {
|
|
7
|
+
const l = f(), o = c(() => {
|
|
8
|
+
const e = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const t of a) {
|
|
10
|
+
if (!t.collection || t.id == null) continue;
|
|
11
|
+
const n = e.get(t.collection) ?? [];
|
|
12
|
+
n.push(String(t.id)), e.set(t.collection, n);
|
|
13
|
+
}
|
|
14
|
+
return [...e.entries()].map(([t, n]) => ({
|
|
15
|
+
collection: t,
|
|
16
|
+
ids: [...new Set(n)].sort()
|
|
17
|
+
}));
|
|
18
|
+
}, [a]), s = _({
|
|
19
|
+
queries: o.map(({ collection: e, ids: t }) => ({
|
|
20
|
+
queryKey: [m, e, t.join(",")],
|
|
21
|
+
queryFn: () => l.request(
|
|
22
|
+
g("/picker-exclusions/batch-status", { collection: e, ids: t })
|
|
23
|
+
).then((n) => {
|
|
24
|
+
var r;
|
|
25
|
+
return ((r = n.data) == null ? void 0 : r.excluded) ?? [];
|
|
26
|
+
}),
|
|
27
|
+
enabled: d && t.length > 0,
|
|
28
|
+
staleTime: 6e4,
|
|
29
|
+
retry: !1
|
|
30
|
+
}))
|
|
31
|
+
}), p = s.map((e) => (e.data ?? []).join(",")).join("|"), i = c(() => {
|
|
32
|
+
const e = /* @__PURE__ */ new Set();
|
|
33
|
+
return o.forEach(({ collection: t }, n) => {
|
|
34
|
+
var r;
|
|
35
|
+
for (const u of ((r = s[n]) == null ? void 0 : r.data) ?? []) e.add(`${t}|${String(u).toUpperCase()}`);
|
|
36
|
+
}), e;
|
|
37
|
+
}, [o, p]);
|
|
38
|
+
return x(
|
|
39
|
+
(e, t) => i.has(`${e}|${String(t).toUpperCase()}`),
|
|
40
|
+
[i]
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const y = "Excluded from pickers — not offered in any dropdown. Actions → Include in pickers to offer it again.", h = [
|
|
44
|
+
"[&>td]:italic [&>td_*]:italic",
|
|
45
|
+
"[&>td]:!text-slate-500 [&>td_a]:!text-slate-500 [&>td_button]:!text-slate-500",
|
|
46
|
+
"dark:[&>td]:!text-slate-400 dark:[&>td_a]:!text-slate-400 dark:[&>td_button]:!text-slate-400",
|
|
47
|
+
"[&>td]:bg-[repeating-linear-gradient(135deg,rgb(100_116_139/0.09)_0_1px,transparent_1px_6px)]",
|
|
48
|
+
"dark:[&>td]:bg-[repeating-linear-gradient(135deg,rgb(148_163_184/0.10)_0_1px,transparent_1px_6px)]"
|
|
49
|
+
].join(" ");
|
|
50
|
+
export {
|
|
51
|
+
h as PICKER_EXCLUDED_ROW_CLASS,
|
|
52
|
+
y as PICKER_EXCLUDED_TITLE,
|
|
53
|
+
m as PICKER_EXCLUSIONS_PAGE_KEY,
|
|
54
|
+
S as usePickerExcludedRows
|
|
55
|
+
};
|
|
@@ -1,77 +1,78 @@
|
|
|
1
1
|
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useQueryClient as D, useQuery as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useState as m, useId as
|
|
2
|
+
import { useQueryClient as D, useQuery as I, useMutation as q } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as K, EyeOff as L, CalendarClock as Q, ChevronsUpDown as R, Check as j } from "lucide-react";
|
|
4
|
+
import { useState as m, useId as A, useMemo as B } from "react";
|
|
5
5
|
import { toast as g } from "sonner";
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { titleCase as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
import { useNivaroClient as F } from "../../context.js";
|
|
7
|
+
import { get as M, post as O } from "../../lib/commands.js";
|
|
8
|
+
import { titleCase as U, cn as V } from "../../lib/utils.js";
|
|
9
|
+
import { PICKER_EXCLUSIONS_PAGE_KEY as W } from "../PickerExcludedRows.js";
|
|
10
|
+
import { Button as S } from "../ui/button.js";
|
|
11
|
+
import { Command as z, CommandInput as G, CommandList as H, CommandEmpty as X, CommandItem as Y } from "../ui/command.js";
|
|
12
|
+
import { Input as w } from "../ui/input.js";
|
|
13
|
+
import { Popover as E, PopoverTrigger as _, PopoverContent as P } from "../ui/popover.js";
|
|
14
|
+
function $(a, r) {
|
|
15
|
+
return a instanceof Error && a.message ? a.message : r;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
const s =
|
|
17
|
+
function J(a, r, l = {}) {
|
|
18
|
+
const s = F(), o = D(), h = ["picker-exclusion", a, r], { data: c, isLoading: p } = I({
|
|
18
19
|
queryKey: h,
|
|
19
20
|
queryFn: () => s.request(
|
|
20
|
-
|
|
21
|
-
).then((
|
|
22
|
-
enabled:
|
|
21
|
+
M(`/picker-exclusions/status/${a}/${r}`)
|
|
22
|
+
).then((i) => i.data),
|
|
23
|
+
enabled: l.enabled ?? !0,
|
|
23
24
|
staleTime: 6e4
|
|
24
|
-
}), d = (
|
|
25
|
+
}), d = (c == null ? void 0 : c.excluded) ?? !1, u = q({
|
|
25
26
|
mutationFn: () => {
|
|
26
|
-
const
|
|
27
|
+
const i = { collection: a, item_id: r, layout: l.layoutSlug ?? null };
|
|
27
28
|
return s.request(
|
|
28
|
-
d ? { _method: "DELETE", _path: "/picker-exclusions", _body:
|
|
29
|
+
d ? { _method: "DELETE", _path: "/picker-exclusions", _body: i } : O("/picker-exclusions", i)
|
|
29
30
|
);
|
|
30
31
|
},
|
|
31
32
|
onSuccess: () => {
|
|
32
|
-
var
|
|
33
|
-
|
|
33
|
+
var i;
|
|
34
|
+
o.invalidateQueries({ queryKey: h }), o.invalidateQueries({ queryKey: [W, a] }), g.success(d ? "Record re-enabled in pickers" : "Record excluded from pickers"), (i = l.onDone) == null || i.call(l);
|
|
34
35
|
},
|
|
35
|
-
onError: (
|
|
36
|
+
onError: (i) => g.error($(i, "Could not change picker visibility"))
|
|
36
37
|
});
|
|
37
38
|
return { excluded: d, isLoading: p, toggle: u };
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
-
collection:
|
|
40
|
+
function me({
|
|
41
|
+
collection: a,
|
|
41
42
|
itemId: r,
|
|
42
|
-
layoutSlug:
|
|
43
|
+
layoutSlug: l
|
|
43
44
|
}) {
|
|
44
|
-
const { excluded: s, toggle:
|
|
45
|
+
const { excluded: s, toggle: o } = J(a, r, { layoutSlug: l });
|
|
45
46
|
return /* @__PURE__ */ n(
|
|
46
47
|
"button",
|
|
47
48
|
{
|
|
48
49
|
type: "button",
|
|
49
50
|
"data-record-picker-exclusion": !0,
|
|
50
51
|
"data-excluded": s ? "true" : "false",
|
|
51
|
-
disabled:
|
|
52
|
-
onClick: () =>
|
|
52
|
+
disabled: o.isPending,
|
|
53
|
+
onClick: () => o.mutate(),
|
|
53
54
|
"data-tip": s ? "This record is hidden from pickers — click to offer it again" : "Hide this record from every picker that would offer it",
|
|
54
55
|
className: "inline-flex items-center",
|
|
55
56
|
children: [
|
|
56
|
-
|
|
57
|
+
o.isPending ? /* @__PURE__ */ t(K, { className: "animate-spin" }) : /* @__PURE__ */ t(L, {}),
|
|
57
58
|
s ? "Re-enable in pickers" : "Disable in pickers"
|
|
58
59
|
]
|
|
59
60
|
}
|
|
60
61
|
);
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
-
collection:
|
|
63
|
+
function he({
|
|
64
|
+
collection: a,
|
|
64
65
|
itemId: r,
|
|
65
|
-
fields:
|
|
66
|
+
fields: l,
|
|
66
67
|
layoutSlug: s
|
|
67
68
|
}) {
|
|
68
|
-
const
|
|
69
|
-
() =>
|
|
70
|
-
[
|
|
71
|
-
), y =
|
|
72
|
-
mutationFn: () =>
|
|
73
|
-
|
|
74
|
-
collection:
|
|
69
|
+
const o = F(), [h, c] = m(!1), [p, d] = m(!1), [u, i] = m(""), [b, N] = m(""), [f, C] = m(""), x = A(), k = B(
|
|
70
|
+
() => l.filter((e) => !e.field.startsWith("__") && !e.field.includes(".")).map((e) => ({ field: e.field, label: e.label || U(e.field) })),
|
|
71
|
+
[l]
|
|
72
|
+
), y = k.find((e) => e.field === u), v = q({
|
|
73
|
+
mutationFn: () => o.request(
|
|
74
|
+
O("/scheduled-changes", {
|
|
75
|
+
collection: a,
|
|
75
76
|
item_id: r,
|
|
76
77
|
change_type: "field_update",
|
|
77
78
|
changes: { [u]: b },
|
|
@@ -81,12 +82,12 @@ function ue({
|
|
|
81
82
|
})
|
|
82
83
|
),
|
|
83
84
|
onSuccess: () => {
|
|
84
|
-
|
|
85
|
+
c(!1), i(""), N(""), C(""), g.success("Change scheduled");
|
|
85
86
|
},
|
|
86
|
-
onError: (e) => g.error(
|
|
87
|
+
onError: (e) => g.error($(e, "Could not schedule the change"))
|
|
87
88
|
}), T = f !== "" && !Number.isNaN(new Date(f).getTime());
|
|
88
|
-
return /* @__PURE__ */ n(E, { open: h, onOpenChange:
|
|
89
|
-
/* @__PURE__ */ t(
|
|
89
|
+
return /* @__PURE__ */ n(E, { open: h, onOpenChange: c, children: [
|
|
90
|
+
/* @__PURE__ */ t(_, { asChild: !0, children: /* @__PURE__ */ n(
|
|
90
91
|
"button",
|
|
91
92
|
{
|
|
92
93
|
type: "button",
|
|
@@ -99,14 +100,14 @@ function ue({
|
|
|
99
100
|
]
|
|
100
101
|
}
|
|
101
102
|
) }),
|
|
102
|
-
/* @__PURE__ */ n(
|
|
103
|
+
/* @__PURE__ */ n(P, { side: "left", align: "start", className: "w-80 p-4", "data-schedule-change-panel": !0, children: [
|
|
103
104
|
/* @__PURE__ */ t("p", { className: "mb-3 text-[13px] font-medium", children: "Schedule a field change" }),
|
|
104
105
|
/* @__PURE__ */ n("div", { className: "space-y-3", children: [
|
|
105
106
|
/* @__PURE__ */ n("div", { children: [
|
|
106
107
|
/* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium text-muted-foreground", children: "Field" }),
|
|
107
108
|
/* @__PURE__ */ n(E, { open: p, onOpenChange: d, children: [
|
|
108
|
-
/* @__PURE__ */ t(
|
|
109
|
-
|
|
109
|
+
/* @__PURE__ */ t(_, { asChild: !0, children: /* @__PURE__ */ n(
|
|
110
|
+
S,
|
|
110
111
|
{
|
|
111
112
|
type: "button",
|
|
112
113
|
variant: "outline",
|
|
@@ -120,23 +121,23 @@ function ue({
|
|
|
120
121
|
]
|
|
121
122
|
}
|
|
122
123
|
) }),
|
|
123
|
-
/* @__PURE__ */ t(
|
|
124
|
-
/* @__PURE__ */ t(
|
|
125
|
-
/* @__PURE__ */ n(
|
|
126
|
-
/* @__PURE__ */ t(
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
/* @__PURE__ */ t(P, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: /* @__PURE__ */ n(z, { children: [
|
|
125
|
+
/* @__PURE__ */ t(G, { placeholder: "Search fields…", className: "h-8 text-[12px]" }),
|
|
126
|
+
/* @__PURE__ */ n(H, { children: [
|
|
127
|
+
/* @__PURE__ */ t(X, { className: "py-3 text-center text-[12px] text-muted-foreground", children: "No field matches" }),
|
|
128
|
+
k.map((e) => /* @__PURE__ */ n(
|
|
129
|
+
Y,
|
|
129
130
|
{
|
|
130
131
|
value: `${e.label} ${e.field}`,
|
|
131
132
|
onSelect: () => {
|
|
132
|
-
|
|
133
|
+
i(e.field), d(!1);
|
|
133
134
|
},
|
|
134
135
|
className: "text-[12px]",
|
|
135
136
|
children: [
|
|
136
137
|
/* @__PURE__ */ t(
|
|
137
|
-
|
|
138
|
+
j,
|
|
138
139
|
{
|
|
139
|
-
className:
|
|
140
|
+
className: V(
|
|
140
141
|
"mr-2 h-3.5 w-3.5",
|
|
141
142
|
u === e.field ? "opacity-100" : "opacity-0"
|
|
142
143
|
)
|
|
@@ -162,11 +163,11 @@ function ue({
|
|
|
162
163
|
}
|
|
163
164
|
),
|
|
164
165
|
/* @__PURE__ */ t(
|
|
165
|
-
|
|
166
|
+
w,
|
|
166
167
|
{
|
|
167
168
|
id: `${x}-value`,
|
|
168
169
|
value: b,
|
|
169
|
-
onChange: (e) =>
|
|
170
|
+
onChange: (e) => N(e.target.value),
|
|
170
171
|
className: "h-8 text-[12px]"
|
|
171
172
|
}
|
|
172
173
|
)
|
|
@@ -181,25 +182,25 @@ function ue({
|
|
|
181
182
|
}
|
|
182
183
|
),
|
|
183
184
|
/* @__PURE__ */ t(
|
|
184
|
-
|
|
185
|
+
w,
|
|
185
186
|
{
|
|
186
187
|
id: `${x}-at`,
|
|
187
188
|
type: "datetime-local",
|
|
188
189
|
value: f,
|
|
189
|
-
onChange: (e) =>
|
|
190
|
+
onChange: (e) => C(e.target.value),
|
|
190
191
|
className: "h-8 text-[12px]"
|
|
191
192
|
}
|
|
192
193
|
)
|
|
193
194
|
] }),
|
|
194
195
|
/* @__PURE__ */ t(
|
|
195
|
-
|
|
196
|
+
S,
|
|
196
197
|
{
|
|
197
198
|
type: "button",
|
|
198
199
|
size: "sm",
|
|
199
200
|
className: "h-8 w-full bg-nvr-cyan text-[12px] text-white hover:bg-nvr-cyan/90",
|
|
200
|
-
disabled: !u || !b || !T ||
|
|
201
|
-
onClick: () =>
|
|
202
|
-
children:
|
|
201
|
+
disabled: !u || !b || !T || v.isPending,
|
|
202
|
+
onClick: () => v.mutate(),
|
|
203
|
+
children: v.isPending ? "Scheduling…" : "Schedule change"
|
|
203
204
|
}
|
|
204
205
|
)
|
|
205
206
|
] })
|
|
@@ -207,7 +208,7 @@ function ue({
|
|
|
207
208
|
] });
|
|
208
209
|
}
|
|
209
210
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
me as PickerExclusionToggle,
|
|
212
|
+
he as ScheduleChangeButton,
|
|
213
|
+
J as usePickerExclusion
|
|
213
214
|
};
|