@nivaro/react 0.3.39 → 0.3.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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared/components/CollectionBrowserView.js +1742 -1737
- package/dist/shared/components/PickerExcludedRows.js +55 -0
- package/dist/shared/components/item-edit/RecordGrantTools.js +81 -80
- package/dist/shared/components/layout-editor/settings/settings-registry.js +1 -1
- 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 h = "Hidden from pickers — not offered in any dropdown. Actions → Show in pickers to offer it again.", y = [
|
|
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
|
+
y as PICKER_EXCLUDED_ROW_CLASS,
|
|
52
|
+
h as PICKER_EXCLUDED_TITLE,
|
|
53
|
+
m as PICKER_EXCLUSIONS_PAGE_KEY,
|
|
54
|
+
S as usePickerExcludedRows
|
|
55
|
+
};
|
|
@@ -1,92 +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 m, useId 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 j, Check as H } from "lucide-react";
|
|
4
|
+
import { useState as m, useId as A, useMemo as B } from "react";
|
|
5
|
+
import { toast as x } 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 R, 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
|
|
17
|
+
function J(a, r, l = {}) {
|
|
18
|
+
const o = F(), s = D(), h = ["picker-exclusion", a, r], { data: c, isLoading: p } = I({
|
|
18
19
|
queryKey: h,
|
|
19
|
-
queryFn: () =>
|
|
20
|
-
|
|
21
|
-
).then((
|
|
22
|
-
enabled:
|
|
20
|
+
queryFn: () => o.request(
|
|
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
|
-
return
|
|
28
|
-
d ? { _method: "DELETE", _path: "/picker-exclusions", _body:
|
|
27
|
+
const i = { collection: a, item_id: r, layout: l.layoutSlug ?? null };
|
|
28
|
+
return o.request(
|
|
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
|
+
s.invalidateQueries({ queryKey: h }), s.invalidateQueries({ queryKey: [W, a] }), x.success(d ? "Shown in pickers again" : "Hidden from pickers"), (i = l.onDone) == null || i.call(l);
|
|
34
35
|
},
|
|
35
|
-
onError: (
|
|
36
|
+
onError: (i) => x.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:
|
|
45
|
+
const { excluded: o, toggle: s } = 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
|
-
"data-excluded":
|
|
51
|
-
disabled:
|
|
52
|
-
onClick: () =>
|
|
53
|
-
"data-tip":
|
|
51
|
+
"data-excluded": o ? "true" : "false",
|
|
52
|
+
disabled: s.isPending,
|
|
53
|
+
onClick: () => s.mutate(),
|
|
54
|
+
"data-tip": o ? "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
|
-
|
|
57
|
+
s.isPending ? /* @__PURE__ */ t(K, { className: "animate-spin" }) : /* @__PURE__ */ t(L, {}),
|
|
58
|
+
o ? "Show in pickers" : "Hide from 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
|
-
layoutSlug:
|
|
66
|
+
fields: l,
|
|
67
|
+
layoutSlug: o
|
|
67
68
|
}) {
|
|
68
|
-
const
|
|
69
|
-
() =>
|
|
70
|
-
[
|
|
71
|
-
), y =
|
|
72
|
-
mutationFn: () =>
|
|
73
|
-
|
|
74
|
-
collection:
|
|
69
|
+
const s = F(), [h, c] = m(!1), [p, d] = m(!1), [u, i] = m(""), [b, N] = m(""), [f, C] = m(""), g = 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: () => s.request(
|
|
74
|
+
O("/scheduled-changes", {
|
|
75
|
+
collection: a,
|
|
75
76
|
item_id: r,
|
|
76
77
|
change_type: "field_update",
|
|
77
78
|
changes: { [u]: b },
|
|
78
79
|
// datetime-local is the viewer's local time; the API stores UTC.
|
|
79
80
|
scheduled_at: new Date(f).toISOString(),
|
|
80
|
-
layout:
|
|
81
|
+
layout: o ?? null
|
|
81
82
|
})
|
|
82
83
|
),
|
|
83
84
|
onSuccess: () => {
|
|
84
|
-
|
|
85
|
+
c(!1), i(""), N(""), C(""), x.success("Change scheduled");
|
|
85
86
|
},
|
|
86
|
-
onError: (e) =>
|
|
87
|
+
onError: (e) => x.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",
|
|
@@ -116,27 +117,27 @@ function ue({
|
|
|
116
117
|
className: "h-8 w-full justify-between text-[12px] font-normal",
|
|
117
118
|
children: [
|
|
118
119
|
/* @__PURE__ */ t("span", { className: "truncate", children: (y == null ? void 0 : y.label) ?? "Select a field…" }),
|
|
119
|
-
/* @__PURE__ */ t(
|
|
120
|
+
/* @__PURE__ */ t(j, { className: "ml-1 h-3 w-3 shrink-0 opacity-50" })
|
|
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(R, { 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
|
+
H,
|
|
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
|
)
|
|
@@ -156,17 +157,17 @@ function ue({
|
|
|
156
157
|
/* @__PURE__ */ t(
|
|
157
158
|
"label",
|
|
158
159
|
{
|
|
159
|
-
htmlFor: `${
|
|
160
|
+
htmlFor: `${g}-value`,
|
|
160
161
|
className: "mb-1 block text-[11px] font-medium text-muted-foreground",
|
|
161
162
|
children: "New value"
|
|
162
163
|
}
|
|
163
164
|
),
|
|
164
165
|
/* @__PURE__ */ t(
|
|
165
|
-
|
|
166
|
+
w,
|
|
166
167
|
{
|
|
167
|
-
id: `${
|
|
168
|
+
id: `${g}-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
|
)
|
|
@@ -175,31 +176,31 @@ function ue({
|
|
|
175
176
|
/* @__PURE__ */ t(
|
|
176
177
|
"label",
|
|
177
178
|
{
|
|
178
|
-
htmlFor: `${
|
|
179
|
+
htmlFor: `${g}-at`,
|
|
179
180
|
className: "mb-1 block text-[11px] font-medium text-muted-foreground",
|
|
180
181
|
children: "When"
|
|
181
182
|
}
|
|
182
183
|
),
|
|
183
184
|
/* @__PURE__ */ t(
|
|
184
|
-
|
|
185
|
+
w,
|
|
185
186
|
{
|
|
186
|
-
id: `${
|
|
187
|
+
id: `${g}-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
|
};
|
|
@@ -203,7 +203,7 @@ const y = [
|
|
|
203
203
|
{
|
|
204
204
|
key: "layout.allow_disable_pickers",
|
|
205
205
|
section: "buttons",
|
|
206
|
-
label: "Hide
|
|
206
|
+
label: "Hide from pickers button for everyone",
|
|
207
207
|
effect: "Everyone who can edit may hide a record from pickers, not only admins.",
|
|
208
208
|
types: t
|
|
209
209
|
},
|