@nivaro/react 0.3.38 → 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 +2348 -2315
- package/dist/shared/components/PickerExcludedRows.js +55 -0
- package/dist/shared/components/item-edit/RecordGrantTools.js +89 -81
- 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,86 +1,93 @@
|
|
|
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
|
|
5
|
-
import { toast as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { titleCase as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
import { toast as g } from "sonner";
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
queryFn: () => u.request(
|
|
24
|
-
V(`/picker-exclusions/status/${l}/${r}`)
|
|
25
|
-
).then((a) => a.data),
|
|
17
|
+
function J(a, r, l = {}) {
|
|
18
|
+
const s = F(), o = D(), h = ["picker-exclusion", a, r], { data: c, isLoading: p } = I({
|
|
19
|
+
queryKey: h,
|
|
20
|
+
queryFn: () => s.request(
|
|
21
|
+
M(`/picker-exclusions/status/${a}/${r}`)
|
|
22
|
+
).then((i) => i.data),
|
|
23
|
+
enabled: l.enabled ?? !0,
|
|
26
24
|
staleTime: 6e4
|
|
27
|
-
}),
|
|
25
|
+
}), d = (c == null ? void 0 : c.excluded) ?? !1, u = q({
|
|
28
26
|
mutationFn: () => {
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
|
|
27
|
+
const i = { collection: a, item_id: r, layout: l.layoutSlug ?? null };
|
|
28
|
+
return s.request(
|
|
29
|
+
d ? { _method: "DELETE", _path: "/picker-exclusions", _body: i } : O("/picker-exclusions", i)
|
|
32
30
|
);
|
|
33
31
|
},
|
|
34
32
|
onSuccess: () => {
|
|
35
|
-
|
|
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);
|
|
36
35
|
},
|
|
37
|
-
onError: (
|
|
36
|
+
onError: (i) => g.error($(i, "Could not change picker visibility"))
|
|
38
37
|
});
|
|
38
|
+
return { excluded: d, isLoading: p, toggle: u };
|
|
39
|
+
}
|
|
40
|
+
function me({
|
|
41
|
+
collection: a,
|
|
42
|
+
itemId: r,
|
|
43
|
+
layoutSlug: l
|
|
44
|
+
}) {
|
|
45
|
+
const { excluded: s, toggle: o } = J(a, r, { layoutSlug: l });
|
|
39
46
|
return /* @__PURE__ */ n(
|
|
40
47
|
"button",
|
|
41
48
|
{
|
|
42
49
|
type: "button",
|
|
43
50
|
"data-record-picker-exclusion": !0,
|
|
44
|
-
"data-excluded":
|
|
51
|
+
"data-excluded": s ? "true" : "false",
|
|
45
52
|
disabled: o.isPending,
|
|
46
53
|
onClick: () => o.mutate(),
|
|
47
|
-
"data-tip":
|
|
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",
|
|
48
55
|
className: "inline-flex items-center",
|
|
49
56
|
children: [
|
|
50
|
-
o.isPending ? /* @__PURE__ */ t(
|
|
51
|
-
|
|
57
|
+
o.isPending ? /* @__PURE__ */ t(K, { className: "animate-spin" }) : /* @__PURE__ */ t(L, {}),
|
|
58
|
+
s ? "Re-enable in pickers" : "Disable in pickers"
|
|
52
59
|
]
|
|
53
60
|
}
|
|
54
61
|
);
|
|
55
62
|
}
|
|
56
|
-
function
|
|
57
|
-
collection:
|
|
63
|
+
function he({
|
|
64
|
+
collection: a,
|
|
58
65
|
itemId: r,
|
|
59
|
-
fields:
|
|
60
|
-
layoutSlug:
|
|
66
|
+
fields: l,
|
|
67
|
+
layoutSlug: s
|
|
61
68
|
}) {
|
|
62
|
-
const
|
|
63
|
-
() =>
|
|
64
|
-
[
|
|
65
|
-
),
|
|
66
|
-
mutationFn: () =>
|
|
67
|
-
|
|
68
|
-
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,
|
|
69
76
|
item_id: r,
|
|
70
77
|
change_type: "field_update",
|
|
71
|
-
changes: { [
|
|
78
|
+
changes: { [u]: b },
|
|
72
79
|
// datetime-local is the viewer's local time; the API stores UTC.
|
|
73
|
-
scheduled_at: new Date(
|
|
74
|
-
layout:
|
|
80
|
+
scheduled_at: new Date(f).toISOString(),
|
|
81
|
+
layout: s ?? null
|
|
75
82
|
})
|
|
76
83
|
),
|
|
77
84
|
onSuccess: () => {
|
|
78
|
-
|
|
85
|
+
c(!1), i(""), N(""), C(""), g.success("Change scheduled");
|
|
79
86
|
},
|
|
80
|
-
onError: (e) =>
|
|
81
|
-
}), T =
|
|
82
|
-
return /* @__PURE__ */ n(
|
|
83
|
-
/* @__PURE__ */ t(
|
|
87
|
+
onError: (e) => g.error($(e, "Could not schedule the change"))
|
|
88
|
+
}), T = f !== "" && !Number.isNaN(new Date(f).getTime());
|
|
89
|
+
return /* @__PURE__ */ n(E, { open: h, onOpenChange: c, children: [
|
|
90
|
+
/* @__PURE__ */ t(_, { asChild: !0, children: /* @__PURE__ */ n(
|
|
84
91
|
"button",
|
|
85
92
|
{
|
|
86
93
|
type: "button",
|
|
@@ -98,41 +105,41 @@ function de({
|
|
|
98
105
|
/* @__PURE__ */ n("div", { className: "space-y-3", children: [
|
|
99
106
|
/* @__PURE__ */ n("div", { children: [
|
|
100
107
|
/* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium text-muted-foreground", children: "Field" }),
|
|
101
|
-
/* @__PURE__ */ n(
|
|
102
|
-
/* @__PURE__ */ t(
|
|
103
|
-
|
|
108
|
+
/* @__PURE__ */ n(E, { open: p, onOpenChange: d, children: [
|
|
109
|
+
/* @__PURE__ */ t(_, { asChild: !0, children: /* @__PURE__ */ n(
|
|
110
|
+
S,
|
|
104
111
|
{
|
|
105
112
|
type: "button",
|
|
106
113
|
variant: "outline",
|
|
107
114
|
role: "combobox",
|
|
108
|
-
"aria-expanded":
|
|
115
|
+
"aria-expanded": p,
|
|
109
116
|
"aria-label": "Field",
|
|
110
117
|
className: "h-8 w-full justify-between text-[12px] font-normal",
|
|
111
118
|
children: [
|
|
112
|
-
/* @__PURE__ */ t("span", { className: "truncate", children: (
|
|
119
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: (y == null ? void 0 : y.label) ?? "Select a field…" }),
|
|
113
120
|
/* @__PURE__ */ t(R, { className: "ml-1 h-3 w-3 shrink-0 opacity-50" })
|
|
114
121
|
]
|
|
115
122
|
}
|
|
116
123
|
) }),
|
|
117
|
-
/* @__PURE__ */ t(P, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: /* @__PURE__ */ n(
|
|
118
|
-
/* @__PURE__ */ t(
|
|
119
|
-
/* @__PURE__ */ n(
|
|
120
|
-
/* @__PURE__ */ t(
|
|
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" }),
|
|
121
128
|
k.map((e) => /* @__PURE__ */ n(
|
|
122
|
-
|
|
129
|
+
Y,
|
|
123
130
|
{
|
|
124
131
|
value: `${e.label} ${e.field}`,
|
|
125
132
|
onSelect: () => {
|
|
126
|
-
|
|
133
|
+
i(e.field), d(!1);
|
|
127
134
|
},
|
|
128
135
|
className: "text-[12px]",
|
|
129
136
|
children: [
|
|
130
137
|
/* @__PURE__ */ t(
|
|
131
|
-
|
|
138
|
+
j,
|
|
132
139
|
{
|
|
133
|
-
className:
|
|
140
|
+
className: V(
|
|
134
141
|
"mr-2 h-3.5 w-3.5",
|
|
135
|
-
|
|
142
|
+
u === e.field ? "opacity-100" : "opacity-0"
|
|
136
143
|
)
|
|
137
144
|
}
|
|
138
145
|
),
|
|
@@ -150,17 +157,17 @@ function de({
|
|
|
150
157
|
/* @__PURE__ */ t(
|
|
151
158
|
"label",
|
|
152
159
|
{
|
|
153
|
-
htmlFor: `${
|
|
160
|
+
htmlFor: `${x}-value`,
|
|
154
161
|
className: "mb-1 block text-[11px] font-medium text-muted-foreground",
|
|
155
162
|
children: "New value"
|
|
156
163
|
}
|
|
157
164
|
),
|
|
158
165
|
/* @__PURE__ */ t(
|
|
159
|
-
|
|
166
|
+
w,
|
|
160
167
|
{
|
|
161
|
-
id: `${
|
|
162
|
-
value:
|
|
163
|
-
onChange: (e) =>
|
|
168
|
+
id: `${x}-value`,
|
|
169
|
+
value: b,
|
|
170
|
+
onChange: (e) => N(e.target.value),
|
|
164
171
|
className: "h-8 text-[12px]"
|
|
165
172
|
}
|
|
166
173
|
)
|
|
@@ -169,31 +176,31 @@ function de({
|
|
|
169
176
|
/* @__PURE__ */ t(
|
|
170
177
|
"label",
|
|
171
178
|
{
|
|
172
|
-
htmlFor: `${
|
|
179
|
+
htmlFor: `${x}-at`,
|
|
173
180
|
className: "mb-1 block text-[11px] font-medium text-muted-foreground",
|
|
174
181
|
children: "When"
|
|
175
182
|
}
|
|
176
183
|
),
|
|
177
184
|
/* @__PURE__ */ t(
|
|
178
|
-
|
|
185
|
+
w,
|
|
179
186
|
{
|
|
180
|
-
id: `${
|
|
187
|
+
id: `${x}-at`,
|
|
181
188
|
type: "datetime-local",
|
|
182
|
-
value:
|
|
189
|
+
value: f,
|
|
183
190
|
onChange: (e) => C(e.target.value),
|
|
184
191
|
className: "h-8 text-[12px]"
|
|
185
192
|
}
|
|
186
193
|
)
|
|
187
194
|
] }),
|
|
188
195
|
/* @__PURE__ */ t(
|
|
189
|
-
|
|
196
|
+
S,
|
|
190
197
|
{
|
|
191
198
|
type: "button",
|
|
192
199
|
size: "sm",
|
|
193
200
|
className: "h-8 w-full bg-nvr-cyan text-[12px] text-white hover:bg-nvr-cyan/90",
|
|
194
|
-
disabled: !
|
|
195
|
-
onClick: () =>
|
|
196
|
-
children:
|
|
201
|
+
disabled: !u || !b || !T || v.isPending,
|
|
202
|
+
onClick: () => v.mutate(),
|
|
203
|
+
children: v.isPending ? "Scheduling…" : "Schedule change"
|
|
197
204
|
}
|
|
198
205
|
)
|
|
199
206
|
] })
|
|
@@ -201,6 +208,7 @@ function de({
|
|
|
201
208
|
] });
|
|
202
209
|
}
|
|
203
210
|
export {
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
me as PickerExclusionToggle,
|
|
212
|
+
he as ScheduleChangeButton,
|
|
213
|
+
J as usePickerExclusion
|
|
206
214
|
};
|