@nivaro/react 0.3.92 → 0.3.94
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,127 +1,142 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { MoveRight as
|
|
4
|
-
import { useState as h, useEffect as
|
|
5
|
-
import { toast as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { toastError as
|
|
9
|
-
import { Button as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
const
|
|
13
|
-
function
|
|
1
|
+
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as O, useMutation as T } from "@tanstack/react-query";
|
|
3
|
+
import { MoveRight as C, AlertTriangle as U, Loader2 as _ } from "lucide-react";
|
|
4
|
+
import { useState as h, useEffect as j, useMemo as z } from "react";
|
|
5
|
+
import { toast as W } from "sonner";
|
|
6
|
+
import { useNivaroClient as B } from "../../context.js";
|
|
7
|
+
import { get as K, post as Q } from "../../lib/commands.js";
|
|
8
|
+
import { toastError as V } from "../../lib/error-toast.js";
|
|
9
|
+
import { Button as R } from "../ui/button.js";
|
|
10
|
+
import { Input as G } from "../ui/input.js";
|
|
11
|
+
import { SimpleSelect as H } from "../ui/SimpleSelect.js";
|
|
12
|
+
const I = 5;
|
|
13
|
+
function ne({
|
|
14
14
|
collection: m,
|
|
15
15
|
item: d,
|
|
16
16
|
states: n,
|
|
17
|
-
currentStateId:
|
|
18
|
-
onMoved:
|
|
17
|
+
currentStateId: E,
|
|
18
|
+
onMoved: q,
|
|
19
19
|
openSignal: x = 0,
|
|
20
20
|
standalone: c = !1,
|
|
21
21
|
onCancel: p
|
|
22
22
|
}) {
|
|
23
|
-
var M,
|
|
24
|
-
const f =
|
|
25
|
-
|
|
23
|
+
var M, S, P, $;
|
|
24
|
+
const f = B(), [A, i] = h(c), [u, b] = h(""), [l, v] = h("");
|
|
25
|
+
j(() => {
|
|
26
26
|
x > 0 && i(!0);
|
|
27
27
|
}, [x]);
|
|
28
|
-
const { data:
|
|
28
|
+
const { data: s, isLoading: g } = O({
|
|
29
29
|
queryKey: ["move-state-instance", m, String(d)],
|
|
30
30
|
queryFn: () => f.request(
|
|
31
|
-
|
|
31
|
+
K(`/pipelines/instance/${m}/${encodeURIComponent(String(d))}`)
|
|
32
32
|
),
|
|
33
33
|
enabled: !n
|
|
34
|
-
}), N = n ?? ((M =
|
|
34
|
+
}), N = n ?? ((M = s == null ? void 0 : s.data) == null ? void 0 : M.states) ?? [], y = n ? E ?? null : ((P = (S = s == null ? void 0 : s.data) == null ? void 0 : S.instance) == null ? void 0 : P.current_state) ?? null, F = !n && !g && !(($ = s == null ? void 0 : s.data) != null && $.instance), L = z(
|
|
35
35
|
() => [
|
|
36
36
|
{ value: "", label: "Pick a state" },
|
|
37
37
|
...N.filter((e) => String(e.id).toUpperCase() !== String(y ?? "").toUpperCase()).map((e) => ({ value: String(e.id), label: e.label }))
|
|
38
38
|
],
|
|
39
39
|
[N, y]
|
|
40
|
-
),
|
|
40
|
+
), o = T({
|
|
41
41
|
mutationFn: () => f.request(
|
|
42
|
-
|
|
42
|
+
Q(`/pipelines/instance/${m}/${encodeURIComponent(String(d))}/move-state`, {
|
|
43
43
|
to_state: u,
|
|
44
44
|
reason: l.trim()
|
|
45
45
|
})
|
|
46
46
|
),
|
|
47
47
|
onSuccess: (e) => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
), c || i(!1),
|
|
48
|
+
const r = e == null ? void 0 : e.data;
|
|
49
|
+
W.success(
|
|
50
|
+
r != null && r.ended ? `Moved to ${r.to.label}, then an automatic rule took it to ${r.ended.label}` : `Moved to ${(r == null ? void 0 : r.to.label) ?? "the new state"}`
|
|
51
|
+
), c || i(!1), b(""), v(""), q();
|
|
52
52
|
},
|
|
53
|
-
onError: (e) =>
|
|
54
|
-
}), k = l.trim().length >=
|
|
55
|
-
return
|
|
56
|
-
"
|
|
53
|
+
onError: (e) => V(e, "Could not move it")
|
|
54
|
+
}), k = l.trim().length >= I, w = !!u && k && !o.isPending;
|
|
55
|
+
return A ? F ? /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-500", "data-move-to-state-none": !0, children: "This record has no pipeline to move." }) : /* @__PURE__ */ a(
|
|
56
|
+
"form",
|
|
57
57
|
{
|
|
58
|
-
className: "
|
|
58
|
+
className: "rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card",
|
|
59
59
|
"data-move-to-state-form": !0,
|
|
60
|
+
onSubmit: (e) => {
|
|
61
|
+
e.preventDefault(), w && o.mutate();
|
|
62
|
+
},
|
|
60
63
|
children: [
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ a("div", { className: "flex items-start gap-2.5 border-b border-slate-100 px-4 py-3 dark:border-border/60", children: [
|
|
65
|
+
/* @__PURE__ */ t(C, { className: "mt-0.5 h-4 w-4 shrink-0 text-slate-400" }),
|
|
66
|
+
/* @__PURE__ */ a("div", { className: "min-w-0 space-y-0.5", children: [
|
|
67
|
+
/* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-100", children: "Move to state" }),
|
|
68
|
+
/* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 text-[12px] text-amber-700 dark:text-amber-300", children: [
|
|
69
|
+
/* @__PURE__ */ t(U, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
70
|
+
"Skips the transition: no Fusion or MWF pushes, emails or flows run."
|
|
71
|
+
] })
|
|
72
|
+
] })
|
|
64
73
|
] }),
|
|
65
|
-
/* @__PURE__ */
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
74
|
+
/* @__PURE__ */ a("div", { className: "space-y-3 px-4 py-3.5", children: [
|
|
75
|
+
/* @__PURE__ */ a("div", { className: "flex flex-wrap items-start gap-x-4 gap-y-3", children: [
|
|
76
|
+
/* @__PURE__ */ a("div", { className: "w-full space-y-1.5 sm:w-60", children: [
|
|
77
|
+
/* @__PURE__ */ t("span", { className: "block text-[12px] font-medium text-slate-600 dark:text-slate-300", children: "New state" }),
|
|
78
|
+
/* @__PURE__ */ t(
|
|
79
|
+
H,
|
|
80
|
+
{
|
|
81
|
+
value: u,
|
|
82
|
+
onChange: b,
|
|
83
|
+
options: L,
|
|
84
|
+
ariaLabel: "New state",
|
|
85
|
+
className: "h-8 text-[12.5px]",
|
|
86
|
+
disabled: o.isPending || !n && g
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ a("div", { className: "min-w-0 flex-1 basis-72 space-y-1.5", children: [
|
|
91
|
+
/* @__PURE__ */ t("span", { className: "block text-[12px] font-medium text-slate-600 dark:text-slate-300", children: "Reason" }),
|
|
92
|
+
/* @__PURE__ */ t(
|
|
93
|
+
G,
|
|
94
|
+
{
|
|
95
|
+
value: l,
|
|
96
|
+
onChange: (e) => v(e.target.value),
|
|
97
|
+
placeholder: "Why it moves — saved in the history",
|
|
98
|
+
maxLength: 500,
|
|
99
|
+
disabled: o.isPending,
|
|
100
|
+
className: "h-8 text-[12.5px]",
|
|
101
|
+
"aria-label": "Reason",
|
|
102
|
+
"aria-describedby": "move-state-hint"
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] })
|
|
95
106
|
] }),
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
107
|
+
/* @__PURE__ */ t("p", { id: "move-state-hint", className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: !k && l.length > 0 ? `A few more words, please (${I} characters or more).` : "Automatic rules are checked again afterwards, so the record may move on by itself." }),
|
|
108
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
109
|
+
/* @__PURE__ */ a(
|
|
110
|
+
R,
|
|
111
|
+
{
|
|
112
|
+
type: "submit",
|
|
113
|
+
size: "sm",
|
|
114
|
+
className: "h-8 gap-1.5 bg-nvr-cyan px-3.5 text-[12.5px] text-white hover:bg-nvr-cyan/90",
|
|
115
|
+
disabled: !w,
|
|
116
|
+
"data-move-to-state-submit": !0,
|
|
117
|
+
children: [
|
|
118
|
+
o.isPending && /* @__PURE__ */ t(_, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
119
|
+
"Move"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ t(
|
|
124
|
+
R,
|
|
125
|
+
{
|
|
126
|
+
type: "button",
|
|
127
|
+
size: "sm",
|
|
128
|
+
variant: "ghost",
|
|
129
|
+
className: "h-8 text-[12.5px]",
|
|
130
|
+
onClick: () => c ? p == null ? void 0 : p() : i(!1),
|
|
131
|
+
disabled: o.isPending,
|
|
132
|
+
children: "Cancel"
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
] })
|
|
121
136
|
] })
|
|
122
137
|
]
|
|
123
138
|
}
|
|
124
|
-
) : /* @__PURE__ */
|
|
139
|
+
) : /* @__PURE__ */ a(
|
|
125
140
|
"button",
|
|
126
141
|
{
|
|
127
142
|
type: "button",
|
|
@@ -129,13 +144,13 @@ function re({
|
|
|
129
144
|
onClick: () => i(!0),
|
|
130
145
|
"data-move-to-state-open": !0,
|
|
131
146
|
children: [
|
|
132
|
-
/* @__PURE__ */
|
|
147
|
+
/* @__PURE__ */ t(C, { className: "h-3.5 w-3.5" }),
|
|
133
148
|
"Move to state…"
|
|
134
149
|
]
|
|
135
150
|
}
|
|
136
151
|
);
|
|
137
152
|
}
|
|
138
153
|
export {
|
|
139
|
-
|
|
140
|
-
|
|
154
|
+
I as MOVE_REASON_MIN,
|
|
155
|
+
ne as MoveToStatePanel
|
|
141
156
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { useSyncExternalStore as
|
|
2
|
-
import { useLiveEvent as
|
|
1
|
+
import { useSyncExternalStore as f } from "react";
|
|
2
|
+
import { useLiveEvent as a } from "./live.js";
|
|
3
3
|
let t = null, l = 0;
|
|
4
|
-
const
|
|
4
|
+
const i = /* @__PURE__ */ new Set();
|
|
5
5
|
let r = null;
|
|
6
6
|
function s() {
|
|
7
7
|
l++;
|
|
8
|
-
for (const e of
|
|
8
|
+
for (const e of i) e();
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function m() {
|
|
11
11
|
return `bp${typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID().replace(/-/g, "") : `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 12)}`}`.slice(0, 40);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function S(e, n) {
|
|
14
14
|
r && clearTimeout(r), t = {
|
|
15
15
|
id: e,
|
|
16
16
|
rows: new Map(n.map((o) => [String(o), { status: "queued" }])),
|
|
17
17
|
finished: !1
|
|
18
18
|
}, s();
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function d(e, n = 6e3) {
|
|
21
21
|
if (!(!t || t.id !== e)) {
|
|
22
22
|
t.finished = !0;
|
|
23
|
-
for (const [o,
|
|
24
|
-
(
|
|
23
|
+
for (const [o, u] of t.rows)
|
|
24
|
+
(u.status === "queued" || u.status === "running") && t.rows.set(o, { status: "done" });
|
|
25
25
|
s(), r && clearTimeout(r), r = setTimeout(() => {
|
|
26
26
|
(t == null ? void 0 : t.id) === e && (t = null, s());
|
|
27
27
|
}, n);
|
|
@@ -34,23 +34,27 @@ function c(e) {
|
|
|
34
34
|
const n = t.rows.get(String(e.running));
|
|
35
35
|
(!n || n.status === "queued") && t.rows.set(String(e.running), { status: "running" });
|
|
36
36
|
}
|
|
37
|
+
if (e.finished && !t.finished) {
|
|
38
|
+
d(t.id);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
37
41
|
s();
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
function k() {
|
|
41
|
-
|
|
45
|
+
a("bulk:rows", c, { includeOwn: !0 });
|
|
42
46
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
45
|
-
(n) => (
|
|
47
|
+
function y(e) {
|
|
48
|
+
return f(
|
|
49
|
+
(n) => (i.add(n), () => i.delete(n)),
|
|
46
50
|
() => l,
|
|
47
51
|
() => 0
|
|
48
52
|
), (t == null ? void 0 : t.rows.get(String(e))) ?? null;
|
|
49
53
|
}
|
|
50
54
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
d as endBulkProgress,
|
|
56
|
+
m as newBulkProgressId,
|
|
57
|
+
S as startBulkProgress,
|
|
54
58
|
k as useBulkProgressFeed,
|
|
55
|
-
|
|
59
|
+
y as useBulkRowState
|
|
56
60
|
};
|