@nivaro/react 0.3.30 → 0.3.31
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.
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { jsx as i, Fragment as
|
|
2
|
-
import { useQuery as
|
|
1
|
+
import { jsx as i, Fragment as x, jsxs as f } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as w, useQueryClient as q, useMutation as R } from "@tanstack/react-query";
|
|
3
3
|
import { Play as C, Pause as N, Zap as $ } from "lucide-react";
|
|
4
|
-
import { useMemo as
|
|
4
|
+
import { useMemo as y, useState as F } from "react";
|
|
5
5
|
import { toast as p } from "sonner";
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as j, post as
|
|
6
|
+
import { useNivaroClient as v } from "../../context.js";
|
|
7
|
+
import { get as j, post as k } from "../../lib/commands.js";
|
|
8
8
|
import { userErrorMessage as A } from "../../lib/safe-error.js";
|
|
9
9
|
import { cn as S } from "../../lib/utils.js";
|
|
10
10
|
import { useAvailableBulkActions as B, guardMatches as P } from "../bulk/BulkActionButtons.js";
|
|
11
|
-
import { Button as
|
|
11
|
+
import { Button as b } from "../ui/button.js";
|
|
12
12
|
import { Dialog as T, DialogContent as D, DialogHeader as H, DialogTitle as M, DialogDescription as Q, DialogBody as _, DialogFooter as E } from "../ui/dialog.js";
|
|
13
13
|
import { Textarea as J } from "../ui/textarea.js";
|
|
14
14
|
import { invalidateRecordQueries as K } from "./RecordLiveSync.js";
|
|
15
15
|
function ie(e, n, t) {
|
|
16
|
-
const h =
|
|
16
|
+
const h = v(), m = !!n && n !== "new", { data: u } = B(m ? [e] : []), d = y(
|
|
17
17
|
() => ((u == null ? void 0 : u[e]) ?? []).filter(
|
|
18
18
|
(o) => o.header === !0 && (o.kind === "update_fields" || o.kind === "transition")
|
|
19
19
|
),
|
|
20
20
|
[u, e]
|
|
21
|
-
), s =
|
|
21
|
+
), s = y(() => {
|
|
22
22
|
const o = /* @__PURE__ */ new Set();
|
|
23
23
|
for (const a of d)
|
|
24
24
|
for (const r of a.guard ?? [])
|
|
25
25
|
r && typeof r.field == "string" && !(t && r.field in t) && o.add(r.field);
|
|
26
26
|
return [...o].sort();
|
|
27
|
-
}, [d, t]), { data: l } =
|
|
27
|
+
}, [d, t]), { data: l } = w({
|
|
28
28
|
queryKey: ["record-header-action-guard", e, String(n), s.join(",")],
|
|
29
29
|
queryFn: () => h.request(
|
|
30
30
|
j(`/items/${encodeURIComponent(e)}/${encodeURIComponent(String(n))}`, {
|
|
@@ -34,7 +34,7 @@ function ie(e, n, t) {
|
|
|
34
34
|
enabled: m && s.length > 0,
|
|
35
35
|
staleTime: 0
|
|
36
36
|
});
|
|
37
|
-
return
|
|
37
|
+
return y(() => {
|
|
38
38
|
if (s.length > 0 && !l) return d.filter((a) => {
|
|
39
39
|
var r;
|
|
40
40
|
return !((r = a.guard) != null && r.length);
|
|
@@ -54,23 +54,28 @@ function ae({
|
|
|
54
54
|
actions: e,
|
|
55
55
|
onPick: n
|
|
56
56
|
}) {
|
|
57
|
-
return e.length === 0 ? null : /* @__PURE__ */ i(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
return e.length === 0 ? null : /* @__PURE__ */ i(x, { children: e.map((t) => (
|
|
58
|
+
// Same Button, size and type as the pipeline's transition buttons beside them.
|
|
59
|
+
/* @__PURE__ */ f(
|
|
60
|
+
b,
|
|
61
|
+
{
|
|
62
|
+
type: "button",
|
|
63
|
+
size: "sm",
|
|
64
|
+
variant: "outline",
|
|
65
|
+
"data-record-header-action": t.key,
|
|
66
|
+
"data-tip": W(t),
|
|
67
|
+
onClick: () => n(t),
|
|
68
|
+
className: S(
|
|
69
|
+
"shrink-0 gap-1.5 text-[12px]",
|
|
70
|
+
t.variant === "danger" && "border-red-300 text-red-600 hover:bg-red-50 hover:text-red-700 dark:border-red-500/40 dark:text-red-400 dark:hover:bg-red-500/10"
|
|
71
|
+
),
|
|
72
|
+
children: [
|
|
73
|
+
U(t),
|
|
74
|
+
t.label
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
`${t.source}:${t.key}`
|
|
78
|
+
)
|
|
74
79
|
)) });
|
|
75
80
|
}
|
|
76
81
|
function se({
|
|
@@ -80,9 +85,9 @@ function se({
|
|
|
80
85
|
onClose: h,
|
|
81
86
|
onDone: m
|
|
82
87
|
}) {
|
|
83
|
-
const u =
|
|
88
|
+
const u = v(), d = q(), [s, l] = F(""), o = !!(e != null && e.require_reason), a = R({
|
|
84
89
|
mutationFn: async (r) => {
|
|
85
|
-
const c = { collection: n, ids: [t], reason: s.trim() || null }, g = r.source === "db" ? await u.request(
|
|
90
|
+
const c = { collection: n, ids: [t], reason: s.trim() || null }, g = r.source === "db" ? await u.request(k("/bulk-actions/run", { ...c, key: r.key })) : await u.request(k(`/bulk-actions/${r.key}/execute`, c));
|
|
86
91
|
return { a: r, result: g.data ?? {} };
|
|
87
92
|
},
|
|
88
93
|
onSuccess: ({ a: r, result: c }) => {
|
|
@@ -118,9 +123,9 @@ function se({
|
|
|
118
123
|
)
|
|
119
124
|
] }),
|
|
120
125
|
/* @__PURE__ */ f(E, { children: [
|
|
121
|
-
/* @__PURE__ */ i(
|
|
126
|
+
/* @__PURE__ */ i(b, { variant: "outline", onClick: h, disabled: a.isPending, children: "Cancel" }),
|
|
122
127
|
/* @__PURE__ */ i(
|
|
123
|
-
|
|
128
|
+
b,
|
|
124
129
|
{
|
|
125
130
|
onClick: () => e && a.mutate(e),
|
|
126
131
|
disabled: !e || a.isPending || o && !s.trim(),
|