@nivaro/react 0.3.98 → 0.3.100
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/useFormSchema.js +82 -85
- package/dist/hooks/useSessionRecorder.js +206 -175
- package/dist/index.d.ts +38 -13
- package/dist/index.js +182 -180
- package/dist/lib/commands.js +15 -11
- package/dist/shared/components/CollectionBrowserView.js +516 -503
- package/dist/shared/components/ItemEditForm.js +3021 -3019
- package/dist/shared/components/JobsTray.js +20 -16
- package/dist/shared/components/MyWorkView.js +133 -126
- package/dist/shared/components/NotificationBell.js +314 -288
- package/dist/shared/components/RecordCompare.js +38 -40
- package/dist/shared/components/RecordReadView.js +119 -119
- package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
- package/dist/shared/components/item-edit/InlineGridField.js +45 -45
- package/dist/shared/components/item-edit/InlineTableField.js +750 -749
- package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
- package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
- package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
- package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
- package/dist/shared/components/item-edit/related-missing.js +75 -19
- package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
- package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
- package/dist/shared/components/panels/BackgroundMove.js +175 -0
- package/dist/shared/components/panels/MoveAdvisory.js +204 -0
- package/dist/shared/components/panels/PipelinePanel.js +1450 -1219
- package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
- package/dist/shared/lib/commands.js +18 -14
- package/dist/shared/lib/error-hints.js +1 -1
- package/dist/shared/lib/job-failure-text.js +12 -0
- package/dist/shared/lib/move-failure.js +9 -0
- package/dist/shared/lib/obligation-banner.js +15 -14
- package/dist/shared/lib/partner-failure.js +71 -0
- package/dist/shared/lib/prefetch.js +73 -73
- package/dist/shared/lib/replay-checkout.js +18 -13
- package/dist/shared/lib/replay-context.js +90 -77
- package/dist/shared/lib/replay-idle.js +21 -0
- package/dist/shared/lib/replay-socket.js +21 -17
- package/dist/shared/lib/rum.js +56 -51
- package/dist/shared/lib/safe-error.js +17 -13
- package/dist/shared/lib/stale-chunk.js +69 -26
- package/dist/shared/lib/system-collections.js +20 -0
- package/package.json +1 -1
|
@@ -5,32 +5,33 @@ import { useState as f } from "react";
|
|
|
5
5
|
import { toast as y } from "sonner";
|
|
6
6
|
import { useNivaroClient as F } from "../../context.js";
|
|
7
7
|
import { post as L, get as T } from "../../lib/commands.js";
|
|
8
|
-
|
|
8
|
+
import { hasRecordExtras as _ } from "../../lib/system-collections.js";
|
|
9
|
+
const E = {
|
|
9
10
|
access: !1,
|
|
10
11
|
reasons: [{ type: "not_found", message: "There is no record with this id." }]
|
|
11
12
|
};
|
|
12
|
-
function
|
|
13
|
-
var
|
|
14
|
-
const e =
|
|
15
|
-
return ((e == null ? void 0 : e.status) ?? ((
|
|
13
|
+
function R(s) {
|
|
14
|
+
var r;
|
|
15
|
+
const e = s;
|
|
16
|
+
return ((e == null ? void 0 : e.status) ?? ((r = e == null ? void 0 : e.response) == null ? void 0 : r.status)) === 404;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function j(s, e) {
|
|
18
19
|
const o = e == null ? void 0 : e.trim();
|
|
19
20
|
if (o) return o.toLowerCase();
|
|
20
|
-
const
|
|
21
|
-
return /ies$/i.test(
|
|
21
|
+
const r = s.replace(/_/g, " ").trim();
|
|
22
|
+
return /ies$/i.test(r) ? r.replace(/ies$/i, "y") : /[^su]s$/i.test(r) ? r.slice(0, -1) : r || "record";
|
|
22
23
|
}
|
|
23
24
|
const b = 300;
|
|
24
|
-
function
|
|
25
|
-
collection:
|
|
25
|
+
function I({
|
|
26
|
+
collection: s,
|
|
26
27
|
itemId: e,
|
|
27
28
|
noun: o,
|
|
28
|
-
onBack:
|
|
29
|
+
onBack: r
|
|
29
30
|
}) {
|
|
30
|
-
const d =
|
|
31
|
+
const d = j(s, o), g = F(), [i, k] = f(!1), [c, N] = f(""), u = w({
|
|
31
32
|
mutationFn: () => g.request(
|
|
32
33
|
L("/access-requests", {
|
|
33
|
-
collection:
|
|
34
|
+
collection: s,
|
|
34
35
|
item: String(e),
|
|
35
36
|
...c.trim() ? { note: c.trim().slice(0, b) } : {}
|
|
36
37
|
})
|
|
@@ -40,12 +41,14 @@ function z({
|
|
|
40
41
|
},
|
|
41
42
|
onError: () => y.error("Could not send the request")
|
|
42
43
|
}), { data: m, isLoading: x } = q({
|
|
43
|
-
queryKey: ["access-explain",
|
|
44
|
+
queryKey: ["access-explain", s, String(e)],
|
|
44
45
|
queryFn: () => g.request(
|
|
45
|
-
T(`/access-explain/${
|
|
46
|
-
).then((
|
|
46
|
+
T(`/access-explain/${s}/${encodeURIComponent(e)}`)
|
|
47
|
+
).then((a) => a.data ?? null).catch((a) => R(a) ? E : null),
|
|
48
|
+
// "Why can't I see this" is refused for system tables by name: the plain message stands.
|
|
49
|
+
enabled: _(s),
|
|
47
50
|
staleTime: 3e4
|
|
48
|
-
}), p = (m == null ? void 0 : m.reasons) ?? [], l = p.some((
|
|
51
|
+
}), p = (m == null ? void 0 : m.reasons) ?? [], l = p.some((a) => a.type === "not_found");
|
|
49
52
|
return /* @__PURE__ */ t("div", { className: "flex flex-1 items-start justify-center px-6 py-16", children: /* @__PURE__ */ n("div", { className: "w-full max-w-[560px] rounded-xl border border-slate-200 bg-white p-8 dark:border-border dark:bg-card", children: [
|
|
50
53
|
/* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
|
|
51
54
|
/* @__PURE__ */ t("span", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ t($, { className: "h-[18px] w-[18px] text-slate-500 dark:text-slate-400" }) }),
|
|
@@ -60,20 +63,20 @@ function z({
|
|
|
60
63
|
] }) : l ? null : p.length > 0 ? (
|
|
61
64
|
// A missing record is said once, in the heading (army11 f3: the
|
|
62
65
|
// page gave two different reasons for the same thing).
|
|
63
|
-
p.map((
|
|
66
|
+
p.map((a, v) => /* @__PURE__ */ t(
|
|
64
67
|
"div",
|
|
65
68
|
{
|
|
66
69
|
className: "rounded-lg border border-slate-200 bg-slate-50 px-3.5 py-2.5 text-[13px] leading-relaxed text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-300",
|
|
67
|
-
children:
|
|
70
|
+
children: a.message
|
|
68
71
|
},
|
|
69
|
-
`${
|
|
72
|
+
`${a.type}-${a.dimension ?? v}`
|
|
70
73
|
))
|
|
71
74
|
) : /* @__PURE__ */ t("div", { className: "rounded-lg border border-slate-200 bg-slate-50 px-3.5 py-2.5 text-[13px] leading-relaxed text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-300", children: "This record could not be loaded. It may have been deleted, or an access rule may be hiding it." }) }),
|
|
72
75
|
!l && !x && !i && /* @__PURE__ */ n("div", { className: "mt-4", children: [
|
|
73
76
|
/* @__PURE__ */ n(
|
|
74
77
|
"label",
|
|
75
78
|
{
|
|
76
|
-
htmlFor: `access-note-${
|
|
79
|
+
htmlFor: `access-note-${s}-${e}`,
|
|
77
80
|
className: "block text-[12px] font-medium text-slate-700 dark:text-slate-300",
|
|
78
81
|
children: [
|
|
79
82
|
"Need it? Say what for ",
|
|
@@ -84,9 +87,9 @@ function z({
|
|
|
84
87
|
/* @__PURE__ */ t(
|
|
85
88
|
"textarea",
|
|
86
89
|
{
|
|
87
|
-
id: `access-note-${
|
|
90
|
+
id: `access-note-${s}-${e}`,
|
|
88
91
|
value: c,
|
|
89
|
-
onChange: (
|
|
92
|
+
onChange: (a) => N(a.target.value.slice(0, b)),
|
|
90
93
|
rows: 2,
|
|
91
94
|
maxLength: b,
|
|
92
95
|
placeholder: `e.g. I approve this ${d} for my team`,
|
|
@@ -117,11 +120,11 @@ function z({
|
|
|
117
120
|
] })
|
|
118
121
|
}
|
|
119
122
|
),
|
|
120
|
-
|
|
123
|
+
r && /* @__PURE__ */ n(
|
|
121
124
|
"button",
|
|
122
125
|
{
|
|
123
126
|
type: "button",
|
|
124
|
-
onClick:
|
|
127
|
+
onClick: r,
|
|
125
128
|
className: "mt-5 inline-flex items-center gap-1.5 rounded-md border border-slate-200 px-3 py-1.5 text-[12px] font-medium text-slate-600 hover:bg-slate-50 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.03]",
|
|
126
129
|
children: [
|
|
127
130
|
/* @__PURE__ */ t(S, { className: "h-3.5 w-3.5" }),
|
|
@@ -132,7 +135,7 @@ function z({
|
|
|
132
135
|
] }) });
|
|
133
136
|
}
|
|
134
137
|
export {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
I as AccessDeniedPanel,
|
|
139
|
+
R as explainMissing,
|
|
140
|
+
j as recordNoun
|
|
138
141
|
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsxs as n, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { Loader2 as y, AlertTriangle as _ } from "lucide-react";
|
|
3
|
+
import { useRef as u, useEffect as w, useMemo as p } from "react";
|
|
4
|
+
import { useItemEditAuth as f } from "../../context.js";
|
|
5
|
+
import { describeError as E } from "../../lib/error-message.js";
|
|
6
|
+
import { partnerFailureText as M, withoutMoveLabel as T } from "../../lib/partner-failure.js";
|
|
7
|
+
import { partnerOutcome as ee, partnerWords as te } from "../../lib/partner-failure.js";
|
|
8
|
+
import { formatRelative as b, cn as x } from "../../lib/utils.js";
|
|
9
|
+
import { ErrorDetails as I } from "../ErrorNotice.js";
|
|
10
|
+
import { useOverflowTip as R } from "../TipLayer.js";
|
|
11
|
+
import { Button as O } from "../ui/button.js";
|
|
12
|
+
const L = 4e3;
|
|
13
|
+
function W(e) {
|
|
14
|
+
return e != null && e.running_move ? L : !1;
|
|
15
|
+
}
|
|
16
|
+
function Y(e, t) {
|
|
17
|
+
const r = u(!1), s = u(t);
|
|
18
|
+
s.current = t, w(() => {
|
|
19
|
+
r.current && !e && s.current(), r.current = e;
|
|
20
|
+
}, [e]);
|
|
21
|
+
}
|
|
22
|
+
function q(e, t) {
|
|
23
|
+
return (e ?? []).some((r) => r.id === t && r.background === !0) ? { accept_pending: !0 } : {};
|
|
24
|
+
}
|
|
25
|
+
function H(e) {
|
|
26
|
+
const t = e == null ? void 0 : e.data;
|
|
27
|
+
return (t == null ? void 0 : t.background) === !0 && t.run ? t.run : null;
|
|
28
|
+
}
|
|
29
|
+
function S(e, t) {
|
|
30
|
+
return !!e && !!t && e.toUpperCase() === t.toUpperCase();
|
|
31
|
+
}
|
|
32
|
+
function k(e, t) {
|
|
33
|
+
return e.mode === "auto" ? "Started automatically" : S(e.started_by, t) ? "You started it" : e.started_by_name ? `Started by ${e.started_by_name}` : "Started";
|
|
34
|
+
}
|
|
35
|
+
function B(e) {
|
|
36
|
+
return T(e.reason, e.transition_label);
|
|
37
|
+
}
|
|
38
|
+
const h = "flex items-start gap-2.5", g = "is running. Other moves wait until it finishes.", N = (e) => {
|
|
39
|
+
var t;
|
|
40
|
+
return ((t = e.transition_label) == null ? void 0 : t.trim()) || "A move";
|
|
41
|
+
};
|
|
42
|
+
function J(e) {
|
|
43
|
+
return `${N(e)} ${g}`;
|
|
44
|
+
}
|
|
45
|
+
const C = {
|
|
46
|
+
refused: "did not go through. The record was not moved.",
|
|
47
|
+
interrupted: "stopped before it finished.",
|
|
48
|
+
failed: "ran into a problem."
|
|
49
|
+
};
|
|
50
|
+
function K({
|
|
51
|
+
run: e,
|
|
52
|
+
floating: t,
|
|
53
|
+
className: r,
|
|
54
|
+
style: s
|
|
55
|
+
}) {
|
|
56
|
+
const { userId: m } = f(), d = N(e);
|
|
57
|
+
return /* @__PURE__ */ n(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
role: "status",
|
|
61
|
+
"data-running-move": e.transition_id ?? "",
|
|
62
|
+
className: x(
|
|
63
|
+
h,
|
|
64
|
+
t ? "rounded-lg border border-sky-200 bg-sky-50 p-3 shadow-lg dark:border-sky-500/30 dark:bg-sky-950" : "border-t border-sky-200/80 bg-sky-50/70 px-4 py-2.5 dark:border-sky-500/20 dark:bg-sky-500/[0.06]",
|
|
65
|
+
r
|
|
66
|
+
),
|
|
67
|
+
style: s,
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ a(
|
|
70
|
+
y,
|
|
71
|
+
{
|
|
72
|
+
"aria-hidden": !0,
|
|
73
|
+
className: "mt-[3px] h-3.5 w-3.5 shrink-0 animate-spin text-sky-600 motion-reduce:animate-none dark:text-sky-400"
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
|
|
77
|
+
/* @__PURE__ */ n("p", { className: "break-words text-[13px] leading-snug text-slate-800 dark:text-slate-100", children: [
|
|
78
|
+
/* @__PURE__ */ a("span", { className: "font-medium", children: d }),
|
|
79
|
+
" ",
|
|
80
|
+
g
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ n("p", { className: "mt-0.5 text-[11.5px] text-sky-800/80 dark:text-sky-300/80", children: [
|
|
83
|
+
k(e, m),
|
|
84
|
+
" · ",
|
|
85
|
+
b(e.started_at),
|
|
86
|
+
" · this page updates on its own"
|
|
87
|
+
] })
|
|
88
|
+
] })
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function Q({
|
|
94
|
+
problem: e,
|
|
95
|
+
onRetry: t,
|
|
96
|
+
retryDisabled: r,
|
|
97
|
+
className: s
|
|
98
|
+
}) {
|
|
99
|
+
var c;
|
|
100
|
+
const { userId: m } = f(), d = ((c = e.transition_label) == null ? void 0 : c.trim()) || "The move", o = B(e), i = p(() => o ? E({ message: o }, "") : null, [o]), l = p(
|
|
101
|
+
() => (o ? M(o) : null) ?? (i == null ? void 0 : i.title.trim()) ?? "",
|
|
102
|
+
[o, i]
|
|
103
|
+
), v = R(l);
|
|
104
|
+
return /* @__PURE__ */ n(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
role: "note",
|
|
108
|
+
"data-move-problem": e.result,
|
|
109
|
+
className: x(
|
|
110
|
+
h,
|
|
111
|
+
"border-t border-amber-200/80 bg-amber-50/70 px-4 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/[0.06]",
|
|
112
|
+
s
|
|
113
|
+
),
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ a(
|
|
116
|
+
_,
|
|
117
|
+
{
|
|
118
|
+
"aria-hidden": !0,
|
|
119
|
+
className: "mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-400"
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
/* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
|
|
123
|
+
/* @__PURE__ */ n("p", { className: "break-words text-[13px] leading-snug text-slate-800 dark:text-slate-100", children: [
|
|
124
|
+
/* @__PURE__ */ a("span", { className: "font-medium", children: d }),
|
|
125
|
+
" ",
|
|
126
|
+
C[e.result]
|
|
127
|
+
] }),
|
|
128
|
+
l && /* @__PURE__ */ a(
|
|
129
|
+
"p",
|
|
130
|
+
{
|
|
131
|
+
ref: v,
|
|
132
|
+
"data-move-problem-reason": !0,
|
|
133
|
+
className: "mt-0.5 line-clamp-3 break-words text-[12px] leading-snug text-slate-700 dark:text-slate-300",
|
|
134
|
+
children: l
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ n("p", { className: "mt-0.5 text-[11.5px] text-amber-800/80 dark:text-amber-300/80", children: [
|
|
138
|
+
k(e, m),
|
|
139
|
+
" · ",
|
|
140
|
+
b(e.finished_at ?? e.started_at)
|
|
141
|
+
] }),
|
|
142
|
+
i && /* @__PURE__ */ a(I, { description: i, action: d, className: "mt-1" })
|
|
143
|
+
] }),
|
|
144
|
+
t && /* @__PURE__ */ a(
|
|
145
|
+
O,
|
|
146
|
+
{
|
|
147
|
+
type: "button",
|
|
148
|
+
size: "sm",
|
|
149
|
+
variant: "outline",
|
|
150
|
+
className: "h-7 shrink-0 text-[12px]",
|
|
151
|
+
disabled: r,
|
|
152
|
+
onClick: t,
|
|
153
|
+
"data-move-problem-retry": !0,
|
|
154
|
+
children: "Try again"
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
export {
|
|
162
|
+
Q as MoveProblemNotice,
|
|
163
|
+
L as RUNNING_MOVE_POLL_MS,
|
|
164
|
+
K as RunningMoveNotice,
|
|
165
|
+
ee as partnerOutcome,
|
|
166
|
+
te as partnerWords,
|
|
167
|
+
q as pendingOptIn,
|
|
168
|
+
B as problemReason,
|
|
169
|
+
W as runningMovePoll,
|
|
170
|
+
J as runningMoveTip,
|
|
171
|
+
S as sameMoveId,
|
|
172
|
+
k as startedBy,
|
|
173
|
+
H as startedInBackground,
|
|
174
|
+
Y as useRunEnded
|
|
175
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { jsxs as c, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useMutation as z, useQueryClient as O, useQuery as P } from "@tanstack/react-query";
|
|
3
|
+
import { AlertTriangle as Q, Loader2 as D } from "lucide-react";
|
|
4
|
+
import { useState as S, useRef as T, useEffect as _ } from "react";
|
|
5
|
+
import { toast as F } from "sonner";
|
|
6
|
+
import { useNivaroClient as U } from "../../context.js";
|
|
7
|
+
import { get as B, post as j } from "../../lib/commands.js";
|
|
8
|
+
import { toastError as H } from "../../lib/error-toast.js";
|
|
9
|
+
import { cn as V } from "../../lib/utils.js";
|
|
10
|
+
import { invalidateRecordData as X } from "../item-edit/RecordInsights.js";
|
|
11
|
+
import { Button as y } from "../ui/button.js";
|
|
12
|
+
const Y = {
|
|
13
|
+
PRIORITY_REQUIRED: "priority",
|
|
14
|
+
// A held record does not move forward (efp-ops hold-gate, army 11): taking
|
|
15
|
+
// the hold off is one deliberate, noted step, then the move is tried again.
|
|
16
|
+
ON_HOLD: "remove-hold"
|
|
17
|
+
};
|
|
18
|
+
function G(n) {
|
|
19
|
+
var o, t;
|
|
20
|
+
return ((t = (o = n.fix) == null ? void 0 : o.action) == null ? void 0 : t.trim()) || Y[n.code] || null;
|
|
21
|
+
}
|
|
22
|
+
function ie(n) {
|
|
23
|
+
var t;
|
|
24
|
+
const o = /* @__PURE__ */ new Map();
|
|
25
|
+
for (const e of n) {
|
|
26
|
+
if (!((t = e.advisory) != null && t.message)) continue;
|
|
27
|
+
const i = `${e.advisory.code}\0${e.advisory.message}`, s = o.get(i);
|
|
28
|
+
s ? s.moves.push(e) : o.set(i, { advisory: e.advisory, moves: [e] });
|
|
29
|
+
}
|
|
30
|
+
return [...o.values()];
|
|
31
|
+
}
|
|
32
|
+
function J(n, o, t) {
|
|
33
|
+
const e = U(), i = O(), { data: s, isLoading: d } = P({
|
|
34
|
+
queryKey: ["bulk-actions-available-one", n, t],
|
|
35
|
+
enabled: !!t,
|
|
36
|
+
queryFn: async () => ((await e.request(
|
|
37
|
+
B("/bulk-actions/available", { collection: n })
|
|
38
|
+
)).data ?? []).find((u) => u.key === t) ?? null,
|
|
39
|
+
staleTime: 6e4
|
|
40
|
+
});
|
|
41
|
+
return { action: s ?? null, isLoading: !!t && d, run: async (p) => {
|
|
42
|
+
var h, x;
|
|
43
|
+
if (!s) throw new Error("This action is not available");
|
|
44
|
+
const u = { collection: n, ids: [o], reason: p.trim() || null }, m = (s.source === "extension" ? await e.request(j(`/bulk-actions/${s.key}/execute`, u)) : await e.request(j("/bulk-actions/run", { ...u, key: s.key }))).data ?? {};
|
|
45
|
+
if (s.source !== "extension" && !(m.succeeded && m.succeeded > 0))
|
|
46
|
+
throw new Error(((x = (h = m.errors) == null ? void 0 : h[0]) == null ? void 0 : x.error) || `${s.label} did not change the record`);
|
|
47
|
+
X(i, n, o);
|
|
48
|
+
} };
|
|
49
|
+
}
|
|
50
|
+
function le({
|
|
51
|
+
collection: n,
|
|
52
|
+
item: o,
|
|
53
|
+
advisory: t,
|
|
54
|
+
armedMove: e,
|
|
55
|
+
stops: i,
|
|
56
|
+
floating: s,
|
|
57
|
+
onFixed: d,
|
|
58
|
+
onDismiss: b,
|
|
59
|
+
className: p,
|
|
60
|
+
style: u
|
|
61
|
+
}) {
|
|
62
|
+
var A, I;
|
|
63
|
+
const { action: r, isLoading: m, run: h } = J(n, o, G(t)), [x, k] = S(!1), [N, v] = S(""), R = T(null), C = T(null), g = !!r && (x || !!e);
|
|
64
|
+
_(() => {
|
|
65
|
+
var a;
|
|
66
|
+
g && ((a = R.current) == null || a.focus());
|
|
67
|
+
}, [g]);
|
|
68
|
+
const $ = e == null ? void 0 : e.id;
|
|
69
|
+
_(() => {
|
|
70
|
+
var a, L;
|
|
71
|
+
$ && ((L = (a = C.current) == null ? void 0 : a.scrollIntoView) == null || L.call(a, { block: "nearest" }));
|
|
72
|
+
}, [$]);
|
|
73
|
+
const f = ((I = (A = t.fix) == null ? void 0 : A.label) == null ? void 0 : I.trim()) || (r == null ? void 0 : r.label) || "", w = z({
|
|
74
|
+
mutationFn: () => h(N),
|
|
75
|
+
onSuccess: () => {
|
|
76
|
+
F.success(
|
|
77
|
+
e != null && e.confirms ? `Done: ${f}. Confirm ${e.label} to finish.` : `Done: ${f}.`
|
|
78
|
+
), k(!1), v(""), d == null || d(e ?? null);
|
|
79
|
+
},
|
|
80
|
+
onError: (a) => H(a, `${(r == null ? void 0 : r.label) ?? "The action"} failed`)
|
|
81
|
+
}), q = !w.isPending && (!(r != null && r.require_reason) || N.trim().length > 0), E = () => {
|
|
82
|
+
k(!1), v(""), b == null || b();
|
|
83
|
+
};
|
|
84
|
+
return /* @__PURE__ */ c(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
ref: C,
|
|
88
|
+
role: e ? "status" : "note",
|
|
89
|
+
"data-move-advisory": t.code,
|
|
90
|
+
className: V(
|
|
91
|
+
"flex items-start gap-2.5",
|
|
92
|
+
s ? "rounded-lg border border-amber-200 bg-amber-50 p-3 shadow-lg dark:border-amber-500/30 dark:bg-amber-950" : "border-t border-amber-200/80 bg-amber-50/70 px-4 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/[0.06]",
|
|
93
|
+
e && "ring-1 ring-inset ring-amber-400 dark:ring-amber-400/60",
|
|
94
|
+
p
|
|
95
|
+
),
|
|
96
|
+
style: u,
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ l(
|
|
99
|
+
Q,
|
|
100
|
+
{
|
|
101
|
+
"aria-hidden": !0,
|
|
102
|
+
className: "mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-400"
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ c("div", { className: "min-w-0 flex-1 space-y-2", children: [
|
|
106
|
+
/* @__PURE__ */ c("div", { children: [
|
|
107
|
+
/* @__PURE__ */ l("p", { className: "break-words text-[13px] leading-snug text-slate-800 dark:text-slate-100", children: t.message }),
|
|
108
|
+
!!(i != null && i.length) && /* @__PURE__ */ c(
|
|
109
|
+
"p",
|
|
110
|
+
{
|
|
111
|
+
className: "mt-0.5 text-[11.5px] text-amber-800/80 dark:text-amber-300/80",
|
|
112
|
+
"data-move-advisory-stops": !0,
|
|
113
|
+
children: [
|
|
114
|
+
"Stops: ",
|
|
115
|
+
i.join(", ")
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] }),
|
|
120
|
+
g && r && /* @__PURE__ */ c(
|
|
121
|
+
"form",
|
|
122
|
+
{
|
|
123
|
+
className: "space-y-2",
|
|
124
|
+
onSubmit: (a) => {
|
|
125
|
+
a.preventDefault(), q && w.mutate();
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
r.require_reason && /* @__PURE__ */ l(
|
|
129
|
+
"input",
|
|
130
|
+
{
|
|
131
|
+
ref: R,
|
|
132
|
+
type: "text",
|
|
133
|
+
value: N,
|
|
134
|
+
onChange: (a) => v(a.target.value),
|
|
135
|
+
placeholder: "Reason (required)",
|
|
136
|
+
"aria-label": "Reason",
|
|
137
|
+
className: "w-full rounded-md border border-slate-200 bg-white px-3 py-1.5 text-[13px] text-slate-900 placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30 dark:border-border dark:bg-card dark:text-slate-100 dark:placeholder-slate-400"
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ c("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [
|
|
141
|
+
/* @__PURE__ */ l(
|
|
142
|
+
y,
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
size: "sm",
|
|
146
|
+
variant: "ghost",
|
|
147
|
+
className: "h-7 text-[12px]",
|
|
148
|
+
onClick: E,
|
|
149
|
+
children: "Not now"
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ c(
|
|
153
|
+
y,
|
|
154
|
+
{
|
|
155
|
+
type: "submit",
|
|
156
|
+
size: "sm",
|
|
157
|
+
className: "h-7 gap-1.5 text-[12px]",
|
|
158
|
+
disabled: !q,
|
|
159
|
+
"data-move-advisory-run": !0,
|
|
160
|
+
children: [
|
|
161
|
+
w.isPending && /* @__PURE__ */ l(D, { className: "h-3 w-3 animate-spin" }),
|
|
162
|
+
e ? `${f}, then ${e.label}` : f
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
] })
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
e && !r && !m && s && /* @__PURE__ */ l("div", { className: "flex justify-end", children: /* @__PURE__ */ l(
|
|
171
|
+
y,
|
|
172
|
+
{
|
|
173
|
+
type: "button",
|
|
174
|
+
size: "sm",
|
|
175
|
+
variant: "ghost",
|
|
176
|
+
className: "h-7 text-[12px]",
|
|
177
|
+
onClick: E,
|
|
178
|
+
children: "Close"
|
|
179
|
+
}
|
|
180
|
+
) })
|
|
181
|
+
] }),
|
|
182
|
+
r && !g && /* @__PURE__ */ l(
|
|
183
|
+
y,
|
|
184
|
+
{
|
|
185
|
+
type: "button",
|
|
186
|
+
size: "sm",
|
|
187
|
+
variant: "outline",
|
|
188
|
+
className: "h-7 shrink-0 text-[12px]",
|
|
189
|
+
onClick: () => k(!0),
|
|
190
|
+
"data-move-advisory-fix": r.key,
|
|
191
|
+
children: f
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
le as MoveAdvisoryNotice,
|
|
200
|
+
Y as REFUSAL_FIX_ACTIONS,
|
|
201
|
+
G as advisoryFixKey,
|
|
202
|
+
ie as distinctAdvisories,
|
|
203
|
+
J as useRecordFixAction
|
|
204
|
+
};
|