@nivaro/react 0.3.71 → 0.3.73
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,26 +1,27 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as n, Fragment as K, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useQueryClient as G, useQuery as J } from "@tanstack/react-query";
|
|
3
3
|
import { ArrowLeft as X, Eye as Y, ExternalLink as Z } from "lucide-react";
|
|
4
|
-
import { useState as L, useCallback as
|
|
5
|
-
import { useNivaroClient as ee, useItemNavigation as te, useDrilldownViews as le, DrilldownContext as
|
|
4
|
+
import { useState as L, useCallback as j, useMemo as P, Suspense as q, lazy as E } from "react";
|
|
5
|
+
import { useNivaroClient as ee, useItemNavigation as te, useDrilldownViews as le, DrilldownContext as b } from "../context.js";
|
|
6
6
|
import { get as re } from "../lib/commands.js";
|
|
7
7
|
import { usePresence as oe } from "../lib/presence-hooks.js";
|
|
8
8
|
import { titleCase as ne } from "../lib/utils.js";
|
|
9
9
|
import { DesignCanvas as ae } from "./layout-editor/design-canvas.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
10
|
+
import { ItemActionButtons as ie } from "./panels/ItemActionButtons.js";
|
|
11
|
+
import { Sheet as ce, SheetContent as de, SheetHeader as se, SheetTitle as me } from "./ui/sheet.js";
|
|
12
|
+
const ue = E(() => import("./ItemEditForm.js").then((a) => ({ default: a.ItemEditForm }))), F = E(
|
|
13
|
+
() => import("./RecordReadView.js").then((a) => ({ default: a.RecordReadView }))
|
|
14
|
+
), y = /* @__PURE__ */ t("div", { className: "space-y-2 px-4 py-3", children: [0, 1, 2, 3, 4, 5].map((a) => /* @__PURE__ */ t(
|
|
14
15
|
"div",
|
|
15
16
|
{
|
|
16
17
|
className: "h-8 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]"
|
|
17
18
|
},
|
|
18
|
-
|
|
19
|
+
a
|
|
19
20
|
)) });
|
|
20
|
-
function
|
|
21
|
-
collection:
|
|
22
|
-
itemId:
|
|
23
|
-
layoutId:
|
|
21
|
+
function Ne({
|
|
22
|
+
collection: a,
|
|
23
|
+
itemId: W,
|
|
24
|
+
layoutId: A,
|
|
24
25
|
rootLayoutSlug: w,
|
|
25
26
|
width: p,
|
|
26
27
|
title: Q,
|
|
@@ -32,19 +33,19 @@ function ke({
|
|
|
32
33
|
onOpenRecord: g
|
|
33
34
|
}) {
|
|
34
35
|
var R;
|
|
35
|
-
const
|
|
36
|
-
{ collection:
|
|
37
|
-
]),
|
|
36
|
+
const B = G(), O = ee(), { open: V, urlFor: z } = te(), [H, k] = L([
|
|
37
|
+
{ collection: a, itemId: W, layoutId: A, width: p, title: Q }
|
|
38
|
+
]), d = x != null, i = d && x.length ? x : H, e = l ? i[0] : i[i.length - 1], I = j(
|
|
38
39
|
(r) => {
|
|
39
|
-
|
|
40
|
+
d ? u == null || u(r) : k((f) => [...f, r]);
|
|
40
41
|
},
|
|
41
|
-
[
|
|
42
|
-
), N =
|
|
43
|
-
|
|
44
|
-
}, [
|
|
42
|
+
[d, u]
|
|
43
|
+
), N = j(() => {
|
|
44
|
+
d ? h == null || h() : k((r) => r.slice(0, -1));
|
|
45
|
+
}, [d, h]), { viewers: c } = oe(
|
|
45
46
|
l ? null : e.collection,
|
|
46
47
|
l ? null : e.itemId
|
|
47
|
-
), v = P(() => l ? null : { open: I }, [l, I]),
|
|
48
|
+
), v = P(() => l ? null : { open: I }, [l, I]), M = le(), s = l ? null : M[e.collection] ?? null, m = !l && i.length === 1 && !!w, { data: T, isLoading: U } = J({
|
|
48
49
|
queryKey: ["drilldown-layout", e.collection, e.layoutId ?? null],
|
|
49
50
|
enabled: !m && !l,
|
|
50
51
|
queryFn: () => O.request(
|
|
@@ -56,8 +57,8 @@ function ke({
|
|
|
56
57
|
}), o = l ? {
|
|
57
58
|
...l.layout,
|
|
58
59
|
layout: l.layout.layout ?? { id: 0, name: "", slug: null }
|
|
59
|
-
} :
|
|
60
|
-
/* @__PURE__ */
|
|
60
|
+
} : T, S = m ? w ?? void 0 : (o == null ? void 0 : o.layout.slug) ?? void 0, C = (R = o == null ? void 0 : o.layout) == null ? void 0 : R.sheet_width, D = /* @__PURE__ */ n(K, { children: [
|
|
61
|
+
/* @__PURE__ */ n("span", { className: "flex min-w-0 items-center gap-1.5", children: [
|
|
61
62
|
i.length > 1 && /* @__PURE__ */ t(
|
|
62
63
|
"button",
|
|
63
64
|
{
|
|
@@ -68,12 +69,12 @@ function ke({
|
|
|
68
69
|
children: /* @__PURE__ */ t(X, { className: "h-4 w-4" })
|
|
69
70
|
}
|
|
70
71
|
),
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: [
|
|
72
73
|
ne(e.collection),
|
|
73
74
|
!m && o ? ` · ${o.layout.name}` : ""
|
|
74
75
|
] })
|
|
75
76
|
] }),
|
|
76
|
-
!l && c.length > 0 && /* @__PURE__ */
|
|
77
|
+
!l && c.length > 0 && /* @__PURE__ */ n(
|
|
77
78
|
"span",
|
|
78
79
|
{
|
|
79
80
|
className: "ml-auto flex min-w-0 items-center gap-1 text-[11px] font-normal text-slate-500 dark:text-slate-400",
|
|
@@ -87,7 +88,7 @@ function ke({
|
|
|
87
88
|
),
|
|
88
89
|
!l && // A real link (army 11 Q1-4): Cmd/Ctrl/middle-click opens the record in a new
|
|
89
90
|
// tab and keeps this list where it is; a plain click goes through the host.
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ n(
|
|
91
92
|
"a",
|
|
92
93
|
{
|
|
93
94
|
href: z({ collection: e.collection, itemId: e.itemId }),
|
|
@@ -104,32 +105,42 @@ function ke({
|
|
|
104
105
|
]
|
|
105
106
|
}
|
|
106
107
|
)
|
|
107
|
-
] }), $ = /* @__PURE__ */ t("div", { className: "nvr-tab-enter flex min-h-0 flex-1 flex-col overflow-hidden", children:
|
|
108
|
+
] }), $ = /* @__PURE__ */ t("div", { className: "nvr-tab-enter flex min-h-0 flex-1 flex-col overflow-hidden", children: s ? /* @__PURE__ */ t(b.Provider, { value: v, children: s.render({ itemId: String(e.itemId) }) }) : U && !m ? y : !m && (o == null ? void 0 : o.layout.display_mode) === "read" ? (
|
|
108
109
|
// Read-only presentation — definition grids + tabbed child lists,
|
|
109
110
|
// no form inputs. Editing lives on the full record page.
|
|
110
|
-
/* @__PURE__ */ t(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
/* @__PURE__ */ t(b.Provider, { value: v, children: /* @__PURE__ */ t(q, { fallback: y, children: l ? /* @__PURE__ */ t(F, { collection: e.collection, design: l }) : /* @__PURE__ */ n(K, { children: [
|
|
112
|
+
/* @__PURE__ */ t("div", { className: "flex shrink-0 flex-wrap items-center justify-end gap-2 border-b border-slate-200 px-4 py-2 empty:hidden dark:border-border", children: /* @__PURE__ */ t(
|
|
113
|
+
ie,
|
|
114
|
+
{
|
|
115
|
+
collection: e.collection,
|
|
116
|
+
itemId: String(e.itemId)
|
|
117
|
+
}
|
|
118
|
+
) }),
|
|
119
|
+
/* @__PURE__ */ t(
|
|
120
|
+
F,
|
|
121
|
+
{
|
|
122
|
+
collection: e.collection,
|
|
123
|
+
itemId: e.itemId,
|
|
124
|
+
layoutData: o
|
|
125
|
+
},
|
|
126
|
+
`${e.collection}:${e.itemId}:read`
|
|
127
|
+
)
|
|
128
|
+
] }) }) })
|
|
129
|
+
) : /* @__PURE__ */ t(b.Provider, { value: v, children: /* @__PURE__ */ t(q, { fallback: y, children: /* @__PURE__ */ t(
|
|
130
|
+
ue,
|
|
121
131
|
{
|
|
122
132
|
collection: e.collection,
|
|
123
133
|
itemId: e.itemId,
|
|
124
134
|
layoutSlug: S,
|
|
125
135
|
onSaved: () => {
|
|
126
|
-
|
|
136
|
+
B.invalidateQueries({ queryKey: ["queue-items"] });
|
|
127
137
|
},
|
|
128
|
-
design: l
|
|
138
|
+
design: l,
|
|
139
|
+
showItemActions: !l
|
|
129
140
|
},
|
|
130
141
|
`${e.collection}:${e.itemId}:${S ?? "default"}`
|
|
131
142
|
) }) }) });
|
|
132
|
-
return l ? /* @__PURE__ */ t(ae, { design: l.context, onRefusedWrite: l.onRefusedWrite, children: /* @__PURE__ */
|
|
143
|
+
return l ? /* @__PURE__ */ t(ae, { design: l.context, onRefusedWrite: l.onRefusedWrite, children: /* @__PURE__ */ n(
|
|
133
144
|
"div",
|
|
134
145
|
{
|
|
135
146
|
"data-design-sheet": !0,
|
|
@@ -140,24 +151,24 @@ function ke({
|
|
|
140
151
|
$
|
|
141
152
|
]
|
|
142
153
|
}
|
|
143
|
-
) }) : /* @__PURE__ */ t(
|
|
144
|
-
|
|
154
|
+
) }) : /* @__PURE__ */ t(ce, { open: !0, onOpenChange: (r) => !r && _(), children: /* @__PURE__ */ n(
|
|
155
|
+
de,
|
|
145
156
|
{
|
|
146
157
|
className: "flex flex-col gap-0 overflow-hidden p-0",
|
|
147
158
|
style: {
|
|
148
|
-
width: (
|
|
159
|
+
width: (s == null ? void 0 : s.width) ?? e.width ?? C ?? p ?? 640,
|
|
149
160
|
maxWidth: "96vw"
|
|
150
161
|
},
|
|
151
162
|
onEscapeKeyDown: i.length > 1 ? (r) => {
|
|
152
163
|
r.preventDefault(), N();
|
|
153
164
|
} : void 0,
|
|
154
165
|
children: [
|
|
155
|
-
/* @__PURE__ */ t(se, { className: "shrink-0 border-b border-slate-200 bg-slate-50 px-4 py-2 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t(
|
|
166
|
+
/* @__PURE__ */ t(se, { className: "shrink-0 border-b border-slate-200 bg-slate-50 px-4 py-2 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t(me, { className: "flex items-center justify-between gap-2 pr-6 text-[12px] font-medium text-slate-500 dark:text-muted-foreground", children: D }) }),
|
|
156
167
|
$
|
|
157
168
|
]
|
|
158
169
|
}
|
|
159
170
|
) });
|
|
160
171
|
}
|
|
161
172
|
export {
|
|
162
|
-
|
|
173
|
+
Ne as RecordDrilldownSheet
|
|
163
174
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { jsxs as d,
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useState as m } from "react";
|
|
5
|
-
import { createPortal as
|
|
1
|
+
import { jsxs as d, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as F, useQuery as L, useMutation as _ } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as E, Play as M, X as O } from "lucide-react";
|
|
4
|
+
import { useState as m, useRef as T } from "react";
|
|
5
|
+
import { createPortal as X } from "react-dom";
|
|
6
6
|
import { toast as x } from "sonner";
|
|
7
|
-
import { useNivaroClient as
|
|
8
|
-
import { get as
|
|
9
|
-
import { PushReadinessChip as
|
|
7
|
+
import { useNivaroClient as D } from "../../context.js";
|
|
8
|
+
import { get as R, post as G } from "../../lib/commands.js";
|
|
9
|
+
import { PushReadinessChip as H } from "../integrations/RecordIntegrationPreview.js";
|
|
10
10
|
import { Button as g } from "../ui/button.js";
|
|
11
|
-
import { ItemActionChoiceList as
|
|
12
|
-
function
|
|
13
|
-
var
|
|
14
|
-
const f =
|
|
11
|
+
import { ItemActionChoiceList as J, itemActionChoiceStep as U } from "./ItemActionChoices.js";
|
|
12
|
+
function se({ collection: r, itemId: s }) {
|
|
13
|
+
var Q, K, S, j, A, z, P;
|
|
14
|
+
const f = D(), l = F(), [N, c] = m(null), k = T(null), { data: h } = L({
|
|
15
15
|
queryKey: ["item-actions", r, s],
|
|
16
16
|
queryFn: () => f.request(
|
|
17
|
-
|
|
17
|
+
R("/item-actions/registered", { collection: r, item: s })
|
|
18
18
|
).then((e) => e.data ?? []),
|
|
19
19
|
staleTime: 5 * 6e4
|
|
20
|
-
}), [t, p] = m(null), [b,
|
|
20
|
+
}), [t, p] = m(null), [b, q] = m(""), [y, $] = m(null), [v, C] = m(null), w = _({
|
|
21
21
|
mutationFn: ({
|
|
22
22
|
action: e,
|
|
23
23
|
message: i,
|
|
@@ -25,7 +25,7 @@ function re({ collection: r, itemId: s }) {
|
|
|
25
25
|
}) => {
|
|
26
26
|
const o = {};
|
|
27
27
|
return i != null && i.trim() && (o.message = i.trim()), e.choose && a != null && (o[e.choose.key] = a), f.request(
|
|
28
|
-
|
|
28
|
+
G(`/item-actions/${e.id}/execute`, {
|
|
29
29
|
collection: r,
|
|
30
30
|
itemId: s,
|
|
31
31
|
...Object.keys(o).length > 0 ? { payload: o } : {}
|
|
@@ -40,30 +40,30 @@ function re({ collection: r, itemId: s }) {
|
|
|
40
40
|
const a = e == null ? void 0 : e.response;
|
|
41
41
|
x.error((a == null ? void 0 : a.error) ?? `${i.label} failed`, { duration: 12e3 }), l.invalidateQueries({ queryKey: ["erp-submissions", r, String(s)] });
|
|
42
42
|
},
|
|
43
|
-
onSettled: () =>
|
|
44
|
-
}),
|
|
43
|
+
onSettled: () => c(null)
|
|
44
|
+
}), B = async (e) => {
|
|
45
45
|
let i = null, a = null;
|
|
46
46
|
if (e.choose) {
|
|
47
|
-
|
|
47
|
+
c(e.id);
|
|
48
48
|
try {
|
|
49
49
|
const o = await f.request(
|
|
50
|
-
|
|
51
|
-
),
|
|
52
|
-
|
|
50
|
+
R(`/item-actions/${e.id}/choices`, { collection: r, item: s })
|
|
51
|
+
), u = U(o.data ?? []);
|
|
52
|
+
u.ask ? a = o.data : i = u.value;
|
|
53
53
|
} catch (o) {
|
|
54
|
-
const
|
|
55
|
-
x.error((
|
|
54
|
+
const u = o == null ? void 0 : o.response;
|
|
55
|
+
x.error((u == null ? void 0 : u.error) ?? `${e.label}: could not load the options`), c(null);
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
c(null);
|
|
59
59
|
}
|
|
60
60
|
if (e.confirm || a) {
|
|
61
|
-
|
|
61
|
+
q(""), $(a), C(i), p(e);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
c(e.id), w.mutate({ action: e, pick: i });
|
|
65
65
|
};
|
|
66
|
-
return !h || h.length === 0 ? null : /* @__PURE__ */ d(
|
|
66
|
+
return !h || h.length === 0 ? null : /* @__PURE__ */ d("span", { ref: k, className: "contents", children: [
|
|
67
67
|
h.map((e) => /* @__PURE__ */ d("span", { className: "relative inline-flex", children: [
|
|
68
68
|
/* @__PURE__ */ d(
|
|
69
69
|
g,
|
|
@@ -72,16 +72,16 @@ function re({ collection: r, itemId: s }) {
|
|
|
72
72
|
size: "sm",
|
|
73
73
|
variant: e.variant ?? "outline",
|
|
74
74
|
className: "gap-1.5",
|
|
75
|
-
disabled:
|
|
76
|
-
onClick: () => void
|
|
75
|
+
disabled: N !== null,
|
|
76
|
+
onClick: () => void B(e),
|
|
77
77
|
children: [
|
|
78
|
-
|
|
78
|
+
N === e.id ? /* @__PURE__ */ n(E, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(M, { className: "h-3.5 w-3.5" }),
|
|
79
79
|
e.label
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
82
|
),
|
|
83
83
|
e.has_preflight && /* @__PURE__ */ n(
|
|
84
|
-
|
|
84
|
+
H,
|
|
85
85
|
{
|
|
86
86
|
collection: r,
|
|
87
87
|
itemId: String(s),
|
|
@@ -91,10 +91,10 @@ function re({ collection: r, itemId: s }) {
|
|
|
91
91
|
}
|
|
92
92
|
)
|
|
93
93
|
] }, e.id)),
|
|
94
|
-
t &&
|
|
94
|
+
t && X(
|
|
95
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
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: ((
|
|
97
|
+
/* @__PURE__ */ n("h3", { className: "text-[14px] font-semibold text-slate-900 dark:text-foreground", children: ((Q = t.confirm) == null ? void 0 : Q.title) ?? t.label }),
|
|
98
98
|
/* @__PURE__ */ n(
|
|
99
99
|
"button",
|
|
100
100
|
{
|
|
@@ -102,27 +102,27 @@ function re({ collection: r, itemId: s }) {
|
|
|
102
102
|
onClick: () => p(null),
|
|
103
103
|
className: "rounded p-1 text-slate-400 hover:text-slate-600",
|
|
104
104
|
"aria-label": "Close",
|
|
105
|
-
children: /* @__PURE__ */ n(
|
|
105
|
+
children: /* @__PURE__ */ n(O, { className: "h-4 w-4" })
|
|
106
106
|
}
|
|
107
107
|
)
|
|
108
108
|
] }),
|
|
109
|
-
((
|
|
109
|
+
((K = t.confirm) == null ? void 0 : K.body) && /* @__PURE__ */ n("p", { className: "mt-2 text-[12.5px] leading-relaxed text-slate-600 dark:text-muted-foreground", children: t.confirm.body }),
|
|
110
110
|
t.choose && y && /* @__PURE__ */ n(
|
|
111
|
-
|
|
111
|
+
J,
|
|
112
112
|
{
|
|
113
113
|
choose: t.choose,
|
|
114
114
|
options: y,
|
|
115
115
|
value: v,
|
|
116
|
-
onChange:
|
|
116
|
+
onChange: C
|
|
117
117
|
}
|
|
118
118
|
),
|
|
119
|
-
((
|
|
119
|
+
((S = t.confirm) == null ? void 0 : S.input) && /* @__PURE__ */ d("div", { className: "mt-3", children: [
|
|
120
120
|
/* @__PURE__ */ n("p", { className: "mb-1 text-[11.5px] font-medium text-slate-500", children: t.confirm.input.label }),
|
|
121
121
|
/* @__PURE__ */ n(
|
|
122
122
|
"textarea",
|
|
123
123
|
{
|
|
124
124
|
value: b,
|
|
125
|
-
onChange: (e) =>
|
|
125
|
+
onChange: (e) => q(e.target.value),
|
|
126
126
|
placeholder: t.confirm.input.placeholder,
|
|
127
127
|
rows: 3,
|
|
128
128
|
className: "w-full rounded-md border border-slate-200 bg-background px-2.5 py-1.5 text-[12.5px] dark:border-border"
|
|
@@ -136,20 +136,20 @@ function re({ collection: r, itemId: s }) {
|
|
|
136
136
|
{
|
|
137
137
|
type: "button",
|
|
138
138
|
size: "sm",
|
|
139
|
-
disabled: !!((
|
|
139
|
+
disabled: !!((A = (j = t.confirm) == null ? void 0 : j.input) != null && A.required) && !b.trim() || !!y && v == null,
|
|
140
140
|
onClick: () => {
|
|
141
141
|
const e = t;
|
|
142
|
-
p(null),
|
|
142
|
+
p(null), c(e.id), w.mutate({ action: e, message: b, pick: v });
|
|
143
143
|
},
|
|
144
|
-
children: ((
|
|
144
|
+
children: ((z = t.confirm) == null ? void 0 : z.confirm_label) ?? t.label
|
|
145
145
|
}
|
|
146
146
|
)
|
|
147
147
|
] })
|
|
148
148
|
] }) }),
|
|
149
|
-
document.body
|
|
149
|
+
((P = k.current) == null ? void 0 : P.closest('[role="dialog"]')) ?? document.body
|
|
150
150
|
)
|
|
151
151
|
] });
|
|
152
152
|
}
|
|
153
153
|
export {
|
|
154
|
-
|
|
154
|
+
se as ItemActionButtons
|
|
155
155
|
};
|