@nivaro/react 0.3.20 → 0.3.22
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 +11 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/shared/components/CollectionBrowserView.js +2668 -2613
- package/dist/shared/components/ItemEditForm.js +1501 -1480
- package/dist/shared/components/QueryTable.js +268 -239
- package/dist/shared/components/bulk/PushBulkButtons.js +17 -17
- package/dist/shared/components/bulk/RowPushActions.js +45 -35
- package/dist/shared/components/chat/ChatPanel.js +258 -251
- package/dist/shared/components/help-videos/viewer/HelpVideoButton.js +106 -99
- package/dist/shared/components/item-edit/RecordHeaderActions.js +140 -0
- package/dist/shared/components/item-edit/UserChip.js +1 -1
- package/dist/shared/components/queue/QueueWorklist.js +1026 -1006
- package/package.json +1 -1
- package/styles.css +10 -0
|
@@ -9,8 +9,8 @@ import { useHelpVideoRecording as te, RECORDING_BUSY as oe } from "../recorder/H
|
|
|
9
9
|
import { useHelpVideoUpload as re } from "../upload/HelpVideoUpload.js";
|
|
10
10
|
import { registerHelpVideoPage as ne } from "../walk/store.js";
|
|
11
11
|
import { collectPageLabels as ie } from "../walk/target.js";
|
|
12
|
-
import { showButton as se, isGettingReady as q, progressLabel as
|
|
13
|
-
import { LazyHelpVideoSheet as
|
|
12
|
+
import { showButton as se, isGettingReady as q, progressLabel as le, listMeta as ae } from "./format.js";
|
|
13
|
+
import { LazyHelpVideoSheet as de } from "./LazyHelpVideoSheet.js";
|
|
14
14
|
import { useHelpVideosPath as ce } from "./useHelpVideosPath.js";
|
|
15
15
|
import { RECORD_UNSUPPORTED as ue } from "../recorder/RecorderStatus.js";
|
|
16
16
|
const s = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan motion-reduce:transition-none", me = 3e3;
|
|
@@ -22,9 +22,9 @@ function $e({
|
|
|
22
22
|
compact: y
|
|
23
23
|
}) {
|
|
24
24
|
var $, _, H;
|
|
25
|
-
const N = z(), w = W(), R = ce(),
|
|
25
|
+
const N = z(), w = W(), R = ce(), a = Z({ collection: m, item: B, page: o }), [D, l] = k(!1), [C, p] = k(null), f = te(), [U, x] = k(!1), b = ee(), d = O(null), P = Y(), g = O(N);
|
|
26
26
|
g.current = N;
|
|
27
|
-
const r = (($ =
|
|
27
|
+
const r = (($ = a.data) == null ? void 0 : $.data) ?? [], c = !!((_ = a.data) != null && _.can_author);
|
|
28
28
|
A(() => o ? ne(o) : void 0, [o]), A(() => {
|
|
29
29
|
if (o && c) {
|
|
30
30
|
S(g.current).registerPage(o, h ?? o).catch(() => null);
|
|
@@ -35,14 +35,14 @@ function $e({
|
|
|
35
35
|
return () => window.clearTimeout(e);
|
|
36
36
|
}
|
|
37
37
|
}, [o, h, c]);
|
|
38
|
-
const j = !!
|
|
38
|
+
const j = !!a.data && se(r.length, c), u = r.filter(
|
|
39
39
|
(e) => {
|
|
40
40
|
var i;
|
|
41
41
|
return e.required && !((i = e.my_progress) != null && i.completed) && !q(e);
|
|
42
42
|
}
|
|
43
|
-
).length, V = m ? [{ kind: "collection", key: m, state_key: ((H =
|
|
43
|
+
).length, V = m ? [{ kind: "collection", key: m, state_key: ((H = a.data) == null ? void 0 : H.state) ?? null }] : o ? [{ kind: "page", key: o, state_key: null }] : [], v = re({
|
|
44
44
|
contexts: V,
|
|
45
|
-
host: J(
|
|
45
|
+
host: J(d.current) ?? null,
|
|
46
46
|
onDone: (e) => w.navigate(R(`?edit=${e.id}`))
|
|
47
47
|
});
|
|
48
48
|
return /* @__PURE__ */ n(L, { children: [
|
|
@@ -51,13 +51,13 @@ function $e({
|
|
|
51
51
|
{
|
|
52
52
|
open: D,
|
|
53
53
|
onOpenChange: (e) => {
|
|
54
|
-
|
|
54
|
+
l(e), e || x(!1);
|
|
55
55
|
},
|
|
56
56
|
children: [
|
|
57
57
|
/* @__PURE__ */ t(Q, { asChild: !0, children: /* @__PURE__ */ n(
|
|
58
58
|
"button",
|
|
59
59
|
{
|
|
60
|
-
ref:
|
|
60
|
+
ref: d,
|
|
61
61
|
type: "button",
|
|
62
62
|
"aria-label": r.length ? `Videos for this screen (${r.length}${u ? `, ${u} required` : ""})` : "Record a video for this screen",
|
|
63
63
|
title: r.length ? "Videos about this screen" : "Record a video for this screen",
|
|
@@ -78,106 +78,113 @@ function $e({
|
|
|
78
78
|
]
|
|
79
79
|
}
|
|
80
80
|
) }),
|
|
81
|
-
/* @__PURE__ */ n(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
children:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
81
|
+
/* @__PURE__ */ n(
|
|
82
|
+
X,
|
|
83
|
+
{
|
|
84
|
+
align: "end",
|
|
85
|
+
className: "flex max-h-[min(70vh,var(--radix-popover-content-available-height))] w-[340px] flex-col p-1.5 text-[13px]",
|
|
86
|
+
children: [
|
|
87
|
+
r.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-muted-foreground", children: "No videos for this screen yet. Record one to show people how it works." }),
|
|
88
|
+
/* @__PURE__ */ t("ul", { className: "-mr-1 min-h-0 flex-1 overflow-y-auto overscroll-contain pr-1", children: r.map((e) => {
|
|
89
|
+
const i = le(e), E = ae(e), I = q(e);
|
|
90
|
+
return /* @__PURE__ */ t("li", { children: /* @__PURE__ */ n(
|
|
91
|
+
"button",
|
|
92
|
+
{
|
|
93
|
+
type: "button",
|
|
94
|
+
className: `flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted ${s}`,
|
|
95
|
+
onClick: () => {
|
|
96
|
+
l(!1), p(e.id);
|
|
97
|
+
},
|
|
98
|
+
"data-hv-pick": e.id,
|
|
99
|
+
children: [
|
|
100
|
+
I ? /* @__PURE__ */ t(F, { className: "h-4 w-4 shrink-0 text-muted-foreground" }) : i.done ? /* @__PURE__ */ t(G, { className: "h-4 w-4 shrink-0 text-emerald-600 dark:text-emerald-400" }) : /* @__PURE__ */ t(M, { className: "h-4 w-4 shrink-0 text-[#2563eb] dark:text-sky-300" }),
|
|
101
|
+
/* @__PURE__ */ n("span", { className: "min-w-0 flex-1", children: [
|
|
102
|
+
/* @__PURE__ */ t("span", { className: "block truncate font-medium", children: e.title }),
|
|
103
|
+
/* @__PURE__ */ t(
|
|
104
|
+
"span",
|
|
105
|
+
{
|
|
106
|
+
className: `block text-[12px] ${E.overdue ? "text-rose-700 dark:text-rose-300" : "text-muted-foreground"}`,
|
|
107
|
+
children: E.text
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
] })
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
) }, e.id);
|
|
114
|
+
}) }),
|
|
115
|
+
/* @__PURE__ */ n("div", { className: "mt-1 flex shrink-0 flex-wrap items-start gap-x-3 gap-y-1 border-t border-border px-2 pt-1.5", children: [
|
|
116
|
+
/* @__PURE__ */ t(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
type: "button",
|
|
120
|
+
className: `rounded text-[12px] text-muted-foreground hover:underline ${s}`,
|
|
121
|
+
onClick: () => {
|
|
122
|
+
l(!1), w.navigate(R());
|
|
123
|
+
},
|
|
124
|
+
children: "All videos"
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
c && /* @__PURE__ */ n("div", { className: "ml-auto flex flex-col items-end", children: [
|
|
128
|
+
/* @__PURE__ */ t(
|
|
129
|
+
"button",
|
|
130
|
+
{
|
|
131
|
+
type: "button",
|
|
132
|
+
disabled: !b,
|
|
133
|
+
"aria-describedby": b ? void 0 : P,
|
|
134
|
+
className: `rounded text-[12px] font-medium text-[#2563eb] hover:underline disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:no-underline dark:text-sky-300 ${s}`,
|
|
135
|
+
onClick: () => {
|
|
136
|
+
f.start({ contexts: V, from: d.current }) ? (x(!1), l(!1)) : x(!0);
|
|
137
|
+
},
|
|
138
|
+
"data-hv-record-here": !0,
|
|
139
|
+
children: "Record one for this screen"
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ t(
|
|
143
|
+
"button",
|
|
144
|
+
{
|
|
145
|
+
type: "button",
|
|
146
|
+
disabled: v.busy,
|
|
147
|
+
className: `mt-0.5 rounded text-[12px] font-medium text-[#2563eb] hover:underline disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:no-underline dark:text-sky-300 ${s}`,
|
|
148
|
+
onClick: () => {
|
|
149
|
+
v.pick(), l(!1);
|
|
150
|
+
},
|
|
151
|
+
"data-hv-upload-here": !0,
|
|
152
|
+
children: "Upload a video"
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
!b && /* @__PURE__ */ t(
|
|
156
|
+
"p",
|
|
157
|
+
{
|
|
158
|
+
id: P,
|
|
159
|
+
className: "mt-0.5 max-w-[220px] text-right text-[12px] text-muted-foreground",
|
|
160
|
+
children: ue
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
U && f.active && /* @__PURE__ */ t(
|
|
164
|
+
"p",
|
|
165
|
+
{
|
|
166
|
+
role: "status",
|
|
167
|
+
className: "mt-0.5 max-w-[220px] text-right text-[12px] text-rose-700 dark:text-rose-300",
|
|
168
|
+
children: oe
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
] })
|
|
172
|
+
] })
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
)
|
|
169
176
|
]
|
|
170
177
|
}
|
|
171
178
|
),
|
|
172
179
|
/* @__PURE__ */ t(
|
|
173
|
-
|
|
180
|
+
de,
|
|
174
181
|
{
|
|
175
182
|
videoId: C,
|
|
176
183
|
open: !!C,
|
|
177
184
|
onOpenChange: (e) => !e && p(null),
|
|
178
185
|
upNext: r,
|
|
179
186
|
onPick: p,
|
|
180
|
-
returnFocusRef:
|
|
187
|
+
returnFocusRef: d
|
|
181
188
|
}
|
|
182
189
|
),
|
|
183
190
|
f.fallback,
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsx as i, Fragment as w, jsxs as f } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as v, useQueryClient as q, useMutation as R } from "@tanstack/react-query";
|
|
3
|
+
import { Play as C, Pause as N, Zap as $ } from "lucide-react";
|
|
4
|
+
import { useMemo as b, useState as F } from "react";
|
|
5
|
+
import { toast as p } from "sonner";
|
|
6
|
+
import { useNivaroClient as x } from "../../context.js";
|
|
7
|
+
import { get as j, post as y } from "../../lib/commands.js";
|
|
8
|
+
import { userErrorMessage as A } from "../../lib/safe-error.js";
|
|
9
|
+
import { cn as S } from "../../lib/utils.js";
|
|
10
|
+
import { useAvailableBulkActions as B, guardMatches as P } from "../bulk/BulkActionButtons.js";
|
|
11
|
+
import { Button as k } from "../ui/button.js";
|
|
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
|
+
import { Textarea as J } from "../ui/textarea.js";
|
|
14
|
+
import { invalidateRecordQueries as K } from "./RecordLiveSync.js";
|
|
15
|
+
function ie(e, n, t) {
|
|
16
|
+
const h = x(), m = !!n && n !== "new", { data: u } = B(m ? [e] : []), d = b(
|
|
17
|
+
() => ((u == null ? void 0 : u[e]) ?? []).filter(
|
|
18
|
+
(o) => o.header === !0 && (o.kind === "update_fields" || o.kind === "transition")
|
|
19
|
+
),
|
|
20
|
+
[u, e]
|
|
21
|
+
), s = b(() => {
|
|
22
|
+
const o = /* @__PURE__ */ new Set();
|
|
23
|
+
for (const a of d)
|
|
24
|
+
for (const r of a.guard ?? [])
|
|
25
|
+
r && typeof r.field == "string" && !(t && r.field in t) && o.add(r.field);
|
|
26
|
+
return [...o].sort();
|
|
27
|
+
}, [d, t]), { data: l } = v({
|
|
28
|
+
queryKey: ["record-header-action-guard", e, String(n), s.join(",")],
|
|
29
|
+
queryFn: () => h.request(
|
|
30
|
+
j(`/items/${encodeURIComponent(e)}/${encodeURIComponent(String(n))}`, {
|
|
31
|
+
fields: s.join(",")
|
|
32
|
+
})
|
|
33
|
+
).then((o) => o.data ?? {}).catch(() => ({})),
|
|
34
|
+
enabled: m && s.length > 0,
|
|
35
|
+
staleTime: 0
|
|
36
|
+
});
|
|
37
|
+
return b(() => {
|
|
38
|
+
if (s.length > 0 && !l) return d.filter((a) => {
|
|
39
|
+
var r;
|
|
40
|
+
return !((r = a.guard) != null && r.length);
|
|
41
|
+
});
|
|
42
|
+
const o = { ...l ?? {}, ...t ?? {} };
|
|
43
|
+
return d.filter((a) => P(a.guard, o) !== !1);
|
|
44
|
+
}, [d, s, l, t]);
|
|
45
|
+
}
|
|
46
|
+
function U(e) {
|
|
47
|
+
return /remove-hold|unhold/i.test(e.key) ? /* @__PURE__ */ i(C, { className: "h-3.5 w-3.5" }) : /hold/i.test(e.key) ? /* @__PURE__ */ i(N, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ i($, { className: "h-3.5 w-3.5" });
|
|
48
|
+
}
|
|
49
|
+
function W(e) {
|
|
50
|
+
const n = e.summary && e.summary !== "Built-in" ? e.summary : e.label;
|
|
51
|
+
return e.require_reason ? `${n}. You’ll be asked for a justification, saved as a note on the record.` : `${n}.`;
|
|
52
|
+
}
|
|
53
|
+
function ae({
|
|
54
|
+
actions: e,
|
|
55
|
+
onPick: n
|
|
56
|
+
}) {
|
|
57
|
+
return e.length === 0 ? null : /* @__PURE__ */ i(w, { children: e.map((t) => /* @__PURE__ */ f(
|
|
58
|
+
"button",
|
|
59
|
+
{
|
|
60
|
+
type: "button",
|
|
61
|
+
"data-record-header-action": t.key,
|
|
62
|
+
"data-tip": W(t),
|
|
63
|
+
onClick: () => n(t),
|
|
64
|
+
className: S(
|
|
65
|
+
"inline-flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md border px-3 text-[13px] font-medium shadow-sm transition-colors",
|
|
66
|
+
t.variant === "danger" ? "border-red-300 text-red-600 hover:bg-red-50 dark:border-red-500/40 dark:text-red-400 dark:hover:bg-red-500/10" : "border-slate-300 bg-background text-slate-700 hover:bg-accent dark:border-border dark:text-slate-200"
|
|
67
|
+
),
|
|
68
|
+
children: [
|
|
69
|
+
U(t),
|
|
70
|
+
t.label
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
`${t.source}:${t.key}`
|
|
74
|
+
)) });
|
|
75
|
+
}
|
|
76
|
+
function se({
|
|
77
|
+
action: e,
|
|
78
|
+
collection: n,
|
|
79
|
+
itemId: t,
|
|
80
|
+
onClose: h,
|
|
81
|
+
onDone: m
|
|
82
|
+
}) {
|
|
83
|
+
const u = x(), d = q(), [s, l] = F(""), o = !!(e != null && e.require_reason), a = R({
|
|
84
|
+
mutationFn: async (r) => {
|
|
85
|
+
const c = { collection: n, ids: [t], reason: s.trim() || null }, g = r.source === "db" ? await u.request(y("/bulk-actions/run", { ...c, key: r.key })) : await u.request(y(`/bulk-actions/${r.key}/execute`, c));
|
|
86
|
+
return { a: r, result: g.data ?? {} };
|
|
87
|
+
},
|
|
88
|
+
onSuccess: ({ a: r, result: c }) => {
|
|
89
|
+
var g;
|
|
90
|
+
(g = c.errors) != null && g.length ? p.error(c.errors[0].error) : !c.succeeded && c.skipped ? p.info(`${r.label}: nothing to change on this record`) : p.success(`${r.label} — done`), K(d, n, [t]), d.invalidateQueries({ queryKey: ["record-header-action-guard", n] }), l(""), m == null || m(), h();
|
|
91
|
+
},
|
|
92
|
+
onError: (r) => p.error(A(r, "The action did not run"))
|
|
93
|
+
});
|
|
94
|
+
return /* @__PURE__ */ i(
|
|
95
|
+
T,
|
|
96
|
+
{
|
|
97
|
+
open: !!e,
|
|
98
|
+
onOpenChange: (r) => {
|
|
99
|
+
r || (l(""), h());
|
|
100
|
+
},
|
|
101
|
+
children: /* @__PURE__ */ f(D, { className: "sm:max-w-md", "data-record-header-action-dialog": "", children: [
|
|
102
|
+
/* @__PURE__ */ f(H, { children: [
|
|
103
|
+
/* @__PURE__ */ i(M, { children: e == null ? void 0 : e.label }),
|
|
104
|
+
/* @__PURE__ */ i(Q, { children: o ? "Say why — your justification is saved as a note on this record." : "Runs on this record. A justification, if you add one, is saved as a note." })
|
|
105
|
+
] }),
|
|
106
|
+
/* @__PURE__ */ f(_, { className: "space-y-1.5", children: [
|
|
107
|
+
/* @__PURE__ */ i("label", { htmlFor: "record-header-action-reason", className: "text-[12.5px] font-medium", children: o ? "Justification (required)" : "Justification (optional)" }),
|
|
108
|
+
/* @__PURE__ */ i(
|
|
109
|
+
J,
|
|
110
|
+
{
|
|
111
|
+
id: "record-header-action-reason",
|
|
112
|
+
autoFocus: !0,
|
|
113
|
+
rows: 4,
|
|
114
|
+
value: s,
|
|
115
|
+
onChange: (r) => l(r.target.value),
|
|
116
|
+
placeholder: "Why?"
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] }),
|
|
120
|
+
/* @__PURE__ */ f(E, { children: [
|
|
121
|
+
/* @__PURE__ */ i(k, { variant: "outline", onClick: h, disabled: a.isPending, children: "Cancel" }),
|
|
122
|
+
/* @__PURE__ */ i(
|
|
123
|
+
k,
|
|
124
|
+
{
|
|
125
|
+
onClick: () => e && a.mutate(e),
|
|
126
|
+
disabled: !e || a.isPending || o && !s.trim(),
|
|
127
|
+
className: "bg-nvr-cyan text-white hover:bg-nvr-cyan/90",
|
|
128
|
+
children: a.isPending ? "Working…" : e == null ? void 0 : e.label
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
] })
|
|
132
|
+
] })
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
ae as RecordHeaderActionButtons,
|
|
138
|
+
se as RecordHeaderActionDialog,
|
|
139
|
+
ie as useRecordHeaderActions
|
|
140
|
+
};
|
|
@@ -116,7 +116,7 @@ function ie({
|
|
|
116
116
|
" user",
|
|
117
117
|
e.length === 1 ? "" : "s"
|
|
118
118
|
] }),
|
|
119
|
-
e.map((a) => /* @__PURE__ */ t("div", { className: "px-2 py-0.5", children: /* @__PURE__ */ t(me, { userId: a.id, size: "compact" }) }, a.id))
|
|
119
|
+
e.map((a) => /* @__PURE__ */ t("div", { className: "flex px-2 py-0.5", children: /* @__PURE__ */ t(me, { userId: a.id, size: "compact" }) }, a.id))
|
|
120
120
|
]
|
|
121
121
|
}
|
|
122
122
|
),
|