@nivaro/react 0.2.49 → 0.2.51
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 +1576 -1555
- package/dist/shared/components/ItemEditForm.js +3156 -3099
- package/dist/shared/components/RecordReadView.js +148 -149
- package/dist/shared/components/bulk/RowPushActions.js +37 -36
- package/dist/shared/components/chat/ChatPanel.js +1053 -993
- package/dist/shared/components/import/DocumentAutofillButton.js +141 -129
- package/dist/shared/components/item-edit/SummaryPanel.js +1 -0
- package/dist/shared/components/panels/ItemActionButtons.js +100 -68
- package/dist/shared/components/panels/ItemActionChoices.js +60 -0
- package/dist/shared/components/ui/dialog.js +11 -11
- package/dist/shared/lib/presence-state.js +43 -13
- package/package.json +1 -1
|
@@ -1,115 +1,147 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { toast as
|
|
7
|
-
import { useNivaroClient as
|
|
8
|
-
import { get as
|
|
9
|
-
import { PushReadinessChip as
|
|
10
|
-
import { Button as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { jsxs as d, Fragment as F, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as B, useQuery as L, useMutation as R } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as _, Play as E, X as M } from "lucide-react";
|
|
4
|
+
import { useState as m } from "react";
|
|
5
|
+
import { createPortal as O } from "react-dom";
|
|
6
|
+
import { toast as x } from "sonner";
|
|
7
|
+
import { useNivaroClient as T } from "../../context.js";
|
|
8
|
+
import { get as z, post as X } from "../../lib/commands.js";
|
|
9
|
+
import { PushReadinessChip as D } from "../integrations/RecordIntegrationPreview.js";
|
|
10
|
+
import { Button as g } from "../ui/button.js";
|
|
11
|
+
import { ItemActionChoiceList as G, itemActionChoiceStep as H } from "./ItemActionChoices.js";
|
|
12
|
+
function re({ collection: r, itemId: s }) {
|
|
13
|
+
var w, Q, K, S, j, A;
|
|
14
|
+
const f = T(), l = B(), [k, u] = m(null), { data: h } = L({
|
|
15
|
+
queryKey: ["item-actions", r, s],
|
|
16
|
+
queryFn: () => f.request(
|
|
17
|
+
z("/item-actions/registered", { collection: r, item: s })
|
|
17
18
|
).then((e) => e.data ?? []),
|
|
18
19
|
staleTime: 5 * 6e4
|
|
19
|
-
}), [t,
|
|
20
|
-
mutationFn: ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
20
|
+
}), [t, p] = m(null), [b, N] = m(""), [y, P] = m(null), [v, q] = m(null), C = R({
|
|
21
|
+
mutationFn: ({
|
|
22
|
+
action: e,
|
|
23
|
+
message: i,
|
|
24
|
+
pick: a
|
|
25
|
+
}) => {
|
|
26
|
+
const o = {};
|
|
27
|
+
return i != null && i.trim() && (o.message = i.trim()), e.choose && a != null && (o[e.choose.key] = a), f.request(
|
|
28
|
+
X(`/item-actions/${e.id}/execute`, {
|
|
29
|
+
collection: r,
|
|
30
|
+
itemId: s,
|
|
31
|
+
...Object.keys(o).length > 0 ? { payload: o } : {}
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
},
|
|
27
35
|
onSuccess: (e) => {
|
|
28
|
-
var
|
|
29
|
-
|
|
36
|
+
var i;
|
|
37
|
+
x.success(((i = e == null ? void 0 : e.data) == null ? void 0 : i.message) ?? "Action completed"), l.invalidateQueries({ queryKey: ["item", r, String(s)] }), l.invalidateQueries({ queryKey: ["erp-submissions", r, String(s)] }), l.invalidateQueries({ queryKey: ["item-actions", r, s] }), l.invalidateQueries({ queryKey: ["addendums", r] }), l.invalidateQueries({ queryKey: ["pipeline-all-owners"] }), l.invalidateQueries({ queryKey: ["o2m-rows"] }), l.invalidateQueries({ queryKey: ["pipeline-instance", r, String(s)] });
|
|
30
38
|
},
|
|
31
|
-
onError: (e, { action:
|
|
32
|
-
const
|
|
33
|
-
|
|
39
|
+
onError: (e, { action: i }) => {
|
|
40
|
+
const a = e == null ? void 0 : e.response;
|
|
41
|
+
x.error((a == null ? void 0 : a.error) ?? `${i.label} failed`, { duration: 12e3 }), l.invalidateQueries({ queryKey: ["erp-submissions", r, String(s)] });
|
|
34
42
|
},
|
|
35
|
-
onSettled: () =>
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
onSettled: () => u(null)
|
|
44
|
+
}), $ = async (e) => {
|
|
45
|
+
let i = null, a = null;
|
|
46
|
+
if (e.choose) {
|
|
47
|
+
u(e.id);
|
|
48
|
+
try {
|
|
49
|
+
const o = await f.request(
|
|
50
|
+
z(`/item-actions/${e.id}/choices`, { collection: r, item: s })
|
|
51
|
+
), c = H(o.data ?? []);
|
|
52
|
+
c.ask ? a = o.data : i = c.value;
|
|
53
|
+
} catch (o) {
|
|
54
|
+
const c = o == null ? void 0 : o.response;
|
|
55
|
+
x.error((c == null ? void 0 : c.error) ?? `${e.label}: could not load the options`), u(null);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
u(null);
|
|
59
|
+
}
|
|
60
|
+
if (e.confirm || a) {
|
|
61
|
+
N(""), P(a), q(i), p(e);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
u(e.id), C.mutate({ action: e, pick: i });
|
|
65
|
+
};
|
|
66
|
+
return !h || h.length === 0 ? null : /* @__PURE__ */ d(F, { children: [
|
|
67
|
+
h.map((e) => /* @__PURE__ */ d("span", { className: "relative inline-flex", children: [
|
|
68
|
+
/* @__PURE__ */ d(
|
|
69
|
+
g,
|
|
41
70
|
{
|
|
42
71
|
type: "button",
|
|
43
72
|
size: "sm",
|
|
44
73
|
variant: e.variant ?? "outline",
|
|
45
74
|
className: "gap-1.5",
|
|
46
|
-
disabled:
|
|
47
|
-
onClick: () =>
|
|
48
|
-
if (e.confirm) {
|
|
49
|
-
h(""), l(e);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
d(e.id), x.mutate({ action: e });
|
|
53
|
-
},
|
|
75
|
+
disabled: k !== null,
|
|
76
|
+
onClick: () => void $(e),
|
|
54
77
|
children: [
|
|
55
|
-
|
|
78
|
+
k === e.id ? /* @__PURE__ */ n(_, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(E, { className: "h-3.5 w-3.5" }),
|
|
56
79
|
e.label
|
|
57
80
|
]
|
|
58
81
|
}
|
|
59
82
|
),
|
|
60
|
-
e.has_preflight && /* @__PURE__ */
|
|
61
|
-
|
|
83
|
+
e.has_preflight && /* @__PURE__ */ n(
|
|
84
|
+
D,
|
|
62
85
|
{
|
|
63
86
|
collection: r,
|
|
64
|
-
itemId: String(
|
|
87
|
+
itemId: String(s),
|
|
65
88
|
itemActionId: e.id,
|
|
66
89
|
label: e.label,
|
|
67
90
|
compact: !0
|
|
68
91
|
}
|
|
69
92
|
)
|
|
70
93
|
] }, e.id)),
|
|
71
|
-
t &&
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
94
|
+
t && O(
|
|
95
|
+
/* @__PURE__ */ n("div", { className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4", children: /* @__PURE__ */ d("div", { className: "w-full max-w-md rounded-lg border border-slate-200 bg-white p-5 shadow-xl dark:border-border dark:bg-card", children: [
|
|
96
|
+
/* @__PURE__ */ d("div", { className: "flex items-start justify-between gap-3", children: [
|
|
97
|
+
/* @__PURE__ */ n("h3", { className: "text-[14px] font-semibold text-slate-900 dark:text-foreground", children: ((w = t.confirm) == null ? void 0 : w.title) ?? t.label }),
|
|
98
|
+
/* @__PURE__ */ n(
|
|
76
99
|
"button",
|
|
77
100
|
{
|
|
78
101
|
type: "button",
|
|
79
|
-
onClick: () =>
|
|
102
|
+
onClick: () => p(null),
|
|
80
103
|
className: "rounded p-1 text-slate-400 hover:text-slate-600",
|
|
81
104
|
"aria-label": "Close",
|
|
82
|
-
children: /* @__PURE__ */
|
|
105
|
+
children: /* @__PURE__ */ n(M, { className: "h-4 w-4" })
|
|
83
106
|
}
|
|
84
107
|
)
|
|
85
108
|
] }),
|
|
86
|
-
((
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
109
|
+
((Q = t.confirm) == null ? void 0 : Q.body) && /* @__PURE__ */ n("p", { className: "mt-2 text-[12.5px] leading-relaxed text-slate-600 dark:text-muted-foreground", children: t.confirm.body }),
|
|
110
|
+
t.choose && y && /* @__PURE__ */ n(
|
|
111
|
+
G,
|
|
112
|
+
{
|
|
113
|
+
choose: t.choose,
|
|
114
|
+
options: y,
|
|
115
|
+
value: v,
|
|
116
|
+
onChange: q
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
((K = t.confirm) == null ? void 0 : K.input) && /* @__PURE__ */ d("div", { className: "mt-3", children: [
|
|
120
|
+
/* @__PURE__ */ n("p", { className: "mb-1 text-[11.5px] font-medium text-slate-500", children: t.confirm.input.label }),
|
|
121
|
+
/* @__PURE__ */ n(
|
|
90
122
|
"textarea",
|
|
91
123
|
{
|
|
92
|
-
value:
|
|
93
|
-
onChange: (e) =>
|
|
124
|
+
value: b,
|
|
125
|
+
onChange: (e) => N(e.target.value),
|
|
94
126
|
placeholder: t.confirm.input.placeholder,
|
|
95
127
|
rows: 3,
|
|
96
128
|
className: "w-full rounded-md border border-slate-200 bg-background px-2.5 py-1.5 text-[12.5px] dark:border-border"
|
|
97
129
|
}
|
|
98
130
|
)
|
|
99
131
|
] }),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
|
|
132
|
+
/* @__PURE__ */ d("div", { className: "mt-4 flex justify-end gap-2", children: [
|
|
133
|
+
/* @__PURE__ */ n(g, { type: "button", size: "sm", variant: "ghost", onClick: () => p(null), children: "Cancel" }),
|
|
134
|
+
/* @__PURE__ */ n(
|
|
135
|
+
g,
|
|
104
136
|
{
|
|
105
137
|
type: "button",
|
|
106
138
|
size: "sm",
|
|
107
|
-
disabled: !!((
|
|
139
|
+
disabled: !!((j = (S = t.confirm) == null ? void 0 : S.input) != null && j.required) && !b.trim() || !!y && v == null,
|
|
108
140
|
onClick: () => {
|
|
109
141
|
const e = t;
|
|
110
|
-
|
|
142
|
+
p(null), u(e.id), C.mutate({ action: e, message: b, pick: v });
|
|
111
143
|
},
|
|
112
|
-
children: ((
|
|
144
|
+
children: ((A = t.confirm) == null ? void 0 : A.confirm_label) ?? t.label
|
|
113
145
|
}
|
|
114
146
|
)
|
|
115
147
|
] })
|
|
@@ -119,5 +151,5 @@ function U({ collection: r, itemId: n }) {
|
|
|
119
151
|
] });
|
|
120
152
|
}
|
|
121
153
|
export {
|
|
122
|
-
|
|
154
|
+
re as ItemActionButtons
|
|
123
155
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { Check as i } from "lucide-react";
|
|
3
|
+
import { cn as n } from "../../lib/utils.js";
|
|
4
|
+
function b(e) {
|
|
5
|
+
return e.length === 0 ? { ask: !1, value: null } : e.length === 1 ? { ask: !1, value: e[0].value } : { ask: !0 };
|
|
6
|
+
}
|
|
7
|
+
function x({
|
|
8
|
+
choose: e,
|
|
9
|
+
options: d,
|
|
10
|
+
value: s,
|
|
11
|
+
onChange: c
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ l("div", { className: "mt-3", "data-item-action-choices": e.key, children: [
|
|
14
|
+
/* @__PURE__ */ t("p", { className: "mb-1 text-[11.5px] font-medium text-slate-500 dark:text-muted-foreground", children: e.label }),
|
|
15
|
+
e.body && /* @__PURE__ */ t("p", { className: "mb-2 text-[12px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: e.body }),
|
|
16
|
+
/* @__PURE__ */ t(
|
|
17
|
+
"fieldset",
|
|
18
|
+
{
|
|
19
|
+
"aria-label": e.label,
|
|
20
|
+
className: "m-0 max-h-64 min-w-0 overflow-y-auto overscroll-contain rounded-md border border-slate-200 p-0 dark:border-border",
|
|
21
|
+
children: d.map((r) => {
|
|
22
|
+
const a = r.value === s;
|
|
23
|
+
return /* @__PURE__ */ l(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
type: "button",
|
|
27
|
+
"aria-pressed": a,
|
|
28
|
+
onClick: () => c(r.value),
|
|
29
|
+
className: n(
|
|
30
|
+
"flex w-full items-start gap-2 border-b border-slate-100 px-2.5 py-2 text-left last:border-b-0 dark:border-border",
|
|
31
|
+
a ? "bg-accent" : "hover:bg-muted"
|
|
32
|
+
),
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ t(
|
|
35
|
+
"span",
|
|
36
|
+
{
|
|
37
|
+
className: n(
|
|
38
|
+
"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border",
|
|
39
|
+
a ? "border-nvr-cyan bg-nvr-cyan text-white" : "border-slate-300 dark:border-border"
|
|
40
|
+
),
|
|
41
|
+
children: a && /* @__PURE__ */ t(i, { className: "h-2.5 w-2.5" })
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ l("span", { className: "min-w-0 flex-1", children: [
|
|
45
|
+
/* @__PURE__ */ t("span", { className: "block truncate text-[12.5px] text-slate-800 dark:text-foreground", children: r.label }),
|
|
46
|
+
r.hint && /* @__PURE__ */ t("span", { className: "block truncate text-[11px] text-slate-500 dark:text-muted-foreground", children: r.hint })
|
|
47
|
+
] })
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
r.value
|
|
51
|
+
);
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
x as ItemActionChoiceList,
|
|
59
|
+
b as itemActionChoiceStep
|
|
60
|
+
};
|
|
@@ -18,7 +18,7 @@ function m({
|
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function b({
|
|
22
22
|
className: t,
|
|
23
23
|
children: e,
|
|
24
24
|
hideClose: i = !1,
|
|
@@ -37,7 +37,7 @@ function D({
|
|
|
37
37
|
...r,
|
|
38
38
|
children: [
|
|
39
39
|
e,
|
|
40
|
-
!i && /* @__PURE__ */ n(o.Close, { className: "absolute right-4 top-2 rounded-lg p-1 text-slate-400 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-nvr-cyan", children: [
|
|
40
|
+
!i && /* @__PURE__ */ n(o.Close, { className: "absolute right-4 top-2 rounded-lg p-1 text-slate-400 hover:text-slate-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan", children: [
|
|
41
41
|
/* @__PURE__ */ a(d, { className: "h-4 w-4" }),
|
|
42
42
|
/* @__PURE__ */ a("span", { className: "sr-only", children: "Close" })
|
|
43
43
|
] })
|
|
@@ -46,13 +46,13 @@ function D({
|
|
|
46
46
|
)
|
|
47
47
|
] });
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function D({ className: t, ...e }) {
|
|
50
50
|
return /* @__PURE__ */ a("div", { className: s("px-6 pt-6 pb-4", t), ...e });
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function v({ className: t, ...e }) {
|
|
53
53
|
return /* @__PURE__ */ a("div", { className: s("px-6 pb-6", t), ...e });
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function h({ className: t, ...e }) {
|
|
56
56
|
return /* @__PURE__ */ a(
|
|
57
57
|
"div",
|
|
58
58
|
{
|
|
@@ -61,7 +61,7 @@ function N({ className: t, ...e }) {
|
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function N({
|
|
65
65
|
className: t,
|
|
66
66
|
...e
|
|
67
67
|
}) {
|
|
@@ -87,11 +87,11 @@ function y({
|
|
|
87
87
|
}
|
|
88
88
|
export {
|
|
89
89
|
g as Dialog,
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
v as DialogBody,
|
|
91
|
+
b as DialogContent,
|
|
92
92
|
y as DialogDescription,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
h as DialogFooter,
|
|
94
|
+
D as DialogHeader,
|
|
95
|
+
N as DialogTitle,
|
|
96
96
|
x as DialogTrigger
|
|
97
97
|
};
|
|
@@ -1,19 +1,49 @@
|
|
|
1
|
-
function
|
|
2
|
-
const t = Math.max(0, Math.floor(
|
|
3
|
-
return
|
|
1
|
+
function $(n) {
|
|
2
|
+
const t = Math.max(0, Math.floor(n.minutes)), e = t >= 60 ? `${Math.floor(t / 60)}h ${t % 60}m` : `${t}m`;
|
|
3
|
+
return n.label ? `stuck on ${n.label} for ${e}` : `stuck for ${e}`;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
if (!
|
|
7
|
-
const t =
|
|
5
|
+
function m(n) {
|
|
6
|
+
if (!n) return null;
|
|
7
|
+
const t = n.split("?")[0].split("/").filter(Boolean);
|
|
8
8
|
if (t.length === 0) return "Home";
|
|
9
|
-
const
|
|
10
|
-
return o.length === 0 ? "Home" : o.map((
|
|
9
|
+
const e = /* @__PURE__ */ new Set(["records", "collections", "p"]), o = t.filter((l) => !e.has(l));
|
|
10
|
+
return o.length === 0 ? "Home" : o.map((l, r) => r === 0 ? l.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()) : l).join(" › ");
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const a = /* @__PURE__ */ new Set(["API", "admin"]);
|
|
13
|
+
function d(n, t, e, o, l) {
|
|
14
|
+
if (!n || !n.startsWith("/") || n.startsWith("//") || /[\\\s]/.test(n)) return null;
|
|
15
|
+
const r = n.split("#")[0], c = /^\/(?:records|collections)\/([A-Za-z0-9_]+)\/([^/?#]+)/.exec(r);
|
|
16
|
+
let s = null;
|
|
17
|
+
c && c[2] !== "new" && o && (s = o(c[1], encodeURIComponent(c[2])));
|
|
18
|
+
const i = (e == null ? void 0 : e.replace(/\/$/, "")) ?? "";
|
|
19
|
+
let u = null;
|
|
20
|
+
try {
|
|
21
|
+
u = i && l ? new URL(i, l).origin : null;
|
|
22
|
+
} catch {
|
|
23
|
+
u = null;
|
|
24
|
+
}
|
|
25
|
+
const f = !!u && u === l;
|
|
26
|
+
return s || (t && a.has(t) ? s = f ? r : i ? `${i}${r}` : null : s = f ? null : r), p(s, l, u);
|
|
27
|
+
}
|
|
28
|
+
function p(n, t, e) {
|
|
29
|
+
if (!n || !t) return null;
|
|
30
|
+
try {
|
|
31
|
+
const o = new URL(n, t);
|
|
32
|
+
return o.protocol !== "http:" && o.protocol !== "https:" ? null : o.origin === t || o.origin === e ? n : null;
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function h(n, t) {
|
|
38
|
+
return /^https?:\/\//i.test(n) ? n : `${typeof window > "u" ? "" : window.location.origin}${n}`;
|
|
39
|
+
}
|
|
40
|
+
function w(n) {
|
|
41
|
+
return n.online ? n.away ? "away" : (n.idle_minutes ?? 0) >= 5 ? "idle" : "online" : "offline";
|
|
14
42
|
}
|
|
15
43
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
44
|
+
h as fullHref,
|
|
45
|
+
d as presencePlaceHref,
|
|
46
|
+
w as presenceWord,
|
|
47
|
+
m as prettyPagePath,
|
|
48
|
+
$ as stuckText
|
|
19
49
|
};
|